Spaces:
Running
Running
Auto-discover all benchmark:official leaderboards on the Hub
Browse files- update_data.py +119 -20
update_data.py
CHANGED
|
@@ -30,18 +30,96 @@ from huggingface_hub import HfApi
|
|
| 30 |
|
| 31 |
SPACE_REPO = "davanstrien/benchmark-race"
|
| 32 |
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
PALETTE = [
|
| 47 |
"#6366f1", "#0d9488", "#d97706", "#e11d48", "#7c3aed",
|
|
@@ -73,13 +151,21 @@ def fetch_leaderboard(config: dict, hf_token: str | None) -> list[dict]:
|
|
| 73 |
print(f" error: {e}")
|
| 74 |
return []
|
| 75 |
|
| 76 |
-
|
|
|
|
| 77 |
for entry in data:
|
|
|
|
|
|
|
| 78 |
model_id = entry.get("modelId")
|
| 79 |
score = entry.get("value")
|
| 80 |
if model_id and score is not None:
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
seen[model_id] = score
|
| 84 |
|
| 85 |
print(f" {len(seen)} models")
|
|
@@ -144,13 +230,21 @@ def main():
|
|
| 144 |
hf_token = os.environ.get("HF_TOKEN")
|
| 145 |
print("Generating data.json for bar chart race\n")
|
| 146 |
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
| 148 |
all_model_ids: set[str] = set()
|
| 149 |
|
| 150 |
-
for config in
|
| 151 |
rows = fetch_leaderboard(config, hf_token)
|
| 152 |
if rows:
|
| 153 |
-
all_scores[config["key"]] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
all_model_ids.update(r["model_id"] for r in rows)
|
| 155 |
|
| 156 |
print(f"\n{len(all_model_ids)} unique models across {len(all_scores)} benchmarks")
|
|
@@ -179,8 +273,13 @@ def main():
|
|
| 179 |
"score": round(row["score"], 2),
|
| 180 |
"date": model_dates[mid]["date"],
|
| 181 |
})
|
| 182 |
-
if models:
|
| 183 |
-
benchmarks[key] = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
|
| 185 |
print(f"\nFetching logos for {len(all_providers)} providers...")
|
| 186 |
logos = fetch_all_logos(all_providers)
|
|
|
|
| 30 |
|
| 31 |
SPACE_REPO = "davanstrien/benchmark-race"
|
| 32 |
|
| 33 |
+
# Benchmarks are auto-discovered from datasets tagged `benchmark:official` on
|
| 34 |
+
# the Hub. The originals get keys preserved so the UI's hardcoded default
|
| 35 |
+
# (`sweVerified` in index.html) keeps working; new benchmarks get
|
| 36 |
+
# slugified keys and a name from cardData.pretty_name (or basename).
|
| 37 |
+
OVERRIDES = {
|
| 38 |
+
"SWE-bench/SWE-bench_Verified": ("sweVerified", "SWE-bench Verified"),
|
| 39 |
+
"ScaleAI/SWE-bench_Pro": ("swePro", "SWE-bench Pro"),
|
| 40 |
+
"TIGER-Lab/MMLU-Pro": ("mmluPro", "MMLU-Pro"),
|
| 41 |
+
"Idavidrein/gpqa": ("gpqa", "GPQA Diamond"),
|
| 42 |
+
"cais/hle": ("hle", "HLE"),
|
| 43 |
+
"MathArena/aime_2026": ("aime2026", "AIME 2026"),
|
| 44 |
+
"MathArena/hmmt_feb_2026": ("hmmt2026", "HMMT Feb 2026"),
|
| 45 |
+
"allenai/olmOCR-bench": ("olmOcr", "olmOCR-bench"),
|
| 46 |
+
"harborframework/terminal-bench-2.0": ("terminalBench", "Terminal-Bench 2.0"),
|
| 47 |
+
"FutureMa/EvasionBench": ("evasionBench", "EvasionBench"),
|
| 48 |
+
}
|
| 49 |
+
MIN_MODELS = 2
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def slugify(dataset_id: str) -> str:
|
| 53 |
+
base = dataset_id.split("/")[-1]
|
| 54 |
+
s = re.sub(r"[^a-zA-Z0-9]+", "_", base).strip("_")
|
| 55 |
+
return s or dataset_id.replace("/", "_")
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def discover_benchmarks(hf_token: str | None) -> list[dict]:
|
| 59 |
+
"""Fetch every benchmark:official dataset with a usable leaderboard."""
|
| 60 |
+
print("Discovering official benchmarks...")
|
| 61 |
+
resp = httpx.get(
|
| 62 |
+
"https://huggingface.co/api/datasets",
|
| 63 |
+
params={"filter": "benchmark:official", "limit": 500},
|
| 64 |
+
timeout=30,
|
| 65 |
+
)
|
| 66 |
+
resp.raise_for_status()
|
| 67 |
+
datasets = resp.json()
|
| 68 |
+
print(f" found {len(datasets)} datasets with benchmark:official tag")
|
| 69 |
+
|
| 70 |
+
configs = []
|
| 71 |
+
for d in datasets:
|
| 72 |
+
did = d["id"]
|
| 73 |
+
try:
|
| 74 |
+
info = httpx.get(f"https://huggingface.co/api/datasets/{did}", timeout=15).json()
|
| 75 |
+
except Exception as e:
|
| 76 |
+
print(f" {did}: skipped (info fetch failed: {e})")
|
| 77 |
+
continue
|
| 78 |
+
gated = bool(info.get("gated"))
|
| 79 |
+
card = info.get("cardData") or {}
|
| 80 |
+
if did in OVERRIDES:
|
| 81 |
+
key, pretty = OVERRIDES[did]
|
| 82 |
+
else:
|
| 83 |
+
key = slugify(did)
|
| 84 |
+
pretty = card.get("pretty_name") or did.split("/")[-1]
|
| 85 |
+
|
| 86 |
+
headers = {"Authorization": f"Bearer {hf_token}"} if (gated and hf_token) else {}
|
| 87 |
+
if gated and not hf_token:
|
| 88 |
+
print(f" {did}: skipped (gated, no token)")
|
| 89 |
+
continue
|
| 90 |
+
try:
|
| 91 |
+
lb = httpx.get(
|
| 92 |
+
f"https://huggingface.co/api/datasets/{did}/leaderboard",
|
| 93 |
+
headers=headers,
|
| 94 |
+
timeout=30,
|
| 95 |
+
)
|
| 96 |
+
except Exception as e:
|
| 97 |
+
print(f" {did}: skipped (leaderboard fetch failed: {e})")
|
| 98 |
+
continue
|
| 99 |
+
if lb.status_code != 200:
|
| 100 |
+
print(f" {did}: skipped (status {lb.status_code})")
|
| 101 |
+
continue
|
| 102 |
+
rows = lb.json()
|
| 103 |
+
if not isinstance(rows, list) or len(rows) < MIN_MODELS:
|
| 104 |
+
print(f" {did}: skipped (only {len(rows) if isinstance(rows, list) else '?'} rows)")
|
| 105 |
+
continue
|
| 106 |
+
|
| 107 |
+
lower_is_better = False
|
| 108 |
+
for r in rows:
|
| 109 |
+
if isinstance(r, dict) and "lower_is_better" in r:
|
| 110 |
+
lower_is_better = bool(r["lower_is_better"])
|
| 111 |
+
break
|
| 112 |
+
|
| 113 |
+
configs.append({
|
| 114 |
+
"dataset": did,
|
| 115 |
+
"key": key,
|
| 116 |
+
"name": pretty,
|
| 117 |
+
"gated": gated,
|
| 118 |
+
"lower_is_better": lower_is_better,
|
| 119 |
+
})
|
| 120 |
+
print(f" {did} -> {key} ({len(rows)} rows, lower_is_better={lower_is_better})")
|
| 121 |
+
|
| 122 |
+
return configs
|
| 123 |
|
| 124 |
PALETTE = [
|
| 125 |
"#6366f1", "#0d9488", "#d97706", "#e11d48", "#7c3aed",
|
|
|
|
| 151 |
print(f" error: {e}")
|
| 152 |
return []
|
| 153 |
|
| 154 |
+
lower = config.get("lower_is_better", False)
|
| 155 |
+
seen: dict[str, float] = {}
|
| 156 |
for entry in data:
|
| 157 |
+
if not isinstance(entry, dict):
|
| 158 |
+
continue
|
| 159 |
model_id = entry.get("modelId")
|
| 160 |
score = entry.get("value")
|
| 161 |
if model_id and score is not None:
|
| 162 |
+
try:
|
| 163 |
+
score = float(score)
|
| 164 |
+
except (TypeError, ValueError):
|
| 165 |
+
continue
|
| 166 |
+
if model_id not in seen:
|
| 167 |
+
seen[model_id] = score
|
| 168 |
+
elif (lower and score < seen[model_id]) or (not lower and score > seen[model_id]):
|
| 169 |
seen[model_id] = score
|
| 170 |
|
| 171 |
print(f" {len(seen)} models")
|
|
|
|
| 230 |
hf_token = os.environ.get("HF_TOKEN")
|
| 231 |
print("Generating data.json for bar chart race\n")
|
| 232 |
|
| 233 |
+
benchmark_configs = discover_benchmarks(hf_token)
|
| 234 |
+
print(f"\n{len(benchmark_configs)} usable benchmarks\n")
|
| 235 |
+
|
| 236 |
+
all_scores: dict[str, dict] = {}
|
| 237 |
all_model_ids: set[str] = set()
|
| 238 |
|
| 239 |
+
for config in benchmark_configs:
|
| 240 |
rows = fetch_leaderboard(config, hf_token)
|
| 241 |
if rows:
|
| 242 |
+
all_scores[config["key"]] = {
|
| 243 |
+
"name": config["name"],
|
| 244 |
+
"dataset": config["dataset"],
|
| 245 |
+
"lower_is_better": config["lower_is_better"],
|
| 246 |
+
"rows": rows,
|
| 247 |
+
}
|
| 248 |
all_model_ids.update(r["model_id"] for r in rows)
|
| 249 |
|
| 250 |
print(f"\n{len(all_model_ids)} unique models across {len(all_scores)} benchmarks")
|
|
|
|
| 273 |
"score": round(row["score"], 2),
|
| 274 |
"date": model_dates[mid]["date"],
|
| 275 |
})
|
| 276 |
+
if len(models) >= MIN_MODELS:
|
| 277 |
+
benchmarks[key] = {
|
| 278 |
+
"name": info["name"],
|
| 279 |
+
"dataset": info["dataset"],
|
| 280 |
+
"lower_is_better": info["lower_is_better"],
|
| 281 |
+
"models": models,
|
| 282 |
+
}
|
| 283 |
|
| 284 |
print(f"\nFetching logos for {len(all_providers)} providers...")
|
| 285 |
logos = fetch_all_logos(all_providers)
|