Spaces:
Sleeping
Sleeping
Yaron Koresh
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -552,14 +552,18 @@ def summarize_text(
|
|
552 |
text, max_len=20, min_len=10
|
553 |
):
|
554 |
log(f'CALL summarize_text')
|
555 |
-
inputs = tokenizer
|
|
|
556 |
while len(inputs[0]) > max_len:
|
557 |
-
|
558 |
-
|
|
|
559 |
length_penalty=2.0,
|
560 |
num_beams=4,
|
561 |
early_stopping=True
|
562 |
)
|
|
|
|
|
563 |
summary = tokenizer.decode(inputs[0])
|
564 |
log(f'RET summarize_text with summary as {summary}')
|
565 |
return summary
|
|
|
552 |
text, max_len=20, min_len=10
|
553 |
):
|
554 |
log(f'CALL summarize_text')
|
555 |
+
inputs = tokenizer("summarize: " + text, return_tensors="pt", max_length=float('inf'), truncation=False)
|
556 |
+
i = 1
|
557 |
while len(inputs[0]) > max_len:
|
558 |
+
print(f'DBG summarize_text 1 {i}')
|
559 |
+
outputs = model.generate(
|
560 |
+
inputs[:512],
|
561 |
length_penalty=2.0,
|
562 |
num_beams=4,
|
563 |
early_stopping=True
|
564 |
)
|
565 |
+
inputs[0] = outputs[0] + inputs[0][512:]
|
566 |
+
i = i + 1
|
567 |
summary = tokenizer.decode(inputs[0])
|
568 |
log(f'RET summarize_text with summary as {summary}')
|
569 |
return summary
|