Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,12 +5,14 @@ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
|
| 5 |
model_id = "hramphul/bart-large-cnn"
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 7 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
|
|
|
| 8 |
|
| 9 |
def summarize(text, max_len, min_len):
|
| 10 |
inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
|
| 11 |
with torch.no_grad():
|
| 12 |
ids = model.generate(
|
| 13 |
inputs["input_ids"],
|
|
|
|
| 14 |
max_length=int(max_len),
|
| 15 |
min_length=int(min_len),
|
| 16 |
num_beams=4,
|
|
|
|
| 5 |
model_id = "hramphul/bart-large-cnn"
|
| 6 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 7 |
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
|
| 8 |
+
model.eval()
|
| 9 |
|
| 10 |
def summarize(text, max_len, min_len):
|
| 11 |
inputs = tokenizer(text, return_tensors="pt", max_length=1024, truncation=True)
|
| 12 |
with torch.no_grad():
|
| 13 |
ids = model.generate(
|
| 14 |
inputs["input_ids"],
|
| 15 |
+
attention_mask=inputs["attention_mask"],
|
| 16 |
max_length=int(max_len),
|
| 17 |
min_length=int(min_len),
|
| 18 |
num_beams=4,
|