run480 commited on
Commit
c6fa040
·
verified ·
1 Parent(s): db5817e

Update app.py

Browse files

T5 task checking whether a statement deduced from a text is correct or not

Files changed (1) hide show
  1. app.py +28 -4
app.py CHANGED
@@ -347,14 +347,38 @@
347
  #-----------------------------------------------------------------------------------
348
  # 15. Text-to-Text Generation using the T5 model - Task 6 sentence paraphasing
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
  from transformers import T5ForConditionalGeneration, T5Tokenizer
351
  import gradio as grad
352
 
353
  text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
354
  mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
355
 
356
- def text2text_paraphrase(sentence1,sentence2):
357
- inp1 = "mrpc sentence1: "+sentence1
358
  inp2 = "sentence2: "+sentence2
359
  combined_inp=inp1+" "+inp2
360
  enc = text2text_tkn(combined_inp, return_tensors="pt")
@@ -364,6 +388,6 @@ def text2text_paraphrase(sentence1,sentence2):
364
 
365
  sent1=grad.Textbox(lines=1, label="Sentence1", placeholder="Text in English")
366
  sent2=grad.Textbox(lines=1, label="Sentence2", placeholder="Text in English")
367
- out=grad.Textbox(lines=1, label="Whether the sentence is acceptable or not")
368
 
369
- grad.Interface(text2text_paraphrase, inputs=[sent1,sent2], outputs=out).launch()
 
347
  #-----------------------------------------------------------------------------------
348
  # 15. Text-to-Text Generation using the T5 model - Task 6 sentence paraphasing
349
 
350
+ # from transformers import T5ForConditionalGeneration, T5Tokenizer
351
+ # import gradio as grad
352
+
353
+ # text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
354
+ # mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
355
+
356
+ # def text2text_paraphrase(sentence1,sentence2):
357
+ # inp1 = "mrpc sentence1: "+sentence1
358
+ # inp2 = "sentence2: "+sentence2
359
+ # combined_inp=inp1+" "+inp2
360
+ # enc = text2text_tkn(combined_inp, return_tensors="pt")
361
+ # tokens = mdl.generate(**enc)
362
+ # response=text2text_tkn.batch_decode(tokens)
363
+ # return response
364
+
365
+ # sent1=grad.Textbox(lines=1, label="Sentence1", placeholder="Text in English")
366
+ # sent2=grad.Textbox(lines=1, label="Sentence2", placeholder="Text in English")
367
+ # out=grad.Textbox(lines=1, label="Whether the sentence is acceptable or not")
368
+
369
+ # grad.Interface(text2text_paraphrase, inputs=[sent1,sent2], outputs=out).launch()
370
+
371
+ #-----------------------------------------------------------------------------------
372
+ # 16. Text-to-Text Generation using the T5 model - Task 7 check whether a statement deduced from a text is correct or not.
373
+
374
  from transformers import T5ForConditionalGeneration, T5Tokenizer
375
  import gradio as grad
376
 
377
  text2text_tkn= T5Tokenizer.from_pretrained("t5-small")
378
  mdl = T5ForConditionalGeneration.from_pretrained("t5-small")
379
 
380
+ def text2text_deductible(sentence1,sentence2):
381
+ inp1 = "rte sentence1: "+sentence1
382
  inp2 = "sentence2: "+sentence2
383
  combined_inp=inp1+" "+inp2
384
  enc = text2text_tkn(combined_inp, return_tensors="pt")
 
388
 
389
  sent1=grad.Textbox(lines=1, label="Sentence1", placeholder="Text in English")
390
  sent2=grad.Textbox(lines=1, label="Sentence2", placeholder="Text in English")
391
+ out=grad.Textbox(lines=1, label="Whether sentence2 is deductible from sentence1")
392
 
393
+ grad.Interface(text2text_ deductible, inputs=[sent1,sent2], outputs=out).launch()