Update app.py
Browse files
app.py
CHANGED
|
@@ -9,8 +9,8 @@ model = T5ForConditionalGeneration.from_pretrained(model_name)
|
|
| 9 |
# Define the summarization function
|
| 10 |
def summarize_text(text):
|
| 11 |
input_text = "summarize: " + text.strip()
|
| 12 |
-
input_ids = tokenizer.encode(input_text, return_tensors="pt", max_length=
|
| 13 |
-
summary_ids = model.generate(input_ids, max_length=
|
| 14 |
summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 15 |
return summary
|
| 16 |
|
|
|
|
| 9 |
# Define the summarization function
|
| 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=140, min_length=40, 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 |
|