Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -83,7 +83,14 @@ def summarize_text(text, input_language="English", output_language="English"):
|
|
| 83 |
|
| 84 |
# Summarize the text using mBART
|
| 85 |
inputs = multilingual_summarization_tokenizer(text, return_tensors='pt', padding=True, truncation=True)
|
| 86 |
-
summary_ids = multilingual_summarization_model.generate(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
summary = multilingual_summarization_tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 88 |
|
| 89 |
# Translate summary to the output language if needed
|
|
|
|
| 83 |
|
| 84 |
# Summarize the text using mBART
|
| 85 |
inputs = multilingual_summarization_tokenizer(text, return_tensors='pt', padding=True, truncation=True)
|
| 86 |
+
summary_ids = multilingual_summarization_model.generate(
|
| 87 |
+
inputs['input_ids'],
|
| 88 |
+
num_beams=6, # Increase the number of beams for better quality
|
| 89 |
+
max_length=1024, # Increase the maximum length
|
| 90 |
+
min_length=256, # Set a minimum length for the summary
|
| 91 |
+
length_penalty=2.0, # Adjust length penalty to control the length of the summary
|
| 92 |
+
early_stopping=True
|
| 93 |
+
)
|
| 94 |
summary = multilingual_summarization_tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
| 95 |
|
| 96 |
# Translate summary to the output language if needed
|