Spaces:
Runtime error
Runtime error
import gradio as gr | |
import requests | |
UL2_API_URL = "https://api-inference.huggingface.co/models/google/flan-ul2" | |
FLAN_API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-xxl" | |
def query(payload, api_url): | |
response = requests.request("POST", api_url, json={"inputs":payload}) | |
return response.json() | |
examples = [ | |
["Please answer to the following question. Who is going to be the next Ballon d'or?"], | |
["Q: Can Barack Obama have a conversation with George Washington? Give the rationale before answering."], | |
["Summarize the following text: Peter and Elizabeth took a taxi to attend the night party in the city. While in the party, Elizabeth collapsed and was rushed to the hospital. Since she was diagnosed with a brain injury, the doctor told Peter to stay besides her until she gets well. Therefore, Peter stayed with her at the hospital for 3 days without leaving."], | |
["Please answer the following question: What is the boiling point of water?"], | |
["Answer the following question by detailing your reasoning: Are Pokemons alive?"], | |
["Translate to German: How old are you?"], | |
["Generate a cooking recipe to make bolognese pasta:"], | |
["Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"], | |
["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?"], | |
["Answer the following question by reasoning step by step. The cafeteria had 23 apples. If they used 20 for lunch and bought 6 more, how many apples do they have?"], | |
["""Q: Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can has 3 tennis balls. How many tennis balls does he have now? | |
A: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11. | |
Q: A juggler can juggle 16 balls. Half of the balls are golf balls, and half of the golf balls are blue. How many blue golf balls are there?"""] | |
] | |
title = "Flan UL2 vs Flan T5 XXL" | |
description = "This demo compares [Flan-T5-xxl](https://huggingface.co/google/flan-t5-xxl) and [Flan-UL2](https://huggingface.co/google/flan-ul2). Learn more about these models in their model card!" | |
def inference(text): | |
output_ul2 = query(text, api_url=UL2_API_URL)[0]["generated_text"] | |
output_flan = query(text, api_url=FLAN_API_URL)[0]["generated_text"] | |
return [output_ul2, output_flan] | |
io = gr.Interface( | |
inference, | |
gr.Textbox(lines=3), | |
outputs=[ | |
gr.Textbox(lines=3, label="Flan T5-UL2"), | |
gr.Textbox(lines=3, label="Flan T5-XXL") | |
], | |
title=title, | |
description=description, | |
examples=examples | |
) | |
io.launch() |