Spaces:
Runtime error
Runtime error
EmreYY20
commited on
Commit
•
a5dca46
1
Parent(s):
989abb3
update
Browse files- abstractive_model.py +8 -5
abstractive_model.py
CHANGED
@@ -1,7 +1,10 @@
|
|
1 |
-
from transformers import
|
2 |
-
import torch
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
|
|
|
|
|
|
|
|
7 |
return summary
|
|
|
1 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
|
2 |
|
3 |
+
tokenizer = AutoTokenizer.from_pretrained("EE21/Fine-tuned-BART-ToS-Summarization")
|
4 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("EE21/Fine-tuned-BART-ToS-Summarization")
|
5 |
+
|
6 |
+
def summarize_with_bart(input_text):
|
7 |
+
inputs = tokenizer.encode("summarize: " + input_text, return_tensors="pt", max_length=1024, truncation=True)
|
8 |
+
summary_ids = model.generate(inputs, max_length=150, min_length=40, length_penalty=2.0, num_beams=4, early_stopping=True)
|
9 |
+
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
10 |
return summary
|