ssarathi/Text_Summarizer_Using_Transformers
029
1---2language: en3license: mit4tags:5- summarization6- nlp7- transformer8- text-generation9- huggingface10datasets:11- cnn_dailymail12metrics:13- rouge14widget:15- text: "The quick brown fox jumps over the lazy dog. This is a sample article for testing summarization."16---17 18# Text Summarization Model19 20## Model Overview21This is a **text summarization model** built using a Seq2Seq architecture. 22It was trained on the **CNN/DailyMail dataset (3.0.0)** and is capable of generating concise summaries of news articles or other long-form texts.23 24**Intended Use:** 25- Summarizing articles, documents, or reports. 26- Extracting key points from text for quick understanding.27 28**Limitations & Biases:** 29- May struggle with extremely long articles or highly technical content. 30- Generated summaries may occasionally miss nuanced details.31 32---33 34 35## Training Details36- **Dataset**: CNN/DailyMail (3.0.0 version) 37- **Preprocessing**: Truncation at 512 tokens for input, summaries capped at 150 tokens. 38- **Hyperparameters**: 39 - Optimizer: AdamW (PyTorch) 40 - Learning rate: 2e-5 41 - Batch size: 4 (per device) 42 - Epochs: 10 43- **Evaluation Metrics**: ROUGE-1, ROUGE-2, ROUGE-L 44 45---46 47## Evaluation Results48| Metric | Score (%) |49|-----------|-----------|50| ROUGE-1 | 83.3 |51| ROUGE-2 | 60.0 |52| ROUGE-L | 83.3 |53| ROUGE-Lsum| 83.3 |54 55 56---57 58## Example Usage59```python60from transformers import AutoTokenizer, AutoModelForSeq2SeqLM61 62tokenizer = AutoTokenizer.from_pretrained("your-username/your-model-name")63model = AutoModelForSeq2SeqLM.from_pretrained("your-username/your-model-name")64 65text = "The stock market saw a significant drop today due to rising inflation concerns. Investors are cautious ahead of the Federal Reserve's upcoming decision."66 67inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)68summary_ids = model.generate(**inputs, max_length=150, num_beams=4, early_stopping=True)69 70print(tokenizer.decode(summary_ids[0], skip_special_tokens=True))71 