Spaces:
Running on Zero
Running on Zero
Model size vs param count graph
Browse files
app.py
CHANGED
|
@@ -16,6 +16,7 @@ from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
| 16 |
|
| 17 |
import gradio as gr
|
| 18 |
import pandas as pd
|
|
|
|
| 19 |
|
| 20 |
# ---------------------------------------------------------------------------
|
| 21 |
# Logging
|
|
@@ -62,6 +63,21 @@ BASE_MODEL_DISPLAY: Dict[str, str] = {
|
|
| 62 |
"OpenCerebral/Boris-1.3-75M": "Boris-1.3-75M",
|
| 63 |
}
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
FALLBACK_IDS: Dict[str, str] = {}
|
| 66 |
|
| 67 |
MODERATION_MODEL_ID = "ifmain/ModerationBERT-En-02"
|
|
@@ -564,6 +580,44 @@ def leaderboard_dataframe(state: Optional[Dict[str, dict]] = None, spec: ArenaSp
|
|
| 564 |
df.insert(0, "Rank", range(1, len(df) + 1))
|
| 565 |
return df
|
| 566 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 567 |
# ---------------------------------------------------------------------------
|
| 568 |
# Chat logging to data/chats.jsonl
|
| 569 |
# ---------------------------------------------------------------------------
|
|
@@ -970,8 +1024,11 @@ def create_demo() -> gr.Blocks:
|
|
| 970 |
column_widths=["5%", "15%", "25%", "12%", "7%", "7%", "7%", "7%", "7%"],
|
| 971 |
elem_id=elem_id,
|
| 972 |
)
|
|
|
|
|
|
|
|
|
|
| 973 |
refresh_btn = gr.Button("๐ Refresh", variant="secondary")
|
| 974 |
-
return {"tab": tab, "leaderboard": leaderboard, "refresh_btn": refresh_btn}
|
| 975 |
|
| 976 |
with gr.Tabs():
|
| 977 |
ui = {}
|
|
@@ -1200,7 +1257,7 @@ def create_demo() -> gr.Blocks:
|
|
| 1200 |
)
|
| 1201 |
|
| 1202 |
def on_refresh(spec: ArenaSpec):
|
| 1203 |
-
return leaderboard_dataframe(load_elo(spec), spec)
|
| 1204 |
|
| 1205 |
for spec in (MAIN_ARENA, BASE_ARENA):
|
| 1206 |
u, b = ui[spec.key], lb[spec.key]
|
|
@@ -1226,8 +1283,8 @@ def create_demo() -> gr.Blocks:
|
|
| 1226 |
)
|
| 1227 |
u["new_round_btn"].click(fn=on_new_round, inputs=[], outputs=round_outputs)
|
| 1228 |
u["clear_btn"].click(fn=on_clear, inputs=[], outputs=[u["prompt"]] + round_outputs)
|
| 1229 |
-
b["refresh_btn"].click(fn=lambda s=spec: on_refresh(s), inputs=[], outputs=[b["leaderboard"]])
|
| 1230 |
-
b["tab"].select(fn=lambda s=spec: on_refresh(s), inputs=[], outputs=[b["leaderboard"]])
|
| 1231 |
|
| 1232 |
gr.Markdown(
|
| 1233 |
"<div style=\"text-align:center; font-size:12px; opacity:0.65;\">"
|
|
@@ -1238,7 +1295,7 @@ def create_demo() -> gr.Blocks:
|
|
| 1238 |
)
|
| 1239 |
|
| 1240 |
try:
|
| 1241 |
-
demo.load(fn=lambda: on_refresh(MAIN_ARENA), inputs=[], outputs=[lb["main"]["leaderboard"]], show_progress="hidden")
|
| 1242 |
except Exception:
|
| 1243 |
pass
|
| 1244 |
|
|
|
|
| 16 |
|
| 17 |
import gradio as gr
|
| 18 |
import pandas as pd
|
| 19 |
+
import plotly.graph_objects as go
|
| 20 |
|
| 21 |
# ---------------------------------------------------------------------------
|
| 22 |
# Logging
|
|
|
|
| 63 |
"OpenCerebral/Boris-1.3-75M": "Boris-1.3-75M",
|
| 64 |
}
|
| 65 |
|
| 66 |
+
MODEL_PARAMS: Dict[str, float] = {
|
| 67 |
+
"CodeSoft/MetaDiffusion-150M-ChatBase": 169.5e6,
|
| 68 |
+
"BananaMind/BananaMind-2-Medium-Chat": 49.6e6,
|
| 69 |
+
"SupraLabs/Supra2-100M-Instruct": 100.0e6,
|
| 70 |
+
"HuggingFaceTB/SmolLM2-135M-Instruct": 135.0e6,
|
| 71 |
+
"OpenCerebral/Boris-1.3-125M-Instruct": 125.0e6,
|
| 72 |
+
"OpenCerebral/Boris-1.3-75M-Instruct": 75.0e6,
|
| 73 |
+
"fromziro/Zero-v0.1-150M": 151.6e6,
|
| 74 |
+
"AxiomicLabs/GPT-X2.5-135M": 135.0e6,
|
| 75 |
+
"BananaMind/BananaMind-2-Pro": 139.0e6,
|
| 76 |
+
"HuggingFaceTB/SmolLM2-135M": 135.0e6,
|
| 77 |
+
"OpenCerebral/Boris-1.3-125M": 125.0e6,
|
| 78 |
+
"OpenCerebral/Boris-1.3-75M": 75.0e6,
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
FALLBACK_IDS: Dict[str, str] = {}
|
| 82 |
|
| 83 |
MODERATION_MODEL_ID = "ifmain/ModerationBERT-En-02"
|
|
|
|
| 580 |
df.insert(0, "Rank", range(1, len(df) + 1))
|
| 581 |
return df
|
| 582 |
|
| 583 |
+
|
| 584 |
+
def elo_vs_params_fig(spec: ArenaSpec = MAIN_ARENA) -> "go.Figure":
|
| 585 |
+
"""Scatter of ELO rating vs parameter count (log x) for an arena's models."""
|
| 586 |
+
state = load_elo(spec)
|
| 587 |
+
labels, xs, ys, texts, sizes = [], [], [], [], []
|
| 588 |
+
for mid in spec.model_ids:
|
| 589 |
+
p = MODEL_PARAMS.get(mid)
|
| 590 |
+
if not p:
|
| 591 |
+
continue
|
| 592 |
+
info = state.get(mid, {"rating": INIT_RATING, "battles": 0})
|
| 593 |
+
rating = float(info["rating"])
|
| 594 |
+
battles = int(info.get("battles", 0))
|
| 595 |
+
label = spec.display.get(mid, mid)
|
| 596 |
+
labels.append(label)
|
| 597 |
+
xs.append(p)
|
| 598 |
+
ys.append(rating)
|
| 599 |
+
texts.append(f"{label}<br>Params: {p/1e6:.1f}M<br>ELO: {rating:.1f}<br>Battles: {battles}")
|
| 600 |
+
sizes.append(max(8, min(30, 8 + battles * 1.5)))
|
| 601 |
+
fig = go.Figure()
|
| 602 |
+
fig.add_trace(go.Scatter(
|
| 603 |
+
x=xs, y=ys, mode="markers+text",
|
| 604 |
+
text=labels, textposition="top center",
|
| 605 |
+
textfont=dict(size=10, color="#cccccc"),
|
| 606 |
+
marker=dict(size=sizes, color=ys, colorscale="Viridis",
|
| 607 |
+
line=dict(width=1, color="#ffffff")),
|
| 608 |
+
hovertext=texts, hoverinfo="text",
|
| 609 |
+
))
|
| 610 |
+
fig.update_layout(
|
| 611 |
+
paper_bgcolor="rgba(0,0,0,0)", plot_bgcolor="rgba(0,0,0,0)",
|
| 612 |
+
font=dict(color="#e0e0e0"),
|
| 613 |
+
xaxis=dict(title="Parameters (log scale)", type="log",
|
| 614 |
+
gridcolor="rgba(255,255,255,0.08)"),
|
| 615 |
+
yaxis=dict(title="ELO rating", gridcolor="rgba(255,255,255,0.08)"),
|
| 616 |
+
margin=dict(l=50, r=20, t=20, b=50),
|
| 617 |
+
showlegend=False,
|
| 618 |
+
)
|
| 619 |
+
return fig
|
| 620 |
+
|
| 621 |
# ---------------------------------------------------------------------------
|
| 622 |
# Chat logging to data/chats.jsonl
|
| 623 |
# ---------------------------------------------------------------------------
|
|
|
|
| 1024 |
column_widths=["5%", "15%", "25%", "12%", "7%", "7%", "7%", "7%", "7%"],
|
| 1025 |
elem_id=elem_id,
|
| 1026 |
)
|
| 1027 |
+
gr.Markdown("### ๐ ELO vs Parameters")
|
| 1028 |
+
gr.Markdown("X axis is log-scaled; bubble size scales with battle count.")
|
| 1029 |
+
elo_params_plot = gr.Plot(value=elo_vs_params_fig(spec), show_label=False)
|
| 1030 |
refresh_btn = gr.Button("๐ Refresh", variant="secondary")
|
| 1031 |
+
return {"tab": tab, "leaderboard": leaderboard, "elo_params_plot": elo_params_plot, "refresh_btn": refresh_btn}
|
| 1032 |
|
| 1033 |
with gr.Tabs():
|
| 1034 |
ui = {}
|
|
|
|
| 1257 |
)
|
| 1258 |
|
| 1259 |
def on_refresh(spec: ArenaSpec):
|
| 1260 |
+
return leaderboard_dataframe(load_elo(spec), spec), elo_vs_params_fig(spec)
|
| 1261 |
|
| 1262 |
for spec in (MAIN_ARENA, BASE_ARENA):
|
| 1263 |
u, b = ui[spec.key], lb[spec.key]
|
|
|
|
| 1283 |
)
|
| 1284 |
u["new_round_btn"].click(fn=on_new_round, inputs=[], outputs=round_outputs)
|
| 1285 |
u["clear_btn"].click(fn=on_clear, inputs=[], outputs=[u["prompt"]] + round_outputs)
|
| 1286 |
+
b["refresh_btn"].click(fn=lambda s=spec: on_refresh(s), inputs=[], outputs=[b["leaderboard"], b["elo_params_plot"]])
|
| 1287 |
+
b["tab"].select(fn=lambda s=spec: on_refresh(s), inputs=[], outputs=[b["leaderboard"], b["elo_params_plot"]])
|
| 1288 |
|
| 1289 |
gr.Markdown(
|
| 1290 |
"<div style=\"text-align:center; font-size:12px; opacity:0.65;\">"
|
|
|
|
| 1295 |
)
|
| 1296 |
|
| 1297 |
try:
|
| 1298 |
+
demo.load(fn=lambda: on_refresh(MAIN_ARENA), inputs=[], outputs=[lb["main"]["leaderboard"], lb["main"]["elo_params_plot"]], show_progress="hidden")
|
| 1299 |
except Exception:
|
| 1300 |
pass
|
| 1301 |
|