Vigen1 commited on
Commit
2914ce8
·
verified ·
1 Parent(s): a7464cd

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio
2
+
3
+ model_name = 't5-small'
4
+
5
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
6
+
7
+ finetuned_model = AutoModelForSeq2SeqLM.from_pretrained("finetuned_model_2_epoch")
8
+
9
+ question = gradio.Textbox("question")
10
+ context = gradio.Textbox("context")
11
+
12
+ prompt = f"""Tables:
13
+ {context}
14
+
15
+ Question:
16
+ {question}
17
+
18
+ Answer:
19
+ """
20
+
21
+ inputs = tokenizer(prompt, return_tensors='pt')
22
+
23
+ output = tokenizer.decode(
24
+ finetuned_model.generate(
25
+ inputs["input_ids"],
26
+ max_new_tokens=200,
27
+ )[0],
28
+ skip_special_tokens=True
29
+ )
30
+
31
+ print(f'MODEL GENERATION - ZERO SHOT:\n{output}')