shahrukhx01
commited on
Commit
·
0581fd9
1
Parent(s):
80a8cca
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from transformers import BartTokenizer, BartForConditionalGeneration, BartConfig
|
2 |
+
|
3 |
+
model = BartForConditionalGeneration.from_pretrained('facebook/bart-large-cnn')
|
4 |
+
tokenizer = BartTokenizer.from_pretrained('facebook/bart-large-cnn')
|
5 |
+
|
6 |
+
ARTICLE_TO_SUMMARIZE = "My friends are cool but they eat too many carbs."
|
7 |
+
inputs = tokenizer([ARTICLE_TO_SUMMARIZE], max_length=1024, return_tensors='pt')
|
8 |
+
|
9 |
+
# Generate Summary
|
10 |
+
summary_ids = model.generate(inputs['input_ids'], num_beams=4, max_length=5, early_stopping=True)
|
11 |
+
print([tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=False) for g in summary_ids])
|