Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -11,11 +11,11 @@ model = model.to(device)
|
|
11 |
def generate_text(inp):
|
12 |
text = "paraphrase: "+context + " </s>"
|
13 |
context = inp
|
14 |
-
encoding = tokenizer.encode_plus(text, max_length=
|
15 |
input_ids, attention_mask = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
|
16 |
model.eval()
|
17 |
diverse_beams_output = model.generate(
|
18 |
-
input_ids=input_ids, attention_mask= attention_mask, max_length=
|
19 |
|
20 |
sent = tokenizer.decode(diverse_beams_outputs[0], skip_special_tokens = True, clean_up_tokenization_spaces = True)
|
21 |
return sent
|
|
|
11 |
def generate_text(inp):
|
12 |
text = "paraphrase: "+context + " </s>"
|
13 |
context = inp
|
14 |
+
encoding = tokenizer.encode_plus(text, max_length=128, padding=True, return_tensors="pt")
|
15 |
input_ids, attention_mask = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
|
16 |
model.eval()
|
17 |
diverse_beams_output = model.generate(
|
18 |
+
input_ids=input_ids, attention_mask= attention_mask, max_length=128, early_stopping=True, num_beams=5, num_beam_groups=5, num_return_sequences=5, diversity_penalty=0.70)
|
19 |
|
20 |
sent = tokenizer.decode(diverse_beams_outputs[0], skip_special_tokens = True, clean_up_tokenization_spaces = True)
|
21 |
return sent
|