Update README.md
Browse files
README.md
CHANGED
@@ -16,25 +16,38 @@ This model is based on the Facebook BART (Bidirectional and Auto-Regressive Tran
|
|
16 |
- **Fine-tuned for**: Text Summarization
|
17 |
- **Fine-tuning dataset**: [xsum]
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
### Inference
|
20 |
|
21 |
-
```
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
|
25 |
-
model = AutoModelForSeq2SeqLM.from_pretrained("suriya7/text_summarize")
|
26 |
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
summary_ids = model.generate(inputs['input_ids'],max_new_tokens=100, do_sample=False)
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
text_to_summarize = "Now, there is no doubt that one of the most important aspects of any Pixel phone is its camera.
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
summary = generate_summary(text_to_summarize)
|
|
|
16 |
- **Fine-tuned for**: Text Summarization
|
17 |
- **Fine-tuning dataset**: [xsum]
|
18 |
|
19 |
+
## Usage:
|
20 |
+
|
21 |
+
### Installation:
|
22 |
+
|
23 |
+
You can install the necessary libraries using pip:
|
24 |
+
|
25 |
+
```bash
|
26 |
+
pip install transformers
|
27 |
+
pip datasets
|
28 |
+
pip evaluate
|
29 |
+
pip rouge_score
|
30 |
+
|
31 |
### Inference
|
32 |
|
33 |
+
```bash
|
34 |
+
# Load model directly
|
35 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
36 |
+
|
37 |
+
tokenizer = AutoTokenizer.from_pretrained("suriya7/text_summarize")
|
38 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("suriya7/text_summarize")
|
39 |
|
40 |
+
def generate_summary(text):
|
|
|
41 |
|
42 |
+
inputs = tokenizer([text], max_length=1024, return_tensors='pt', truncation=True)
|
43 |
|
44 |
+
summary_ids = model.generate(inputs['input_ids'],max_new_tokens=100, do_sample=False)
|
|
|
|
|
45 |
|
46 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
47 |
+
return summary
|
48 |
+
|
49 |
+
text_to_summarize = "Now, there is no doubt that one of the most important aspects of any Pixel phone is its camera.
|
50 |
+
And there might be good news for all camera lovers. Rumours have suggested that the Pixel 9 could come with a telephoto lens,
|
51 |
+
improving its photography capabilities even further. Google will likely continue to focus on using AI to
|
52 |
+
enhance its camera performance, in order to make sure that Pixel phones remain top contenders in the world of mobile photography"
|
53 |
+
summary = generate_summary(text_to_summarize)
|