Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -35,7 +35,7 @@ adequacy_score = Adequacy()
|
|
35 |
fluency_score = Fluency()
|
36 |
diversity_score= Diversity()
|
37 |
device= "cuda:0"
|
38 |
-
adequacy_threshold = 0.
|
39 |
fluency_threshold = 0.90 # Fluency (Is the paraphrase fluent English?)
|
40 |
diversity_ranker="levenshtein"
|
41 |
do_diverse=True # Diversity (Lexical / Phrasal / Syntactical) (How much has the paraphrase changed the original sentence?)
|
@@ -51,7 +51,8 @@ def get_max_str(lst):
|
|
51 |
return max(lst, key=len)
|
52 |
def get_response(input_text,num_return_sequences=10,num_beams=10):
|
53 |
batch = tokenizer.prepare_seq2seq_batch([input_text],truncation=True,padding='longest',max_length=90, return_tensors='pt').to(torch_device)
|
54 |
-
translated = model_pegasus.generate(**batch,max_length=90,num_beams=num_beams, num_return_sequences=num_return_sequences,
|
|
|
55 |
tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
|
56 |
try:
|
57 |
adequacy_filtered_phrases = adequacy_score.filter(input_text,tgt_text, adequacy_threshold, device)
|
|
|
35 |
fluency_score = Fluency()
|
36 |
diversity_score= Diversity()
|
37 |
device= "cuda:0"
|
38 |
+
adequacy_threshold = 0.99
|
39 |
fluency_threshold = 0.90 # Fluency (Is the paraphrase fluent English?)
|
40 |
diversity_ranker="levenshtein"
|
41 |
do_diverse=True # Diversity (Lexical / Phrasal / Syntactical) (How much has the paraphrase changed the original sentence?)
|
|
|
51 |
return max(lst, key=len)
|
52 |
def get_response(input_text,num_return_sequences=10,num_beams=10):
|
53 |
batch = tokenizer.prepare_seq2seq_batch([input_text],truncation=True,padding='longest',max_length=90, return_tensors='pt').to(torch_device)
|
54 |
+
translated = model_pegasus.generate(**batch,max_length=90,num_beams=num_beams, num_return_sequences=num_return_sequences, temperature=1.5)
|
55 |
+
#num_beam_groups=num_beams, diversity_penalty=0.5
|
56 |
tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
|
57 |
try:
|
58 |
adequacy_filtered_phrases = adequacy_score.filter(input_text,tgt_text, adequacy_threshold, device)
|