Spaces:
Build error
Build error
asd
Browse files
app.py
CHANGED
@@ -576,34 +576,34 @@ def generate_paraphrases(text, setting, output_format):
|
|
576 |
all_sentence_paraphrases = []
|
577 |
|
578 |
if setting == 1:
|
579 |
-
num_return_sequences =
|
580 |
-
temperature = 0
|
581 |
top_k = 50
|
582 |
-
top_p = 0.
|
583 |
max_length = 128
|
584 |
elif setting == 2:
|
585 |
-
num_return_sequences =
|
586 |
-
temperature =
|
587 |
top_k = 50
|
588 |
-
top_p = 0.
|
589 |
max_length = 192
|
590 |
elif setting == 3:
|
591 |
-
num_return_sequences =
|
592 |
-
temperature =
|
593 |
top_k = 50
|
594 |
-
top_p = 0.
|
595 |
max_length = 256
|
596 |
elif setting == 4:
|
597 |
-
num_return_sequences =
|
598 |
-
temperature = 1.
|
599 |
top_k = 50
|
600 |
-
top_p = 0.
|
601 |
max_length = 320
|
602 |
else:
|
603 |
-
num_return_sequences =
|
604 |
-
temperature = 1.
|
605 |
top_k = 50
|
606 |
-
top_p = 0.
|
607 |
max_length = 384
|
608 |
|
609 |
formatted_output = "Original text:\n" + text + "\n\n"
|
@@ -622,7 +622,7 @@ def generate_paraphrases(text, setting, output_format):
|
|
622 |
input_ids, attention_mask = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
|
623 |
|
624 |
paraphraser_model.eval()
|
625 |
-
|
626 |
input_ids=input_ids,
|
627 |
attention_mask=attention_mask,
|
628 |
max_length=max_length,
|
@@ -633,7 +633,7 @@ def generate_paraphrases(text, setting, output_format):
|
|
633 |
temperature=temperature
|
634 |
)
|
635 |
|
636 |
-
paraphrases_texts = [paraphraser_tokenizer.decode(
|
637 |
|
638 |
formatted_output += f"Original sentence {i+1}: {sentence}\n"
|
639 |
for j, paraphrase in enumerate(paraphrases_texts, 1):
|
|
|
576 |
all_sentence_paraphrases = []
|
577 |
|
578 |
if setting == 1:
|
579 |
+
num_return_sequences = 5
|
580 |
+
temperature = 1.0
|
581 |
top_k = 50
|
582 |
+
top_p = 0.95
|
583 |
max_length = 128
|
584 |
elif setting == 2:
|
585 |
+
num_return_sequences = 7
|
586 |
+
temperature = 1.2
|
587 |
top_k = 50
|
588 |
+
top_p = 0.95
|
589 |
max_length = 192
|
590 |
elif setting == 3:
|
591 |
+
num_return_sequences = 10
|
592 |
+
temperature = 1.4
|
593 |
top_k = 50
|
594 |
+
top_p = 0.95
|
595 |
max_length = 256
|
596 |
elif setting == 4:
|
597 |
+
num_return_sequences = 15
|
598 |
+
temperature = 1.6
|
599 |
top_k = 50
|
600 |
+
top_p = 0.95
|
601 |
max_length = 320
|
602 |
else:
|
603 |
+
num_return_sequences = 20
|
604 |
+
temperature = 1.8
|
605 |
top_k = 50
|
606 |
+
top_p = 0.95
|
607 |
max_length = 384
|
608 |
|
609 |
formatted_output = "Original text:\n" + text + "\n\n"
|
|
|
622 |
input_ids, attention_mask = encoding["input_ids"].to(device), encoding["attention_mask"].to(device)
|
623 |
|
624 |
paraphraser_model.eval()
|
625 |
+
outputs = paraphraser_model.generate(
|
626 |
input_ids=input_ids,
|
627 |
attention_mask=attention_mask,
|
628 |
max_length=max_length,
|
|
|
633 |
temperature=temperature
|
634 |
)
|
635 |
|
636 |
+
paraphrases_texts = [paraphraser_tokenizer.decode(output, skip_special_tokens=True, clean_up_tokenization_spaces=True) for output in outputs]
|
637 |
|
638 |
formatted_output += f"Original sentence {i+1}: {sentence}\n"
|
639 |
for j, paraphrase in enumerate(paraphrases_texts, 1):
|