HemanM commited on
Commit
e44d530
·
verified ·
1 Parent(s): 785c4f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer
3
+ from inference import load_model, predict
4
+
5
+ # Load tokenizer and model
6
+ tokenizer = AutoTokenizer.from_pretrained("bert-base-uncased")
7
+ model, device = load_model("evo_hellaswag.pt")
8
+
9
+ # Interface logic
10
+ def evo_decision(prompt, option1, option2):
11
+ result = predict(model, tokenizer, prompt, option1, option2, device)
12
+ choice = option1 if result["choice"] == 0 else option2
13
+ score_0 = round(result["scores"][0] * 100, 2)
14
+ score_1 = round(result["scores"][1] * 100, 2)
15
+ return (
16
+ f"✅ Evo Suggests: **{choice}**\n\n"
17
+ f"🧠 Confidence Scores:\n"
18
+ f"- Option 1: {score_0}%\n"
19
+ f"- Option 2: {score_1}%"
20
+ )
21
+
22
+ # UI
23
+ with gr.Blocks() as demo:
24
+ gr.Markdown("# 🧬 EvoTransformer – Reasoning API\nAsk Evo a question with 2 choices.")
25
+
26
+ with gr.Row():
27
+ prompt = gr.Textbox(label="🧠 Scenario or Question", placeholder="e.g. You spilled juice on the floor.")
28
+ with gr.Row():
29
+ option1 = gr.Textbox(label="Option 1", placeholder="Wipe it with a cloth.")
30
+ option2 = gr.Textbox(label="Option 2", placeholder="Ignore and walk away.")
31
+
32
+ with gr.Row():
33
+ output = gr.Markdown()
34
+
35
+ with gr.Row():
36
+ btn = gr.Button("Ask Evo")
37
+ btn.click(fn=evo_decision, inputs=[prompt, option1, option2], outputs=[output])
38
+
39
+ # Launch app
40
+ demo.launch()