Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,39 +11,29 @@ print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
|
|
| 11 |
pipe_flan = pipeline("text2text-generation", model="philschmid/flan-t5-xxl-sharded-fp16", model_kwargs={"load_in_8bit":True, "device_map": "auto"})
|
| 12 |
pipe_vanilla = pipeline("text2text-generation", model="t5-large", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
|
| 13 |
|
|
|
|
| 14 |
examples = [
|
| 15 |
-
["
|
| 16 |
["Q: Can Barack Obama have a conversation with George Washington? Give the rationale before answering."],
|
| 17 |
["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."],
|
| 18 |
-
["
|
| 19 |
-
["
|
| 20 |
-
["Translate to German: How old are you?"],
|
| 21 |
-
["Generate a cooking recipe to make bolognese pasta:"],
|
| 22 |
-
["Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"],
|
| 23 |
["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?"],
|
| 24 |
["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?"],
|
| 25 |
-
["""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?
|
| 26 |
-
A: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.
|
| 27 |
-
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?"""]
|
| 28 |
]
|
| 29 |
|
| 30 |
-
title = "
|
| 31 |
-
description = "This demo compares [T5-large](https://huggingface.co/t5-large) and [Flan-T5-XX-large](https://huggingface.co/google/flan-t5-xxl). Note that T5 expects a very specific format of the prompts, so the examples below are not necessarily the best prompts to compare."
|
| 32 |
|
| 33 |
def inference(text):
|
| 34 |
-
|
| 35 |
-
output_vanilla = pipe_vanilla(text, max_length=100)[0]["generated_text"]
|
| 36 |
-
return [output_flan, output_vanilla]
|
| 37 |
|
| 38 |
io = gr.Interface(
|
| 39 |
inference,
|
| 40 |
gr.Textbox(lines=3),
|
| 41 |
outputs=[
|
| 42 |
-
gr.Textbox(lines=3, label="
|
| 43 |
-
gr.Textbox(lines=3, label="T5")
|
| 44 |
],
|
| 45 |
title=title,
|
| 46 |
-
description=description,
|
| 47 |
examples=examples
|
| 48 |
)
|
| 49 |
-
io.launch()
|
|
|
|
| 11 |
pipe_flan = pipeline("text2text-generation", model="philschmid/flan-t5-xxl-sharded-fp16", model_kwargs={"load_in_8bit":True, "device_map": "auto"})
|
| 12 |
pipe_vanilla = pipeline("text2text-generation", model="t5-large", device="cuda:0", model_kwargs={"torch_dtype":torch.bfloat16})
|
| 13 |
|
| 14 |
+
|
| 15 |
examples = [
|
| 16 |
+
["Answer the following question by detailing your reasoning: Are Pokemons alive?"],
|
| 17 |
["Q: Can Barack Obama have a conversation with George Washington? Give the rationale before answering."],
|
| 18 |
["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."],
|
| 19 |
+
["Translate to French: I love eating cake!"],
|
| 20 |
+
["Generate a cooking recipe to make a cheesecacke:"],
|
|
|
|
|
|
|
|
|
|
| 21 |
["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?"],
|
| 22 |
["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?"],
|
|
|
|
|
|
|
|
|
|
| 23 |
]
|
| 24 |
|
| 25 |
+
title = "NLP Fellowship Demo"
|
|
|
|
| 26 |
|
| 27 |
def inference(text):
|
| 28 |
+
return generate(text)
|
|
|
|
|
|
|
| 29 |
|
| 30 |
io = gr.Interface(
|
| 31 |
inference,
|
| 32 |
gr.Textbox(lines=3),
|
| 33 |
outputs=[
|
| 34 |
+
gr.Textbox(lines=3, label="Answer")
|
|
|
|
| 35 |
],
|
| 36 |
title=title,
|
|
|
|
| 37 |
examples=examples
|
| 38 |
)
|
| 39 |
+
io.launch(share=True)
|