Spaces:
Sleeping
Sleeping
Arius XI commited on
Commit ·
ea79937
1
Parent(s): 9a3dff5
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,17 +4,16 @@ import gradio as grad
|
|
| 4 |
text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
|
| 5 |
mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
|
| 6 |
|
| 7 |
-
def
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
|
| 16 |
sent1=grad.Textbox(lines=1, label="Sentence1", placeholder="Text in English")
|
| 17 |
sent2=grad.Textbox(lines=1, label="Sentence2", placeholder="Text in English")
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
grad.Interface(text2text_deductible, inputs=[sent1,sent2], outputs=out).launch()
|
|
|
|
| 4 |
text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
|
| 5 |
mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
|
| 6 |
|
| 7 |
+
def text2text_paraphrase(sentence1,sentence2):
|
| 8 |
+
inp1 = "mrpc sentence1: "+sentence1
|
| 9 |
+
inp2 = "sentence2: "+sentence2
|
| 10 |
+
combined_inp=inp1+" "+inp2
|
| 11 |
+
enc = text2text_tkn(combined_inp, return_tensors="pt")
|
| 12 |
+
tokens = mdl.generate(**enc)
|
| 13 |
+
response=text2text_tkn.batch_decode(tokens)
|
| 14 |
+
return response
|
| 15 |
|
| 16 |
sent1=grad.Textbox(lines=1, label="Sentence1", placeholder="Text in English")
|
| 17 |
sent2=grad.Textbox(lines=1, label="Sentence2", placeholder="Text in English")
|
| 18 |
+
out=grad.Textbox(lines=1, label="Whether the sentence is acceptable or not")
|
| 19 |
+
grad.Interface(text2text_paraphrase, inputs=[sent1,sent2], outputs=out).launch()
|
|
|