shamaayan commited on
Commit
52f1cc9
·
1 Parent(s): b7b3a2b
Files changed (1) hide show
  1. app.py +56 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import requests
4
+
5
+
6
+ examples = [
7
+ ["Please answer to the following question. Who is going to be the next Ballon d'or?"],
8
+ ["Q: Can Barack Obama have a conversation with George Washington? Give the rationale before answering."],
9
+ ["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."],
10
+ ["Please answer the following question: What is the boiling point of water?"],
11
+ ["Answer the following question by detailing your reasoning: Are Pokemons alive?"],
12
+ ["Translate to German: How old are you?"],
13
+ ["Generate a cooking recipe to make bolognese pasta:"],
14
+ ["Answer the following yes/no question by reasoning step-by-step. Can you write a whole Haiku in a single tweet?"],
15
+ ["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?"],
16
+ ["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?"],
17
+ ["""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?
18
+ A: Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11.
19
+ 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?"""]
20
+ ]
21
+
22
+ title = "Upword - Models Competition"
23
+ description = "This demo compares [BART-Large-CNN](https://huggingface.co/facebook/bart-large-cnn) and [Flan-T5-XX-large](https://huggingface.co/google/flan-t5-xxl)."
24
+
25
+ url = os.environ["url"]
26
+ token = os.environ["token"]
27
+
28
+
29
+ def inference(text):
30
+ headers = {"Authorization": f"Bearer {token}"}
31
+ payload = {
32
+ "inputs": text,
33
+ "parameters": {
34
+ "min_length": 30,
35
+ "max_length": 120,
36
+ "do_sample": False
37
+ }
38
+ }
39
+ response = requests.post(url, headers=headers, json=payload)
40
+ output_flan = response.json()[0]['generated_text']
41
+ output_vanilla = 'NA'
42
+ return [output_flan, output_vanilla]
43
+
44
+
45
+ io = gr.Interface(
46
+ inference,
47
+ gr.Textbox(lines=3),
48
+ outputs=[
49
+ gr.Textbox(lines=3, label="Flan T5"),
50
+ gr.Textbox(lines=3, label="T5")
51
+ ],
52
+ title=title,
53
+ description=description,
54
+ examples=examples
55
+ )
56
+ io.launch()