Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,7 +10,7 @@ model = T5ForConditionalGeneration.from_pretrained(model_name)
|
|
| 10 |
def summarize_text(text):
|
| 11 |
input_text = "summarize: " + text.strip()
|
| 12 |
input_ids = tokenizer.encode(input_text, return_tensors="pt", max_length=500, truncation=True)
|
| 13 |
-
summary_ids = model.generate(input_ids, max_length=
|
| 14 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 15 |
return summary
|
| 16 |
|
|
|
|
| 10 |
def summarize_text(text):
|
| 11 |
input_text = "summarize: " + text.strip()
|
| 12 |
input_ids = tokenizer.encode(input_text, return_tensors="pt", max_length=500, truncation=True)
|
| 13 |
+
summary_ids = model.generate(input_ids, max_length=500, min_length=498, length_penalty=2.0, num_beams=2, early_stopping=True)
|
| 14 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 15 |
return summary
|
| 16 |
|