osanseviero commited on
Commit
f689a2c
1 Parent(s): 4f3084f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -4
app.py CHANGED
@@ -3,11 +3,37 @@ import gradio as gr
3
  import numpy as np
4
  from transformers import pipeline
5
 
6
- pipe = pipeline("text2text-generation", model="google/flan-t5-large")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
 
8
  def inference(text):
9
- output = pipe(text)
10
- return output[0]["generated_text"]
 
11
 
12
- io = gr.Interface(inference, gr.Textbox(lines=3), gr.Textbox(lines=3))
 
 
 
 
 
 
 
 
 
13
  io.launch()
 
3
  import numpy as np
4
  from transformers import pipeline
5
 
6
+ pipe_flan = pipeline("text2text-generation", model="google/flan-t5-large", device="cuda")
7
+ pipe_vanilla = pipeline("text2text-generation", model="t5-large", device="cuda")
8
+
9
+ examples = [
10
+ ["Translation"],
11
+ ["Please answer to the following question. Who is going to be the next Ballon d'or?"],
12
+ ["Q: Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering."],
13
+ ["Please answer the following question. What is the boiling point of Nitrogen?"],
14
+ ["Answer the following yes/no question. Can you write a whole Haiku in a single tweet?"],
15
+ ["Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"],
16
+ ["Q: ( False or not False or False ) is? A: Let's think step by step"],
17
+ ["The square root of x is the cube root of y. What is y to the power of 2, if x = 4?"],
18
+ ["Premise: At my age you will probably have learnt one lesson. Hypothesis: It's not certain how many lessons you'll learn by your thirties. Does the premise entail the hypothesis?"]
19
+ ]
20
+
21
+ title = "Flan T5 and Vanilla T5"
22
+ description = "Demo that compares [T5-large](https://huggingface.co/t5-large) and [Flan-T5-large](https://huggingface.co/ybelkada/flan-t5-large)"
23
 
24
  def inference(text):
25
+ output_flan = pipe_flan(text)[0]["generated_text"]
26
+ output_vanilla = pipe_vanilla(text)[0]["generated_text"]
27
+ return [output_flan, output_vanilla_
28
 
29
+ io = gr.Interface(
30
+ inference,
31
+ gr.Textbox(lines=3),
32
+ outputs=[
33
+ gr.Textbox(lines=3, label="Flan T5"),
34
+ gr.Textbox(lines=3, label="T5")
35
+ ],
36
+ title=title,
37
+ description=description
38
+ )
39
  io.launch()