HemanM commited on
Commit
488dba6
Β·
verified Β·
1 Parent(s): 75d1957

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -38
app.py CHANGED
@@ -3,6 +3,8 @@ from inference import predict
3
  from logger import log_feedback_to_firebase
4
  import openai
5
  import os
 
 
6
 
7
  openai.api_key = os.environ["OPENAI_API_KEY"] # Add this secret in your Hugging Face Space
8
 
@@ -23,7 +25,6 @@ def compare(goal, sol1, sol2, correct):
23
  evo = predict(goal, sol1, sol2)
24
  gpt = gpt_predict(goal, sol1, sol2)
25
 
26
- # Determine outcome
27
  if evo == gpt == correct:
28
  verdict = "βœ… Both Evo and GPT-3.5 are correct!"
29
  elif evo == correct and gpt != correct:
@@ -33,45 +34,56 @@ def compare(goal, sol1, sol2, correct):
33
  else:
34
  verdict = "❌ Both models got it wrong."
35
 
36
- # Log to Firebase
37
  log_feedback_to_firebase(goal, sol1, sol2, evo, gpt, correct, "from app.py")
38
 
39
  return evo, gpt, verdict
40
 
 
 
 
 
41
  with gr.Blocks() as demo:
42
- gr.Markdown("## βš”οΈ Evo vs GPT-3.5 – Real-Time Commonsense Showdown")
43
- gr.Markdown(
44
- "> 🧠 EvoTransformer v2.1 – PIQA Accuracy: 69.7% (vs GPT-3.5 β‰ˆ 81%)\n"
45
- "> 13M Parameters β€’ Fully Scratch-Trained β€’ Leans Smart\n"
46
- "> πŸ§ͺ *Note: EvoTransformer is a scratch-built model trained on 1K PIQA examples. It may occasionally misinterpret context or idioms. That’s part of its evolution.*"
47
- )
48
- gr.Markdown(
49
- "> πŸ”„ *EvoTransformer is not static. Every time you provide feedback, Evo learns and evolves. Welcome to real-time neural evolution.*"
50
- )
51
-
52
- with gr.Row():
53
- goal = gr.Text(label="Goal")
54
- with gr.Row():
55
- sol1 = gr.Text(label="Solution 1")
56
- sol2 = gr.Text(label="Solution 2")
57
- correct = gr.Radio(choices=["Solution 1", "Solution 2"], label="βœ… Which is actually correct?", value="Solution 1")
58
-
59
- btn = gr.Button("Submit")
60
- evo_out = gr.Text(label="🧠 EvoTransformer Response")
61
- gpt_out = gr.Text(label="πŸ€– GPT-3.5 Response")
62
- verdict_out = gr.Text(label="βš–οΈ Verdict")
63
-
64
- btn.click(fn=compare, inputs=[goal, sol1, sol2, correct], outputs=[evo_out, gpt_out, verdict_out])
65
-
66
- gr.Markdown("#### πŸ” Try These Examples:")
67
- examples = [
68
- ["Start a fire", "Use a match", "Pour water", "Solution 1"],
69
- ["Warm up food", "Use microwave", "Put it in fridge", "Solution 1"],
70
- ["Charge a phone", "Plug it in", "Put it on grass", "Solution 1"],
71
- ["Get rid of bad smell", "Open window", "Close door", "Solution 1"],
72
- ]
73
- gr.Examples(examples=examples, inputs=[goal, sol1, sol2, correct])
74
-
75
- gr.Markdown("Made with ❀️ by Dr. Heman Mohabeer β€” EvoTransformer is not just code. It's evolution.")
76
-
77
- demo.launch()
 
 
 
 
 
 
 
 
 
3
  from logger import log_feedback_to_firebase
4
  import openai
5
  import os
6
+ from watchdog import manual_retrain
7
+ from dashboard import render_dashboard
8
 
9
  openai.api_key = os.environ["OPENAI_API_KEY"] # Add this secret in your Hugging Face Space
10
 
 
25
  evo = predict(goal, sol1, sol2)
26
  gpt = gpt_predict(goal, sol1, sol2)
27
 
 
28
  if evo == gpt == correct:
29
  verdict = "βœ… Both Evo and GPT-3.5 are correct!"
30
  elif evo == correct and gpt != correct:
 
34
  else:
35
  verdict = "❌ Both models got it wrong."
36
 
 
37
  log_feedback_to_firebase(goal, sol1, sol2, evo, gpt, correct, "from app.py")
38
 
39
  return evo, gpt, verdict
40
 
41
+ def trigger_retrain():
42
+ success = manual_retrain()
43
+ return "βœ… Evo retrained successfully!" if success else "⚠️ Retraining failed."
44
+
45
  with gr.Blocks() as demo:
46
+ with gr.Tab("βš”οΈ Evo vs GPT-3.5 Showdown"):
47
+ gr.Markdown("## βš”οΈ Evo vs GPT-3.5 – Real-Time Commonsense Showdown")
48
+ gr.Markdown(
49
+ "> 🧠 EvoTransformer v2.1 – PIQA Accuracy: 69.7% (vs GPT-3.5 β‰ˆ 81%)\n"
50
+ "> 13M Parameters β€’ Fully Scratch-Trained β€’ Leans Smart\n"
51
+ "> πŸ§ͺ *Note: EvoTransformer is a scratch-built model trained on 1K PIQA examples. It may occasionally misinterpret context or idioms. That’s part of its evolution.*"
52
+ )
53
+ gr.Markdown(
54
+ "> πŸ”„ *EvoTransformer is not static. Every time you provide feedback, Evo learns and evolves. Welcome to real-time neural evolution.*"
55
+ )
56
+
57
+ with gr.Row():
58
+ goal = gr.Text(label="Goal")
59
+ with gr.Row():
60
+ sol1 = gr.Text(label="Solution 1")
61
+ sol2 = gr.Text(label="Solution 2")
62
+ correct = gr.Radio(choices=["Solution 1", "Solution 2"], label="βœ… Which is actually correct?", value="Solution 1")
63
+
64
+ btn = gr.Button("Submit")
65
+ evo_out = gr.Text(label="🧠 EvoTransformer Response")
66
+ gpt_out = gr.Text(label="πŸ€– GPT-3.5 Response")
67
+ verdict_out = gr.Text(label="βš–οΈ Verdict")
68
+
69
+ btn.click(fn=compare, inputs=[goal, sol1, sol2, correct], outputs=[evo_out, gpt_out, verdict_out])
70
+
71
+ gr.Markdown("#### πŸ” Try These Examples:")
72
+ examples = [
73
+ ["Start a fire", "Use a match", "Pour water", "Solution 1"],
74
+ ["Warm up food", "Use microwave", "Put it in fridge", "Solution 1"],
75
+ ["Charge a phone", "Plug it in", "Put it on grass", "Solution 1"],
76
+ ["Get rid of bad smell", "Open window", "Close door", "Solution 1"],
77
+ ]
78
+ gr.Examples(examples=examples, inputs=[goal, sol1, sol2, correct])
79
+
80
+ retrain_btn = gr.Button("πŸ” Retrain EvoTransformer")
81
+ retrain_status = gr.Text(label="πŸ“’ Retrain Status")
82
+ retrain_btn.click(fn=trigger_retrain, outputs=[retrain_status])
83
+
84
+ gr.Markdown("Made with ❀️ by Dr. Heman Mohabeer β€” EvoTransformer is not just code. It's evolution.")
85
+
86
+ with gr.Tab("πŸ“Š Evo Dashboard"):
87
+ render_dashboard()
88
+
89
+ demo.launch()