Spaces:
Sleeping
Sleeping
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -5,25 +5,48 @@ import pandas as pd
|
|
| 5 |
import plotly.graph_objects as go
|
| 6 |
|
| 7 |
RESULTS_REPO = "happynood/quantcall-results"
|
| 8 |
-
RESULTS_FILE = "data/
|
| 9 |
GITHUB_URL = "https://github.com/Happynood/quant-toolcall-bench"
|
|
|
|
|
|
|
| 10 |
CONTRIBUTING_URL = f"{GITHUB_URL}/blob/main/CONTRIBUTING.md"
|
| 11 |
|
| 12 |
-
DISPLAY_COLS = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
CSV_TO_DISPLAY = {
|
| 14 |
"model": "Model",
|
| 15 |
"quant": "Quant",
|
| 16 |
"backend": "Backend",
|
| 17 |
-
"
|
| 18 |
-
"
|
| 19 |
-
"
|
| 20 |
-
"
|
| 21 |
-
"
|
| 22 |
-
"
|
|
|
|
|
|
|
| 23 |
"vram_gb": "VRAM (GB)",
|
| 24 |
"eta": "η",
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
-
FLOAT_COLS = {"SVR", "TSA", "AC", "Abst", "FCR", "
|
| 27 |
FILTER_BACKENDS = ["All", "llama-cpp", "transformers", "vllm", "openai"]
|
| 28 |
FILTER_QUANTS = ["All", "fp16", "Q8_0", "Q5_K_M", "Q4_K_M", "AWQ", "GPTQ"]
|
| 29 |
|
|
@@ -38,7 +61,7 @@ def _empty_df() -> pd.DataFrame:
|
|
| 38 |
|
| 39 |
|
| 40 |
def _load_results_df() -> pd.DataFrame:
|
| 41 |
-
"""Download
|
| 42 |
try:
|
| 43 |
from huggingface_hub import hf_hub_download
|
| 44 |
|
|
@@ -50,12 +73,29 @@ def _load_results_df() -> pd.DataFrame:
|
|
| 50 |
df = pd.read_csv(path)
|
| 51 |
if df.empty:
|
| 52 |
return _empty_df()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
df = df.rename(columns=CSV_TO_DISPLAY)
|
| 54 |
present = [c for c in DISPLAY_COLS if c in df.columns]
|
| 55 |
df = df[present].sort_values("FCR", ascending=False).reset_index(drop=True)
|
| 56 |
for col in FLOAT_COLS:
|
| 57 |
if col in df.columns:
|
| 58 |
df[col] = pd.to_numeric(df[col], errors="coerce").round(4)
|
|
|
|
|
|
|
| 59 |
return df
|
| 60 |
except Exception:
|
| 61 |
return _empty_df()
|
|
@@ -83,6 +123,25 @@ def _pareto_chart(df: pd.DataFrame) -> go.Figure:
|
|
| 83 |
return fig
|
| 84 |
|
| 85 |
valid = df.dropna(subset=["VRAM (GB)", "FCR"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
if "Model" in valid.columns and "Quant" in valid.columns:
|
| 87 |
label = valid["Model"].astype(str) + " " + valid["Quant"].astype(str)
|
| 88 |
else:
|
|
@@ -132,11 +191,20 @@ _initial_df = _load_results_df()
|
|
| 132 |
|
| 133 |
with gr.Blocks(title="QuantCall Leaderboard") as demo:
|
| 134 |
gr.Markdown(
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
f"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
)
|
| 141 |
|
| 142 |
df_state = gr.State(_initial_df)
|
|
@@ -158,7 +226,7 @@ with gr.Blocks(title="QuantCall Leaderboard") as demo:
|
|
| 158 |
table = gr.DataFrame(
|
| 159 |
_initial_df,
|
| 160 |
interactive=False,
|
| 161 |
-
label="Results (sorted by FCR ↓)",
|
| 162 |
)
|
| 163 |
|
| 164 |
def _update_table(
|
|
@@ -206,19 +274,21 @@ with gr.Blocks(title="QuantCall Leaderboard") as demo:
|
|
| 206 |
| **AC** | Argument Correctness — correct argument values (AST-match)? |
|
| 207 |
| **Abst** | Abstention Accuracy — correct silence when no tool is relevant? |
|
| 208 |
| **FCR** | 0.25 × (SVR + TSA + AC + Abst) |
|
| 209 |
-
| **ΔFCR** |
|
| 210 |
| **η** | FCR / peak VRAM (GB) |
|
|
|
|
|
|
|
| 211 |
|
| 212 |
## Dataset Tiers
|
| 213 |
|
| 214 |
| Tier | Source | License |
|
| 215 |
|------|--------|---------|
|
| 216 |
| T0 | In-repo smoke (10 instances) | MIT |
|
| 217 |
-
| T1/T2 | BFCL simple/parallel | Apache 2.0 |
|
| 218 |
| T3 | ToolACE | CC-BY-NC 4.0 |
|
| 219 |
| T4 | xLAM ungated mirror | NC/gated |
|
| 220 |
| T5 | Hermes function-calling v1 | Apache 2.0 (bundles glaive-function-calling-5k; credit both sources) |
|
| 221 |
-
| T6 | BFCL irrelevance (abstention) | Apache 2.0 |
|
| 222 |
|
| 223 |
## How to Submit
|
| 224 |
|
|
|
|
| 5 |
import plotly.graph_objects as go
|
| 6 |
|
| 7 |
RESULTS_REPO = "happynood/quantcall-results"
|
| 8 |
+
RESULTS_FILE = "data/leaderboard.csv"
|
| 9 |
GITHUB_URL = "https://github.com/Happynood/quant-toolcall-bench"
|
| 10 |
+
SUITE_URL = "https://huggingface.co/datasets/happynood/quantcall-suite"
|
| 11 |
+
RESULTS_URL = "https://huggingface.co/datasets/happynood/quantcall-results"
|
| 12 |
CONTRIBUTING_URL = f"{GITHUB_URL}/blob/main/CONTRIBUTING.md"
|
| 13 |
|
| 14 |
+
DISPLAY_COLS = [
|
| 15 |
+
"Model",
|
| 16 |
+
"Quant",
|
| 17 |
+
"Backend",
|
| 18 |
+
"Decoding",
|
| 19 |
+
"Tier",
|
| 20 |
+
"Seeds",
|
| 21 |
+
"SVR",
|
| 22 |
+
"TSA",
|
| 23 |
+
"AC",
|
| 24 |
+
"Abst",
|
| 25 |
+
"FCR",
|
| 26 |
+
"FCR 95% CI",
|
| 27 |
+
"VRAM (GB)",
|
| 28 |
+
"η",
|
| 29 |
+
"ΔFCR %",
|
| 30 |
+
"Baseline",
|
| 31 |
+
]
|
| 32 |
CSV_TO_DISPLAY = {
|
| 33 |
"model": "Model",
|
| 34 |
"quant": "Quant",
|
| 35 |
"backend": "Backend",
|
| 36 |
+
"decoding": "Decoding",
|
| 37 |
+
"tier": "Tier",
|
| 38 |
+
"n_seeds": "Seeds",
|
| 39 |
+
"svr_mean": "SVR",
|
| 40 |
+
"tsa_mean": "TSA",
|
| 41 |
+
"ac_mean": "AC",
|
| 42 |
+
"abstention_mean": "Abst",
|
| 43 |
+
"fcr_mean": "FCR",
|
| 44 |
"vram_gb": "VRAM (GB)",
|
| 45 |
"eta": "η",
|
| 46 |
+
"delta_fcr_rel": "ΔFCR %",
|
| 47 |
+
"baseline_quant": "Baseline",
|
| 48 |
}
|
| 49 |
+
FLOAT_COLS = {"SVR", "TSA", "AC", "Abst", "FCR", "VRAM (GB)", "η"}
|
| 50 |
FILTER_BACKENDS = ["All", "llama-cpp", "transformers", "vllm", "openai"]
|
| 51 |
FILTER_QUANTS = ["All", "fp16", "Q8_0", "Q5_K_M", "Q4_K_M", "AWQ", "GPTQ"]
|
| 52 |
|
|
|
|
| 61 |
|
| 62 |
|
| 63 |
def _load_results_df() -> pd.DataFrame:
|
| 64 |
+
"""Download the aggregated leaderboard CSV; return empty DataFrame on any error."""
|
| 65 |
try:
|
| 66 |
from huggingface_hub import hf_hub_download
|
| 67 |
|
|
|
|
| 73 |
df = pd.read_csv(path)
|
| 74 |
if df.empty:
|
| 75 |
return _empty_df()
|
| 76 |
+
|
| 77 |
+
for col in ("fcr_ci_low", "fcr_ci_high"):
|
| 78 |
+
if col not in df.columns:
|
| 79 |
+
df[col] = pd.NA
|
| 80 |
+
df["FCR 95% CI"] = df.apply(
|
| 81 |
+
lambda r: (
|
| 82 |
+
f"[{r['fcr_ci_low']:.3f}, {r['fcr_ci_high']:.3f}]"
|
| 83 |
+
if pd.notna(r["fcr_ci_low"]) and pd.notna(r["fcr_ci_high"])
|
| 84 |
+
else ""
|
| 85 |
+
),
|
| 86 |
+
axis=1,
|
| 87 |
+
)
|
| 88 |
+
if "delta_fcr_rel" in df.columns:
|
| 89 |
+
df["delta_fcr_rel"] = pd.to_numeric(df["delta_fcr_rel"], errors="coerce") * 100.0
|
| 90 |
+
|
| 91 |
df = df.rename(columns=CSV_TO_DISPLAY)
|
| 92 |
present = [c for c in DISPLAY_COLS if c in df.columns]
|
| 93 |
df = df[present].sort_values("FCR", ascending=False).reset_index(drop=True)
|
| 94 |
for col in FLOAT_COLS:
|
| 95 |
if col in df.columns:
|
| 96 |
df[col] = pd.to_numeric(df[col], errors="coerce").round(4)
|
| 97 |
+
if "ΔFCR %" in df.columns:
|
| 98 |
+
df["ΔFCR %"] = pd.to_numeric(df["ΔFCR %"], errors="coerce").round(1)
|
| 99 |
return df
|
| 100 |
except Exception:
|
| 101 |
return _empty_df()
|
|
|
|
| 123 |
return fig
|
| 124 |
|
| 125 |
valid = df.dropna(subset=["VRAM (GB)", "FCR"])
|
| 126 |
+
if valid.empty:
|
| 127 |
+
fig.add_annotation(
|
| 128 |
+
text="No VRAM measurements yet — submit a PR to populate this chart!",
|
| 129 |
+
x=0.5,
|
| 130 |
+
y=0.5,
|
| 131 |
+
xref="paper",
|
| 132 |
+
yref="paper",
|
| 133 |
+
showarrow=False,
|
| 134 |
+
font={"size": 14, "color": "#6b7280"},
|
| 135 |
+
)
|
| 136 |
+
fig.update_layout(
|
| 137 |
+
xaxis={"visible": False},
|
| 138 |
+
yaxis={"visible": False},
|
| 139 |
+
plot_bgcolor="white",
|
| 140 |
+
paper_bgcolor="white",
|
| 141 |
+
height=420,
|
| 142 |
+
)
|
| 143 |
+
return fig
|
| 144 |
+
|
| 145 |
if "Model" in valid.columns and "Quant" in valid.columns:
|
| 146 |
label = valid["Model"].astype(str) + " " + valid["Quant"].astype(str)
|
| 147 |
else:
|
|
|
|
| 191 |
|
| 192 |
with gr.Blocks(title="QuantCall Leaderboard") as demo:
|
| 193 |
gr.Markdown(
|
| 194 |
+
"# 📊 QuantCall — Function-Calling Reliability Under Quantization\n\n"
|
| 195 |
+
"> Does quantizing your model quietly break its ability to call tools?"
|
| 196 |
+
)
|
| 197 |
+
gr.HTML(
|
| 198 |
+
f"""
|
| 199 |
+
<div style="display:flex; gap:0.75rem; align-items:center; margin:-0.5rem 0 1rem 0;
|
| 200 |
+
font-size:0.95rem;">
|
| 201 |
+
<a href="{GITHUB_URL}" target="_blank" rel="noopener noreferrer"><b>GitHub</b></a>
|
| 202 |
+
<span>·</span>
|
| 203 |
+
<a href="{RESULTS_URL}" target="_blank" rel="noopener noreferrer"><b>Submit results</b></a>
|
| 204 |
+
<span>·</span>
|
| 205 |
+
<a href="{SUITE_URL}" target="_blank" rel="noopener noreferrer"><b>Eval suite</b></a>
|
| 206 |
+
</div>
|
| 207 |
+
"""
|
| 208 |
)
|
| 209 |
|
| 210 |
df_state = gr.State(_initial_df)
|
|
|
|
| 226 |
table = gr.DataFrame(
|
| 227 |
_initial_df,
|
| 228 |
interactive=False,
|
| 229 |
+
label="Results (sorted by FCR ↓, aggregated over seeds — see 'Seeds' column)",
|
| 230 |
)
|
| 231 |
|
| 232 |
def _update_table(
|
|
|
|
| 274 |
| **AC** | Argument Correctness — correct argument values (AST-match)? |
|
| 275 |
| **Abst** | Abstention Accuracy — correct silence when no tool is relevant? |
|
| 276 |
| **FCR** | 0.25 × (SVR + TSA + AC + Abst) |
|
| 277 |
+
| **ΔFCR %** | Relative FCR degradation vs the row's `Baseline` quant (see column) |
|
| 278 |
| **η** | FCR / peak VRAM (GB) |
|
| 279 |
+
| **Baseline** | The Δ reference quant for that (model, backend, decoding, tier) —
|
| 280 |
+
fp16 if it fits and was run, otherwise the best available quant that was run |
|
| 281 |
|
| 282 |
## Dataset Tiers
|
| 283 |
|
| 284 |
| Tier | Source | License |
|
| 285 |
|------|--------|---------|
|
| 286 |
| T0 | In-repo smoke (10 instances) | MIT |
|
| 287 |
+
| T1/T2 | BFCL v4 simple/multiple/parallel | Apache 2.0 |
|
| 288 |
| T3 | ToolACE | CC-BY-NC 4.0 |
|
| 289 |
| T4 | xLAM ungated mirror | NC/gated |
|
| 290 |
| T5 | Hermes function-calling v1 | Apache 2.0 (bundles glaive-function-calling-5k; credit both sources) |
|
| 291 |
+
| T6 | BFCL v4 irrelevance (abstention) | Apache 2.0 |
|
| 292 |
|
| 293 |
## How to Submit
|
| 294 |
|