Spaces:
Sleeping
Sleeping
Commit
·
6fb5242
1
Parent(s):
b20fb1e
Update app.py
Browse files
app.py
CHANGED
@@ -114,22 +114,26 @@ def process_final_text(text):
|
|
114 |
word_attributions = [(letter[i], score[i]) for i in range(0, len(letter))]
|
115 |
|
116 |
# Paraphraser:
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
|
|
|
|
|
|
|
|
131 |
|
132 |
-
para_list = [tokenizer.decode(output, skip_special_tokens=True,clean_up_tokenization_spaces=True) for output in outputs]
|
133 |
|
134 |
return {"Resilience": float(scores.numpy()[1]), "Non-Resilience": float(scores.numpy()[0])},keywords,NER,word_attributions,para_list
|
135 |
|
|
|
114 |
word_attributions = [(letter[i], score[i]) for i in range(0, len(letter))]
|
115 |
|
116 |
# Paraphraser:
|
117 |
+
batch = para_tokenizer(X_test, return_tensors='pt')
|
118 |
+
generated_ids = para_model.generate(batch['input_ids'])
|
119 |
+
para_list = para_tokenizer.batch_decode(generated_ids, skip_special_tokens=True)
|
120 |
+
|
121 |
+
# inp_text = "paraphrase: " + X_test + " </s>"
|
122 |
+
|
123 |
+
# encoding = para_tokenizer.encode_plus(inp_text,pad_to_max_length=True, return_tensors="pt")
|
124 |
+
# input_ids, attention_masks = encoding["input_ids"], encoding["attention_mask"]
|
125 |
+
|
126 |
+
# outputs = para_model.generate(
|
127 |
+
# input_ids=input_ids, attention_mask=attention_masks,
|
128 |
+
# max_length=256,
|
129 |
+
# do_sample=True,
|
130 |
+
# top_k=120,
|
131 |
+
# top_p=0.95,
|
132 |
+
# early_stopping=True,
|
133 |
+
# num_return_sequences=5
|
134 |
+
# )
|
135 |
|
136 |
+
# para_list = [tokenizer.decode(output, skip_special_tokens=True,clean_up_tokenization_spaces=True) for output in outputs]
|
137 |
|
138 |
return {"Resilience": float(scores.numpy()[1]), "Non-Resilience": float(scores.numpy()[0])},keywords,NER,word_attributions,para_list
|
139 |
|