File size: 1,692 Bytes
ed6faba
 
 
c6144cf
ed6faba
f689a2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ed6faba
c6144cf
f689a2c
 
 
ed6faba
f689a2c
 
 
 
 
 
 
 
 
 
ed6faba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import gradio as gr
import numpy as np
from transformers import pipeline

pipe_flan = pipeline("text2text-generation", model="google/flan-t5-large", device="cuda")
pipe_vanilla = pipeline("text2text-generation", model="t5-large", device="cuda")

examples = [
  ["Translation"],
  ["Please answer to the following question. Who is going to be the next Ballon d'or?"],
  ["Q: Can Geoffrey Hinton have a conversation with George Washington? Give the rationale before answering."],
  ["Please answer the following question. What is the boiling point of Nitrogen?"],
  ["Answer the following yes/no question. Can you write a whole Haiku in a single tweet?"],
  ["Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"],
  ["Q: ( False or not False or False ) is? A: Let's think step by step"],
  ["The square root of x is the cube root of y. What is y to the power of 2, if x = 4?"],
  ["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?"]
]

title = "Flan T5 and Vanilla T5"
description = "Demo that compares [T5-large](https://huggingface.co./t5-large) and [Flan-T5-large](https://huggingface.co./ybelkada/flan-t5-large)"

def inference(text):
  output_flan = pipe_flan(text)[0]["generated_text"]
  output_vanilla = pipe_vanilla(text)[0]["generated_text"]
  return [output_flan, output_vanilla_

io = gr.Interface(
  inference,
  gr.Textbox(lines=3),
  outputs=[
    gr.Textbox(lines=3, label="Flan T5"),
    gr.Textbox(lines=3, label="T5")
  ],
  title=title,
  description=description
)
io.launch()