Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -106,16 +106,28 @@ def paraphrase(sentence: str, count: str):
|
|
106 |
|
107 |
# print(res)
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
|
113 |
return {
|
114 |
'result': {
|
115 |
# 'generate_v1':generate_v1(encoding, count),
|
116 |
# 'generate_v2':generate_v2(encoding, count),
|
117 |
# 'generate_v3':generate_v3(encoding, count),
|
118 |
-
|
119 |
}
|
120 |
}
|
121 |
|
|
|
106 |
|
107 |
# print(res)
|
108 |
|
109 |
+
#
|
110 |
+
input_ids, attention_masks = encoding["input_ids"], encoding["attention_mask"]
|
111 |
+
outputs = model.generate(input_ids=input_ids,
|
112 |
+
attention_mask=attention_masks,
|
113 |
+
max_length=512,
|
114 |
+
do_sample=True,
|
115 |
+
top_k=120,
|
116 |
+
top_p=0.95,
|
117 |
+
early_stopping=True,
|
118 |
+
num_return_sequences=count)
|
119 |
+
result_v4 = []
|
120 |
+
for output in outputs:
|
121 |
+
line = tokenizer.decode(output, skip_special_tokens=True, clean_up_tokenization_spaces=True)
|
122 |
+
result_v4.append(line)
|
123 |
+
#
|
124 |
|
125 |
return {
|
126 |
'result': {
|
127 |
# 'generate_v1':generate_v1(encoding, count),
|
128 |
# 'generate_v2':generate_v2(encoding, count),
|
129 |
# 'generate_v3':generate_v3(encoding, count),
|
130 |
+
'generate_v4':result_v4
|
131 |
}
|
132 |
}
|
133 |
|