Spaces:
Sleeping
Sleeping
Redesign UI: styled table, filters, charts tab, hero header
Browse files- __pycache__/app.cpython-313.pyc +0 -0
- app.py +310 -78
- requirements.txt +1 -0
__pycache__/app.cpython-313.pyc
ADDED
|
Binary file (24 kB). View file
|
|
|
app.py
CHANGED
|
@@ -8,6 +8,7 @@ from datetime import datetime, timezone
|
|
| 8 |
|
| 9 |
import gradio as gr
|
| 10 |
import pandas as pd
|
|
|
|
| 11 |
from huggingface_hub import HfApi, hf_hub_download, snapshot_download
|
| 12 |
|
| 13 |
from scoring import load_predictions_jsonl, score_predictions
|
|
@@ -23,15 +24,42 @@ api = HfApi(token=TOKEN)
|
|
| 23 |
|
| 24 |
TIER_LABELS = {
|
| 25 |
"tier1_direct": "T1 Direct",
|
| 26 |
-
"tier2_parametric": "T2
|
| 27 |
-
"tier3_multi_intent": "T3 Multi
|
| 28 |
"tier4_implicit": "T4 Implicit",
|
| 29 |
"tier5_needle": "T5 Needle",
|
| 30 |
-
"tier6_correction": "T6
|
| 31 |
-
"tier7_multiturn": "T7
|
| 32 |
-
"tier8_intent_blending": "T8
|
| 33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
def _load_gt():
|
| 37 |
path = hf_hub_download(GT_REPO, "gt.jsonl", repo_type="dataset", token=TOKEN)
|
|
@@ -45,11 +73,10 @@ def _load_entries():
|
|
| 45 |
entries = []
|
| 46 |
entries_dir = os.path.join(local, "entries")
|
| 47 |
if os.path.isdir(entries_dir):
|
| 48 |
-
for fname in os.listdir(entries_dir):
|
| 49 |
if fname.endswith(".json"):
|
| 50 |
with open(os.path.join(entries_dir, fname)) as f:
|
| 51 |
entries.append(json.load(f))
|
| 52 |
-
# Keep the latest entry per model name
|
| 53 |
latest = {}
|
| 54 |
for e in entries:
|
| 55 |
key = e.get("model", "?")
|
|
@@ -58,36 +85,120 @@ def _load_entries():
|
|
| 58 |
return list(latest.values())
|
| 59 |
|
| 60 |
|
| 61 |
-
def
|
| 62 |
rows = []
|
| 63 |
for e in _load_entries():
|
|
|
|
|
|
|
|
|
|
| 64 |
row = {
|
| 65 |
-
"Model":
|
| 66 |
-
"
|
|
|
|
|
|
|
| 67 |
"Tool Acc": e["overall"]["tool_accuracy"],
|
| 68 |
"Exact Match": e["overall"]["exact_match"],
|
| 69 |
"Param F1": e["overall"]["param_f1"],
|
| 70 |
}
|
| 71 |
for tier, label in TIER_LABELS.items():
|
| 72 |
t = e.get("tiers", {}).get(tier)
|
| 73 |
-
row[label] = t[
|
| 74 |
-
row["Tiers"] = e[
|
| 75 |
row["Date"] = e.get("date", "")
|
| 76 |
-
row["Submitter"] = e.get("submitter", "")
|
| 77 |
rows.append(row)
|
| 78 |
if not rows:
|
| 79 |
-
return pd.DataFrame(
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
def submit(model_name, model_type, link, submitter, file
|
|
|
|
|
|
|
| 86 |
try:
|
| 87 |
if not model_name or not model_name.strip():
|
| 88 |
-
return "**
|
| 89 |
if file is None:
|
| 90 |
-
return "**
|
| 91 |
|
| 92 |
predictions = load_predictions_jsonl(file)
|
| 93 |
gt_rows = _load_gt()
|
|
@@ -118,34 +229,95 @@ def submit(model_name, model_type, link, submitter, file):
|
|
| 118 |
)
|
| 119 |
|
| 120 |
o = result["overall"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
msg = (
|
| 122 |
-
f"
|
| 123 |
-
f"
|
| 124 |
-
f"
|
| 125 |
-
f"
|
| 126 |
-
f"
|
| 127 |
-
f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
)
|
| 129 |
-
return msg,
|
| 130 |
except ValueError as e:
|
| 131 |
-
return f"**Error:** {e}",
|
| 132 |
except Exception as e:
|
| 133 |
-
return f"**Unexpected error:** {type(e).__name__}: {e}",
|
| 134 |
|
| 135 |
|
| 136 |
-
|
| 137 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 143 |
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
|
| 150 |
### Metrics
|
| 151 |
|
|
@@ -155,59 +327,119 @@ implicit, needle-in-haystack, self-correction, multi-turn, intent blending).
|
|
| 155 |
| **Exact Match** | Tool name and all parameters match exactly |
|
| 156 |
| **Param F1** | F1 over parameter key/value pairs (0 if the tool is wrong) |
|
| 157 |
|
| 158 |
-
Overall scores are macro-averaged across covered tiers.
|
| 159 |
-
|
| 160 |
-
|
| 161 |
|
| 162 |
### How to submit
|
| 163 |
|
| 164 |
-
1. Download the eval set:
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
"""
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
f"[benchmark code]({BENCHMARK_REPO}))."
|
| 179 |
-
)
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
refresh = gr.Button("Refresh")
|
| 184 |
-
refresh.click(fn=build_table, outputs=table)
|
| 185 |
|
| 186 |
-
with gr.Tab("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 187 |
gr.Markdown(
|
| 188 |
-
"
|
| 189 |
-
"
|
|
|
|
| 190 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
with gr.Row():
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 204 |
submit_btn.click(
|
| 205 |
fn=submit,
|
| 206 |
-
inputs=[model_name, model_type, link, submitter, file],
|
| 207 |
outputs=[status, table],
|
| 208 |
)
|
| 209 |
|
| 210 |
with gr.Tab("βΉοΈ About"):
|
| 211 |
gr.Markdown(ABOUT)
|
| 212 |
|
| 213 |
-
|
|
|
|
|
|
| 8 |
|
| 9 |
import gradio as gr
|
| 10 |
import pandas as pd
|
| 11 |
+
import plotly.graph_objects as go
|
| 12 |
from huggingface_hub import HfApi, hf_hub_download, snapshot_download
|
| 13 |
|
| 14 |
from scoring import load_predictions_jsonl, score_predictions
|
|
|
|
| 24 |
|
| 25 |
TIER_LABELS = {
|
| 26 |
"tier1_direct": "T1 Direct",
|
| 27 |
+
"tier2_parametric": "T2 Param",
|
| 28 |
+
"tier3_multi_intent": "T3 Multi",
|
| 29 |
"tier4_implicit": "T4 Implicit",
|
| 30 |
"tier5_needle": "T5 Needle",
|
| 31 |
+
"tier6_correction": "T6 Correct",
|
| 32 |
+
"tier7_multiturn": "T7 Turns",
|
| 33 |
+
"tier8_intent_blending": "T8 Blend",
|
| 34 |
}
|
| 35 |
+
TIER_FULL = {
|
| 36 |
+
"tier1_direct": "Tier 1 β Direct commands",
|
| 37 |
+
"tier2_parametric": "Tier 2 β Parametric",
|
| 38 |
+
"tier3_multi_intent": "Tier 3 β Multi-intent",
|
| 39 |
+
"tier4_implicit": "Tier 4 β Implicit intent",
|
| 40 |
+
"tier5_needle": "Tier 5 β Needle in haystack",
|
| 41 |
+
"tier6_correction": "Tier 6 β Self-correction",
|
| 42 |
+
"tier7_multiturn": "Tier 7 β Multi-turn",
|
| 43 |
+
"tier8_intent_blending": "Tier 8 β Intent blending",
|
| 44 |
+
}
|
| 45 |
+
METRIC_KEYS = {
|
| 46 |
+
"Tool Accuracy": "tool_accuracy",
|
| 47 |
+
"Exact Match": "exact_match",
|
| 48 |
+
"Param F1": "param_f1",
|
| 49 |
+
}
|
| 50 |
+
TYPE_BADGES = {
|
| 51 |
+
"end-to-end": "ποΈ end-to-end",
|
| 52 |
+
"cascaded": "βοΈ cascaded",
|
| 53 |
+
"cascaded (oracle ASR)": "π oracle ASR",
|
| 54 |
+
"other": "β other",
|
| 55 |
+
}
|
| 56 |
+
MODEL_TYPES = list(TYPE_BADGES.keys())
|
| 57 |
+
PCT_COLS = ["Tool Acc", "Exact Match", "Param F1"] + list(TIER_LABELS.values())
|
| 58 |
+
|
| 59 |
|
| 60 |
+
# --------------------------------------------------------------------------
|
| 61 |
+
# Data loading
|
| 62 |
+
# --------------------------------------------------------------------------
|
| 63 |
|
| 64 |
def _load_gt():
|
| 65 |
path = hf_hub_download(GT_REPO, "gt.jsonl", repo_type="dataset", token=TOKEN)
|
|
|
|
| 73 |
entries = []
|
| 74 |
entries_dir = os.path.join(local, "entries")
|
| 75 |
if os.path.isdir(entries_dir):
|
| 76 |
+
for fname in sorted(os.listdir(entries_dir)):
|
| 77 |
if fname.endswith(".json"):
|
| 78 |
with open(os.path.join(entries_dir, fname)) as f:
|
| 79 |
entries.append(json.load(f))
|
|
|
|
| 80 |
latest = {}
|
| 81 |
for e in entries:
|
| 82 |
key = e.get("model", "?")
|
|
|
|
| 85 |
return list(latest.values())
|
| 86 |
|
| 87 |
|
| 88 |
+
def build_df(tier_metric_key: str = "tool_accuracy") -> pd.DataFrame:
|
| 89 |
rows = []
|
| 90 |
for e in _load_entries():
|
| 91 |
+
name = e.get("model", "?")
|
| 92 |
+
link = (e.get("link") or "").strip()
|
| 93 |
+
model_md = f"**[{name}]({link})**" if link.startswith("http") else f"**{name}**"
|
| 94 |
row = {
|
| 95 |
+
"Model": model_md,
|
| 96 |
+
"_model_raw": name,
|
| 97 |
+
"Type": TYPE_BADGES.get(e.get("model_type", "other"), e.get("model_type", "")),
|
| 98 |
+
"_type_raw": e.get("model_type", "other"),
|
| 99 |
"Tool Acc": e["overall"]["tool_accuracy"],
|
| 100 |
"Exact Match": e["overall"]["exact_match"],
|
| 101 |
"Param F1": e["overall"]["param_f1"],
|
| 102 |
}
|
| 103 |
for tier, label in TIER_LABELS.items():
|
| 104 |
t = e.get("tiers", {}).get(tier)
|
| 105 |
+
row[label] = t[tier_metric_key] if t else None
|
| 106 |
+
row["Tiers"] = f"{e['overall'].get('n_tiers', len(e.get('tiers', {})))}/8"
|
| 107 |
row["Date"] = e.get("date", "")
|
|
|
|
| 108 |
rows.append(row)
|
| 109 |
if not rows:
|
| 110 |
+
return pd.DataFrame()
|
| 111 |
+
return pd.DataFrame(rows)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
# --------------------------------------------------------------------------
|
| 115 |
+
# Styling
|
| 116 |
+
# --------------------------------------------------------------------------
|
| 117 |
+
|
| 118 |
+
def _cell_style(v):
|
| 119 |
+
"""Green intensity scaled by score; readable in light and dark mode."""
|
| 120 |
+
if v is None or (isinstance(v, float) and pd.isna(v)):
|
| 121 |
+
return "color: #9ca3af"
|
| 122 |
+
alpha = 0.06 + 0.42 * float(v)
|
| 123 |
+
return f"background-color: rgba(16, 163, 90, {alpha:.2f}); font-variant-numeric: tabular-nums"
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def style_table(df: pd.DataFrame, sort_metric: str = "Tool Acc"):
|
| 127 |
+
if df.empty:
|
| 128 |
+
return pd.DataFrame({"": ["No entries yet β be the first to submit!"]})
|
| 129 |
+
df = df.sort_values(sort_metric, ascending=False).reset_index(drop=True)
|
| 130 |
+
medals = ["π₯", "π₯", "π₯"] + [str(i) for i in range(4, len(df) + 1)]
|
| 131 |
+
df.insert(0, "Rank", medals[: len(df)])
|
| 132 |
+
df = df.drop(columns=["_model_raw", "_type_raw"])
|
| 133 |
+
|
| 134 |
+
pct_cols = [c for c in PCT_COLS if c in df.columns]
|
| 135 |
+
styler = (
|
| 136 |
+
df.style
|
| 137 |
+
.format({c: lambda v: "β" if pd.isna(v) else f"{v * 100:.1f}" for c in pct_cols})
|
| 138 |
+
.map(_cell_style, subset=pct_cols)
|
| 139 |
+
.set_properties(subset=["Rank"], **{"text-align": "center", "font-size": "1.05em"})
|
| 140 |
+
)
|
| 141 |
+
return styler
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def leaderboard_view(search: str, types: list, tier_metric: str, sort_metric: str):
|
| 145 |
+
df = build_df(METRIC_KEYS[tier_metric])
|
| 146 |
+
if df.empty:
|
| 147 |
+
return style_table(df)
|
| 148 |
+
if types:
|
| 149 |
+
df = df[df["_type_raw"].isin(types)]
|
| 150 |
+
if search and search.strip():
|
| 151 |
+
df = df[df["_model_raw"].str.contains(search.strip(), case=False, regex=False)]
|
| 152 |
+
return style_table(df, sort_metric)
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
# --------------------------------------------------------------------------
|
| 156 |
+
# Charts
|
| 157 |
+
# --------------------------------------------------------------------------
|
| 158 |
+
|
| 159 |
+
PALETTE = ["#2563eb", "#059669", "#d97706", "#dc2626", "#7c3aed",
|
| 160 |
+
"#0891b2", "#be185d", "#4d7c0f", "#b45309", "#6d28d9"]
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def build_chart(metric_label: str):
|
| 164 |
+
key = METRIC_KEYS[metric_label]
|
| 165 |
+
entries = sorted(_load_entries(),
|
| 166 |
+
key=lambda e: e["overall"][key], reverse=True)
|
| 167 |
+
fig = go.Figure()
|
| 168 |
+
tiers = list(TIER_LABELS.keys())
|
| 169 |
+
for i, e in enumerate(entries[:10]):
|
| 170 |
+
ys = [e.get("tiers", {}).get(t, {}).get(key) for t in tiers]
|
| 171 |
+
fig.add_trace(go.Bar(
|
| 172 |
+
name=e.get("model", "?"),
|
| 173 |
+
x=[TIER_LABELS[t] for t in tiers],
|
| 174 |
+
y=[None if y is None else y * 100 for y in ys],
|
| 175 |
+
marker_color=PALETTE[i % len(PALETTE)],
|
| 176 |
+
))
|
| 177 |
+
fig.update_layout(
|
| 178 |
+
barmode="group",
|
| 179 |
+
template="plotly_white",
|
| 180 |
+
yaxis_title=f"{metric_label} (%)",
|
| 181 |
+
yaxis_range=[0, 100],
|
| 182 |
+
legend=dict(orientation="h", yanchor="bottom", y=1.02, x=0),
|
| 183 |
+
margin=dict(l=40, r=20, t=30, b=40),
|
| 184 |
+
height=480,
|
| 185 |
+
font=dict(family="ui-sans-serif, system-ui, sans-serif"),
|
| 186 |
+
)
|
| 187 |
+
return fig
|
| 188 |
+
|
| 189 |
|
| 190 |
+
# --------------------------------------------------------------------------
|
| 191 |
+
# Submission
|
| 192 |
+
# --------------------------------------------------------------------------
|
| 193 |
|
| 194 |
+
def submit(model_name, model_type, link, submitter, file,
|
| 195 |
+
search, types, tier_metric, sort_metric):
|
| 196 |
+
table = lambda: leaderboard_view(search, types, tier_metric, sort_metric)
|
| 197 |
try:
|
| 198 |
if not model_name or not model_name.strip():
|
| 199 |
+
return "β οΈ **Please provide a model name.**", table()
|
| 200 |
if file is None:
|
| 201 |
+
return "β οΈ **Please upload a predictions `.jsonl` file.**", table()
|
| 202 |
|
| 203 |
predictions = load_predictions_jsonl(file)
|
| 204 |
gt_rows = _load_gt()
|
|
|
|
| 229 |
)
|
| 230 |
|
| 231 |
o = result["overall"]
|
| 232 |
+
per_tier = "\n".join(
|
| 233 |
+
f"| {TIER_FULL[t]} | {m['tool_accuracy']:.1%} | {m['exact_match']:.1%} "
|
| 234 |
+
f"| {m['param_f1']:.1%} | {m['n']} |"
|
| 235 |
+
for t, m in result["tiers"].items()
|
| 236 |
+
)
|
| 237 |
msg = (
|
| 238 |
+
f"### β
Submission scored and added\n\n"
|
| 239 |
+
f"| Overall | Score |\n|---|---|\n"
|
| 240 |
+
f"| Tool Accuracy | **{o['tool_accuracy']:.1%}** |\n"
|
| 241 |
+
f"| Exact Match | **{o['exact_match']:.1%}** |\n"
|
| 242 |
+
f"| Param F1 | **{o['param_f1']:.1%}** |\n\n"
|
| 243 |
+
f"Scored **{result['n_scored']}** samples across "
|
| 244 |
+
f"**{o['n_tiers']}/8** tiers"
|
| 245 |
+
+ (f" Β· β οΈ {result['n_missing']} samples had no prediction"
|
| 246 |
+
if result["n_missing"] else "")
|
| 247 |
+
+ "\n\n<details><summary>Per-tier breakdown</summary>\n\n"
|
| 248 |
+
f"| Tier | Tool Acc | Exact | F1 | n |\n|---|---|---|---|---|\n{per_tier}\n\n</details>"
|
| 249 |
)
|
| 250 |
+
return msg, table()
|
| 251 |
except ValueError as e:
|
| 252 |
+
return f"β **Error:** {e}", table()
|
| 253 |
except Exception as e:
|
| 254 |
+
return f"β **Unexpected error:** {type(e).__name__}: {e}", table()
|
| 255 |
|
| 256 |
|
| 257 |
+
# --------------------------------------------------------------------------
|
| 258 |
+
# Layout
|
| 259 |
+
# --------------------------------------------------------------------------
|
| 260 |
+
|
| 261 |
+
CSS = """
|
| 262 |
+
.a2t-hero {
|
| 263 |
+
text-align: center;
|
| 264 |
+
padding: 28px 16px 20px;
|
| 265 |
+
border-radius: 14px;
|
| 266 |
+
background: linear-gradient(135deg, #0f2d5c 0%, #14532d 100%);
|
| 267 |
+
color: #f8fafc;
|
| 268 |
+
margin-bottom: 4px;
|
| 269 |
+
}
|
| 270 |
+
.a2t-hero h1 { font-size: 2.1em; margin: 0 0 6px; color: #ffffff; }
|
| 271 |
+
.a2t-hero p { margin: 4px 0; color: #cbd5e1; font-size: 1.02em; }
|
| 272 |
+
.a2t-hero a { color: #7dd3fc; text-decoration: none; font-weight: 600; }
|
| 273 |
+
.a2t-hero a:hover { text-decoration: underline; }
|
| 274 |
+
.a2t-badges { margin-top: 10px; }
|
| 275 |
+
.a2t-badges span {
|
| 276 |
+
display: inline-block; padding: 4px 12px; margin: 2px 4px;
|
| 277 |
+
border-radius: 999px; background: rgba(255,255,255,.12);
|
| 278 |
+
font-size: .86em; color: #e2e8f0;
|
| 279 |
+
}
|
| 280 |
+
#leaderboard-table table { font-size: .93em; }
|
| 281 |
+
#leaderboard-table th { white-space: nowrap; }
|
| 282 |
+
#leaderboard-table td:nth-child(2) { white-space: nowrap; }
|
| 283 |
+
.a2t-note { color: #6b7280; font-size: .86em; margin-top: 2px; }
|
| 284 |
+
"""
|
| 285 |
|
| 286 |
+
HERO = f"""
|
| 287 |
+
<div class="a2t-hero">
|
| 288 |
+
<h1>ποΈπ§ Audio2Tool Leaderboard</h1>
|
| 289 |
+
<p>Voice-command tool calling across 8 difficulty tiers, scored on a held-out private set.</p>
|
| 290 |
+
<div class="a2t-badges">
|
| 291 |
+
<span>ποΈ <a href="https://huggingface.co/datasets/{EVAL_REPO}" target="_blank">Eval set</a></span>
|
| 292 |
+
<span>π¦ <a href="https://huggingface.co/datasets/{MAIN_DATASET}" target="_blank">Dataset</a></span>
|
| 293 |
+
<span>π» <a href="{BENCHMARK_REPO}" target="_blank">Benchmark code</a></span>
|
| 294 |
+
<span>π <a href="https://huggingface.co/datasets/{RESULTS_REPO}" target="_blank">Raw results</a></span>
|
| 295 |
+
</div>
|
| 296 |
+
</div>
|
| 297 |
+
"""
|
| 298 |
|
| 299 |
+
ABOUT = f"""
|
| 300 |
+
## What is this?
|
| 301 |
+
|
| 302 |
+
Audio2Tool benchmarks audio-language models on **voice-command tool calling**:
|
| 303 |
+
the model hears a spoken command and must emit the right tool call with the
|
| 304 |
+
right parameters. The eval set is a held-out subset of the private split of
|
| 305 |
+
[{MAIN_DATASET}](https://huggingface.co/datasets/{MAIN_DATASET})
|
| 306 |
+
(up to 200 queries per tier, 1,579 samples). Labels are hidden β scoring
|
| 307 |
+
happens inside this Space.
|
| 308 |
+
|
| 309 |
+
### The 8 tiers
|
| 310 |
+
|
| 311 |
+
| Tier | Challenge |
|
| 312 |
+
|------|-----------|
|
| 313 |
+
| **T1 Direct** | Straightforward commands ("Lock the car") |
|
| 314 |
+
| **T2 Param** | Commands with parameter values ("Set driver temp to 21") |
|
| 315 |
+
| **T3 Multi** | Several intents in one utterance |
|
| 316 |
+
| **T4 Implicit** | Intent must be inferred ("It's freezing back here") |
|
| 317 |
+
| **T5 Needle** | Command buried in long distracting audio |
|
| 318 |
+
| **T6 Correct** | Speaker self-corrects mid-utterance |
|
| 319 |
+
| **T7 Turns** | Multi-turn conversations (turn audio provided in order) |
|
| 320 |
+
| **T8 Blend** | Overlapping speakers / blended intents |
|
| 321 |
|
| 322 |
### Metrics
|
| 323 |
|
|
|
|
| 327 |
| **Exact Match** | Tool name and all parameters match exactly |
|
| 328 |
| **Param F1** | F1 over parameter key/value pairs (0 if the tool is wrong) |
|
| 329 |
|
| 330 |
+
Overall scores are macro-averaged across covered tiers. Entries marked
|
| 331 |
+
*oracle ASR* consume ground-truth transcripts instead of audio β text-side
|
| 332 |
+
upper bounds, not audio models.
|
| 333 |
|
| 334 |
### How to submit
|
| 335 |
|
| 336 |
+
1. Download the eval set:
|
| 337 |
+
```
|
| 338 |
+
hf download {EVAL_REPO} --repo-type dataset --local-dir eval
|
| 339 |
+
```
|
| 340 |
+
2. For each row of `metadata.jsonl`, run your model on the audio and produce a
|
| 341 |
+
tool-call string. Tools are defined in the dataset's
|
| 342 |
+
[`tools_registry.csv`](https://huggingface.co/datasets/{MAIN_DATASET}/blob/main/tools_registry.csv).
|
| 343 |
+
3. Write one JSON row per sample:
|
| 344 |
+
```json
|
| 345 |
+
{{"sample_id": "tier1_direct/00042", "prediction": "setZoneTemperature(zone=Driver, temperature=21.0)"}}
|
| 346 |
+
```
|
| 347 |
+
Multi-intent samples: several calls in one string, primary first β
|
| 348 |
+
`setLockState(state=Locked) setFanSpeed(level=7)`
|
| 349 |
+
4. Upload the file on the **Submit** tab. Scores appear immediately.
|
| 350 |
+
|
| 351 |
+
The scorer uses the exact normalization of the
|
| 352 |
+
[benchmark code]({BENCHMARK_REPO}), so leaderboard numbers are comparable
|
| 353 |
+
to local runs.
|
| 354 |
"""
|
| 355 |
|
| 356 |
+
theme = gr.themes.Soft(
|
| 357 |
+
primary_hue="emerald",
|
| 358 |
+
neutral_hue="slate",
|
| 359 |
+
font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui"],
|
| 360 |
+
)
|
|
|
|
|
|
|
| 361 |
|
| 362 |
+
with gr.Blocks(title="Audio2Tool Leaderboard", theme=theme, css=CSS) as demo:
|
| 363 |
+
gr.HTML(HERO)
|
|
|
|
|
|
|
| 364 |
|
| 365 |
+
with gr.Tab("π Leaderboard"):
|
| 366 |
+
with gr.Row():
|
| 367 |
+
search = gr.Textbox(
|
| 368 |
+
label="π Search models", placeholder="filter by nameβ¦", scale=2)
|
| 369 |
+
type_filter = gr.CheckboxGroup(
|
| 370 |
+
choices=MODEL_TYPES, value=MODEL_TYPES, label="Model type", scale=3)
|
| 371 |
+
tier_metric = gr.Dropdown(
|
| 372 |
+
choices=list(METRIC_KEYS), value="Tool Accuracy",
|
| 373 |
+
label="Per-tier metric", scale=1)
|
| 374 |
+
sort_metric = gr.Dropdown(
|
| 375 |
+
choices=["Tool Acc", "Exact Match", "Param F1"], value="Tool Acc",
|
| 376 |
+
label="Sort by", scale=1)
|
| 377 |
+
table = gr.Dataframe(
|
| 378 |
+
value=lambda: leaderboard_view("", MODEL_TYPES, "Tool Accuracy", "Tool Acc"),
|
| 379 |
+
datatype="markdown", wrap=False, elem_id="leaderboard-table",
|
| 380 |
+
interactive=False,
|
| 381 |
+
)
|
| 382 |
gr.Markdown(
|
| 383 |
+
"<p class='a2t-note'>All numbers are percentages. Per-tier columns show the metric "
|
| 384 |
+
"selected above; overall columns are macro-averages over covered tiers. "
|
| 385 |
+
"βββ means the model has no valid result for that tier.</p>"
|
| 386 |
)
|
| 387 |
+
refresh = gr.Button("π Refresh", size="sm")
|
| 388 |
+
|
| 389 |
+
controls = [search, type_filter, tier_metric, sort_metric]
|
| 390 |
+
for c in controls:
|
| 391 |
+
c.change(fn=leaderboard_view, inputs=controls, outputs=table)
|
| 392 |
+
refresh.click(fn=leaderboard_view, inputs=controls, outputs=table)
|
| 393 |
+
|
| 394 |
+
with gr.Tab("π Charts"):
|
| 395 |
+
chart_metric = gr.Dropdown(
|
| 396 |
+
choices=list(METRIC_KEYS), value="Tool Accuracy", label="Metric")
|
| 397 |
+
chart = gr.Plot(value=lambda: build_chart("Tool Accuracy"))
|
| 398 |
+
chart_metric.change(fn=build_chart, inputs=chart_metric, outputs=chart)
|
| 399 |
+
gr.Markdown(
|
| 400 |
+
"<p class='a2t-note'>Per-tier scores for the top 10 models (by overall score).</p>"
|
| 401 |
+
)
|
| 402 |
+
|
| 403 |
+
with gr.Tab("π€ Submit"):
|
| 404 |
with gr.Row():
|
| 405 |
+
with gr.Column(scale=3):
|
| 406 |
+
gr.Markdown("### Add your model\nScore your predictions against the "
|
| 407 |
+
"hidden labels and join the leaderboard.")
|
| 408 |
+
with gr.Row():
|
| 409 |
+
model_name = gr.Textbox(label="Model name *",
|
| 410 |
+
placeholder="e.g. MyAudioLM-8B")
|
| 411 |
+
model_type = gr.Dropdown(label="Model type",
|
| 412 |
+
choices=MODEL_TYPES, value="end-to-end")
|
| 413 |
+
with gr.Row():
|
| 414 |
+
link = gr.Textbox(label="Link (model card / paper)",
|
| 415 |
+
placeholder="https://β¦")
|
| 416 |
+
submitter = gr.Textbox(label="Submitted by",
|
| 417 |
+
placeholder="your name or org")
|
| 418 |
+
file = gr.File(label="Predictions (.jsonl)",
|
| 419 |
+
file_types=[".jsonl", ".json"], type="filepath")
|
| 420 |
+
submit_btn = gr.Button("π Score and submit", variant="primary")
|
| 421 |
+
status = gr.Markdown()
|
| 422 |
+
with gr.Column(scale=2):
|
| 423 |
+
gr.Markdown(
|
| 424 |
+
"### Format\n"
|
| 425 |
+
"One JSON row per sample:\n"
|
| 426 |
+
"```json\n"
|
| 427 |
+
'{"sample_id": "tier1_direct/00042",\n'
|
| 428 |
+
' "prediction": "setZoneTemperature(zone=Driver, temperature=21.0)"}\n'
|
| 429 |
+
"```\n"
|
| 430 |
+
"- `sample_id` comes from the eval set's `metadata.jsonl`\n"
|
| 431 |
+
"- Multi-intent: several calls in one string, primary first\n"
|
| 432 |
+
"- Partial submissions are scored on covered tiers only\n\n"
|
| 433 |
+
"See the **About** tab for the full walkthrough."
|
| 434 |
+
)
|
| 435 |
submit_btn.click(
|
| 436 |
fn=submit,
|
| 437 |
+
inputs=[model_name, model_type, link, submitter, file] + controls,
|
| 438 |
outputs=[status, table],
|
| 439 |
)
|
| 440 |
|
| 441 |
with gr.Tab("βΉοΈ About"):
|
| 442 |
gr.Markdown(ABOUT)
|
| 443 |
|
| 444 |
+
if __name__ == "__main__":
|
| 445 |
+
demo.launch()
|
requirements.txt
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
gradio>=5.0
|
| 2 |
huggingface_hub>=0.26
|
| 3 |
pandas>=2.0
|
|
|
|
|
|
| 1 |
gradio>=5.0
|
| 2 |
huggingface_hub>=0.26
|
| 3 |
pandas>=2.0
|
| 4 |
+
plotly>=5.20
|