Spaces:
Running
Running
File size: 5,765 Bytes
65cf3d7 5c726db 65cf3d7 5c726db 65cf3d7 5c726db 65cf3d7 2005bdf 65cf3d7 5c726db 2005bdf 5c726db 65cf3d7 5c726db 65cf3d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | """Recompute the leaderboard from models/ and results/, then write leaderboard.json and index.html.
Run it from the root of the Space after adding or changing results:
pip install pink-eval # a version that bundles the oracle grades of every judge below
python scripts/build_leaderboard.py
Every judge is scored against its own oracle grades bundled in pink-eval (``fermat:<judge>``).
A judge whose oracle grades the installed pink-eval does not bundle, or that has no results yet, is shown as "grading".
It also lists every evaluated Hugging Face model, plus the open judges, in the README's ``models:`` metadata.
"""
import datetime as dt
import json
import re
from pathlib import Path
import numpy as np
from pink.score import PACKAGED_ORACLES, load_grades, pink_table
ROOT = Path(__file__).resolve().parents[1]
TABS = [ # id = pink-eval judge preset = results/<id>/ = bundled oracle "fermat:<id>"
dict(id="qwen3.8-27b", label="Qwen3.8-27B", sub="closest open judge to GPT-5",
desc="Graded by Qwen3.8-27B with thinking, the open judge that agrees best with GPT-5, against its own grades "
"of the oracle. New submissions go here.",
notes=["Paper models are graded from the exact transcriptions GPT-5 saw; new models use the paper's OCR prompt "
"with thinking off, or the model card's prompt for dedicated OCR models.",
"The judge is also one of the graded models (Qwen3.8-27B), so a family preference cannot be ruled out. "
"On the paper models it ranks like GPT-5 (Kendall τ = 0.98).",
"Empty transcriptions and repetition loops too long for the judge's 16k context count as 0."]),
dict(id="qwen3-next-80b", label="Qwen3-Next-80B", sub="paper appendix judge",
desc="Graded by Qwen3-Next-80B-A3B-Thinking against its bundled oracle grades, as in the GitHub README "
"(November 2026).",
notes=["Paper models (tag “paper”) are re-graded from their original transcriptions.",
"This judge scores coarsely, so its over-correction rates run well below GPT-5's. Compare rates only "
"within one tab.",
"Empty transcriptions and repetition loops too long for the judge's 16k context count as 0."]),
dict(id="gpt-5", label="GPT-5", sub="paper, Table 1",
desc="The paper's main results: GPT-5 (reasoning effort medium) as the judge, on all 2,244 FERMAT samples.",
notes=["The printed Table 1 swaps the two Pixtral PINK values; these are the correct ones.",
"As in the paper, samples the judge could not grade are left out for these rows."]),
]
JUDGE_REPOS = ["Qwen/Qwen3.8-27B", "Qwen/Qwen3.5-9B", "Qwen/Qwen3-Next-80B-A3B-Thinking-FP8"] # open judges above
def score(path, oracle, missing, seed=0, draws=2000):
model = load_grades(path)
t = pink_table(model, oracle, missing=missing)
pen, ora = t["penalized_total"].to_numpy(), t["oracle_total"].to_numpy()
idx = np.random.default_rng(seed).integers(0, len(t), (draws, len(t)))
boot = pen[idx].sum(1) / ora[idx].sum(1)
return dict(pink=round(float(pen.sum() / ora.sum()), 6), lo=round(float(np.percentile(boot, 2.5)), 6),
hi=round(float(np.percentile(boot, 97.5)), 6), oc=round(float(t["over_corrected"].mean()), 6),
raw=round(float(t["model_total"].sum() / ora.sum()), 6),
graded=int(oracle.index.isin(model.index).sum()), n=int(len(oracle)))
def board(judge):
files = sorted((ROOT / "results" / judge).glob("*.csv"))
if f"fermat:{judge}" not in PACKAGED_ORACLES or not files:
return None
oracle = load_grades(f"fermat:{judge}")
rows = []
for f in files:
meta = json.loads((ROOT / "models" / f"{f.stem}.json").read_text()) # every result needs a model card
# Leaderboard rule: an ungraded sample counts as 0. Only the paper's GPT-5 rows keep the paper's convention.
missing = "drop" if judge == "gpt-5" and meta.get("source") == "paper" else "zero"
rows.append(dict(id=f.stem, name=meta["name"], url=meta.get("url"), type=meta["type"],
source=meta.get("source", "community"), params=meta.get("params_b"), note=meta.get("note", ""),
**score(f, oracle, missing)))
return sorted(rows, key=lambda r: -r["pink"])
def sync_readme_models():
"""Rewrite the ``models:`` list in the README front matter from models/*.json and JUDGE_REPOS."""
hub = "https://huggingface.co/"
cards = (json.loads(p.read_text()) for p in (ROOT / "models").glob("*.json"))
repos = {m["url"][len(hub):] for m in cards if (m.get("url") or "").startswith(hub)} | set(JUDGE_REPOS)
readme = ROOT / "README.md"
text = readme.read_text()
end = text.index("\n---\n", 6) # front matter = text[4:end]
meta = re.sub(r"^models:\n(?: - .*\n)*", "", text[4:end] + "\n", flags=re.M)
meta += "models:\n" + "".join(f" - {r}\n" for r in sorted(repos, key=str.lower))
readme.write_text("---\n" + meta.rstrip("\n") + text[end:])
return len(repos)
def main():
data = dict(updated=dt.date.today().isoformat(), tabs=[dict(t, rows=board(t["id"])) for t in TABS])
(ROOT / "leaderboard.json").write_text(json.dumps(data, ensure_ascii=False, indent=1) + "\n")
page = (ROOT / "scripts" / "page_template.html").read_text()
page = page.replace("__LB_DATA__", json.dumps(data, ensure_ascii=False)).replace("__UPDATED__", data["updated"])
(ROOT / "index.html").write_text(page)
print({t["id"]: len(t["rows"]) if t["rows"] else "grading" for t in data["tabs"]}, "| README models:", sync_readme_models())
if __name__ == "__main__":
main()
|