Spaces:
Runtime error
Runtime error
Commit
·
74899d4
1
Parent(s):
4e2a680
Update app.py
Browse files
app.py
CHANGED
@@ -29,21 +29,8 @@ def summ_t5(text):
|
|
29 |
return summary_text
|
30 |
|
31 |
def summ_bert(text):
|
32 |
-
encoding =
|
33 |
-
|
34 |
-
input_ids=encoding["input_ids"], attention_mask=encoding["attention_mask"],
|
35 |
-
max_length=512,
|
36 |
-
do_sample=True,
|
37 |
-
top_k=200,
|
38 |
-
top_p=0.95,
|
39 |
-
early_stopping=True,
|
40 |
-
num_return_sequences=5)
|
41 |
-
summary_text = tokenizer_bert.decode(summary_ids[0], skip_special_tokens=True)
|
42 |
-
return summary_text
|
43 |
-
|
44 |
-
def para_t5(text):
|
45 |
-
input_ids = t5_para_tokenizer.encode(text, return_tensors='pt')
|
46 |
-
outputs = t5_para_model .generate(input_ids,
|
47 |
min_length=20,
|
48 |
max_length=100,
|
49 |
num_beams=10,
|
@@ -56,6 +43,20 @@ def para_t5(text):
|
|
56 |
temperature = 0.8,
|
57 |
top_k = 50,
|
58 |
top_p = 0.95)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
return [
|
60 |
t5_para_tokenizer.decode(
|
61 |
output, skip_special_tokens=True, clean_up_tokenization_spaces=True
|
|
|
29 |
return summary_text
|
30 |
|
31 |
def summ_bert(text):
|
32 |
+
encoding = tokenizer_bert(text, return_tensors="pt")
|
33 |
+
summary_ids= model_bert.generate(input_ids,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
min_length=20,
|
35 |
max_length=100,
|
36 |
num_beams=10,
|
|
|
43 |
temperature = 0.8,
|
44 |
top_k = 50,
|
45 |
top_p = 0.95)
|
46 |
+
|
47 |
+
summary_text = tokenizer_bert.decode(summary_ids[0], skip_special_tokens=True)
|
48 |
+
return summary_text
|
49 |
+
|
50 |
+
def para_t5(text):
|
51 |
+
input_ids = t5_para_tokenizer.encode(text, padding='longest', return_tensors='pt')
|
52 |
+
outputs = t5_para_model.generate(
|
53 |
+
input_ids=encoding["input_ids"], attention_mask=encoding["attention_mask"],
|
54 |
+
max_length=512,
|
55 |
+
do_sample=True,
|
56 |
+
top_k=200,
|
57 |
+
top_p=0.95,
|
58 |
+
early_stopping=True,
|
59 |
+
num_return_sequences=5)
|
60 |
return [
|
61 |
t5_para_tokenizer.decode(
|
62 |
output, skip_special_tokens=True, clean_up_tokenization_spaces=True
|