"""Markdown fragments about RACE-Net shared by the README and the Hugging Face model card (generated from results).""" import json from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def _p(x): return f"{100 * x:.1f}" def selection_md(): p = ROOT / "models/racenet/selection.json" if not p.exists(): return "" s = json.loads(p.read_text()) if "dev_mean" not in s["candidates"][0]: return "" ref = s["references_dev"] def dev_mean(m): return sum(ref[k][m]["mean"] for k in ref) / len(ref) def row(c): b = "**" if c["selected"] else "" kind = "EM-refinement" if c.get("advisors") else "plain" return (f"| {b}{c['name']}{' (released)' if c['selected'] else ''}{b} | {c['generator']} · {kind} | {c['steps']:,} | {c['params']:,} | " f"{_p(c['synthetic_v3'])} | {b}{_p(c['dev_mean'])}{b} | {_p(c['dev_pool_mean'])} | {_p(c['test']['SO-101']['mean'])} / {_p(c['test']['Panda']['mean'])} | " f"{_p(c['test_pool']['SO-101']['mean'])} / {_p(c['test_pool']['Panda']['mean'])} |") rows = "\n".join(row(c) for c in sorted(s["candidates"], key=lambda c: -c["dev_mean"])) note = "" kp = ROOT / "results/kaggle/racenet_training.json" if kp.exists(): k = json.loads(kp.read_text()) note = (f"\nCheckpoints marked Kaggle were trained in Kaggle CPU notebooks ({k['cpus']} vCPU; logs in `results/kaggle/`). " "All checkpoints are in `models/racenet/candidates/`.\n") return f"""**Checkpoints and selection.** Rule: {s['rule']}. The history splits are the benchmark's unlabelled calibration data; no label-free method ever used their labels, so they serve as development data for the two arms, and the evaluation splits stay test sets. Test columns were computed after the choice and are shown for transparency. On the same development sets RACE-S online scores {_p(dev_mean('race_s_online (new)'))} and RACE online {_p(dev_mean('race_online (new)'))}. | checkpoint | generator · type | steps | params | synthetic (v3) | dev: RACE-Net-V (selects) | dev: RACE-Pool | test SO-101 / Panda: RACE-Net-V | test: RACE-Pool | |---|---|---:|---:|---:|---:|---:|---:|---:| {rows} {note}""" def scaling_md(img="media/figures/racenet_scaling.png"): p = ROOT / "results/racenet/analysis.json" if not p.exists(): return "" d = json.loads(p.read_text()) def at(key, x): return next(r for r in d[key] if r["x"] == x)["acc"] a5, a16 = at("liar_fraction_J5", 0.6), d["liar_fraction_J16"][-1]["acc"] big, w8, wk = d["swarm_size"][-1], d["window"][0]["acc"], d["receiver_skill_clean"][0]["acc"] v2 = "" if "race_net_v1" in wk: w7 = at("receiver_skill_clean", 0.7) v2 = (f"- **Against the first release.** Weak receivers: {_p(wk['race_net'])} at 55% and {_p(w7['race_net'])} at 70% receiver accuracy " f"(first release {_p(wk['race_net_v1'])} and {_p(w7['race_net_v1'])}). {big['J']}-agent swarms: {_p(big['acc']['race_net'])} (first release " f"{_p(big['acc']['race_net_v1'])}).\n") pool = "" if "race_pool" in wk: pool = (f"- **RACE-Pool** on the same sweeps: {_p(a5['race_pool'])} with 3 of 5 lying, {_p(big['acc']['race_pool'])} at {big['J']} agents, " f"{_p(wk['race_pool'])} with a 55% receiver.\n") return f"""