Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,22 @@ import gradio as gr
|
|
| 2 |
import json
|
| 3 |
import time
|
| 4 |
|
| 5 |
-
# Load sealed results
|
| 6 |
with open("results.json") as f:
|
| 7 |
data = json.load(f)
|
| 8 |
|
| 9 |
-
def simulate_epochs(difficulty):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
results = data[difficulty]
|
| 11 |
-
header = "| Epoch | LIAM (RFT) | Adam | Lion | SGR |\n
|
| 12 |
table = header
|
| 13 |
for i in range(len(results["epochs"])):
|
| 14 |
epoch = results["epochs"][i]
|
|
@@ -16,19 +25,20 @@ def simulate_epochs(difficulty):
|
|
| 16 |
adam = results["Adam"][i]
|
| 17 |
lion = results["Lion"][i]
|
| 18 |
sgr = results["SGR"][i]
|
| 19 |
-
|
|
|
|
| 20 |
yield table
|
| 21 |
-
time.sleep(0.75)
|
| 22 |
|
| 23 |
demo = gr.Interface(
|
| 24 |
fn=simulate_epochs,
|
| 25 |
-
inputs=
|
| 26 |
-
choices=list(data.keys()),
|
| 27 |
-
label="
|
| 28 |
-
|
| 29 |
outputs=gr.Markdown(),
|
| 30 |
-
title="RFT Optimizer Showdown",
|
| 31 |
-
description="
|
| 32 |
live=True
|
| 33 |
)
|
| 34 |
|
|
|
|
| 2 |
import json
|
| 3 |
import time
|
| 4 |
|
| 5 |
+
# Load sealed RFT results
|
| 6 |
with open("results.json") as f:
|
| 7 |
data = json.load(f)
|
| 8 |
|
| 9 |
+
def simulate_epochs(difficulty, user_log):
|
| 10 |
+
try:
|
| 11 |
+
user_data = json.loads(user_log)
|
| 12 |
+
user_label = user_data.get("label", "User")
|
| 13 |
+
user_epochs = user_data.get("epochs", [])
|
| 14 |
+
user_scores = user_data.get("scores", [])
|
| 15 |
+
except:
|
| 16 |
+
yield "❌ Invalid log format. Please submit a JSON with 'label', 'epochs', and 'scores'."
|
| 17 |
+
return
|
| 18 |
+
|
| 19 |
results = data[difficulty]
|
| 20 |
+
header = f"| Epoch | LIAM (RFT) | Adam | Lion | SGR | {user_label} |\n|-------|-------------|------|------|-----|--------------|\n"
|
| 21 |
table = header
|
| 22 |
for i in range(len(results["epochs"])):
|
| 23 |
epoch = results["epochs"][i]
|
|
|
|
| 25 |
adam = results["Adam"][i]
|
| 26 |
lion = results["Lion"][i]
|
| 27 |
sgr = results["SGR"][i]
|
| 28 |
+
user_score = user_scores[i] if i < len(user_scores) else "-"
|
| 29 |
+
table += f"| {epoch} | {rft:.2f}% | {adam:.2f}% | {lion:.2f}% | {sgr:.2f}% | {user_score} |\n"
|
| 30 |
yield table
|
| 31 |
+
time.sleep(0.75)
|
| 32 |
|
| 33 |
demo = gr.Interface(
|
| 34 |
fn=simulate_epochs,
|
| 35 |
+
inputs=[
|
| 36 |
+
gr.Dropdown(choices=list(data.keys()), label="Select Difficulty Level"),
|
| 37 |
+
gr.Textbox(lines=10, label="Paste Your Optimizer Log (JSON)")
|
| 38 |
+
],
|
| 39 |
outputs=gr.Markdown(),
|
| 40 |
+
title="RFT Optimizer Showdown – Challenge Mode",
|
| 41 |
+
description="Submit your optimizer log and watch it benchmarked live against RFT, Adam, Lion, and SGR. Format: {\"label\": \"MyOpt\", \"epochs\": [...], \"scores\": [...]}.",
|
| 42 |
live=True
|
| 43 |
)
|
| 44 |
|