"""Recompute the published SplatBench results from the episode tables. uv run python scripts/analyze.py # prints the tables, writes results/analysis.json uv run python scripts/analyze.py --write-table # also rewrites data/leaderboard/leaderboard.parquet Definitions * Task score: the mean over a task's runs (two per task). Model score: the mean of its task scores. * 95% intervals: bootstrap over tasks (10,000 resamples). Paired differences: bootstrap over the tasks both sides ran. The resampling streams are numpy default_rng(0), consumed in a fixed order (below), which reproduces the published intervals exactly. * Early submit: the model's first submit comes before step 20 (of 40 calls). * Settings: medium_effort (the leaderboard: 8 models, all 30 tasks), high_effort and max_effort (7 models, the 15-task effort subset), early_submit_refused (the 4 models that stop early at medium effort, same 15 tasks; the first submit before call 20 is refused once), one_shot (7 models, the 15 build tasks: one call, no renders). """ import argparse import json import statistics as st from collections import defaultdict from pathlib import Path import numpy as np import pyarrow.parquet as pq ap = argparse.ArgumentParser() ap.add_argument("--data", default="data") ap.add_argument("--out", default="results/analysis.json") ap.add_argument("--write-table", action="store_true", help="write data/leaderboard/leaderboard.parquet") a = ap.parse_args() SETTINGS = ["medium_effort", "high_effort", "max_effort", "early_submit_refused", "one_shot"] COLS = ["episode_id", "setting", "model", "model_name", "task_id", "run", "kind", "tier", "effort_subset", "score", "cost_usd", "wall_s", "first_submit_step", "early_submit", "best_score", "part_errors"] B = 10000 def load(setting): rows = pq.read_table(Path(a.data) / "episodes" / f"{setting}.parquet", columns=COLS).to_pylist() # run 1 before run 2, then model, then task: the order the bootstrap streams were drawn in return sorted(rows, key=lambda e: (e["run"], e["model"], e["task_id"])) E = {s: load(s) for s in SETTINGS} NAME = {e["model"]: e["model_name"] for s in SETTINGS for e in E[s]} SUBSET = {e["task_id"] for e in E["medium_effort"] if e["effort_subset"]} BUILD = {e["task_id"] for e in E["medium_effort"] if e["kind"] == "build"} def tmeans(X) -> dict: d = defaultdict(list) for e in X: d[e["task_id"]].append(e["score"]) return {t: st.mean(v) for t, v in d.items()} def r1(x): return None if x is None else round(float(x), 1) def make_ci(rng): def ci(vals): v = np.asarray(list(vals), dtype=float) if len(v) < 2: return None b = v[rng.integers(0, len(v), (B, len(v)))].mean(1) return [round(float(np.percentile(b, 2.5)), 1), round(float(np.percentile(b, 97.5)), 1)] return ci def make_paired(ci): def paired(x: dict, y: dict): ts = sorted(set(x) & set(y)) d = np.array([x[t] - y[t] for t in ts]) return dict(tasks=len(ts), mean_diff=round(float(d.mean()), 1), ci95=ci(d), wins=int((d > 0).sum())) return paired def costs(X): return dict(episodes=len(X), cost_usd=float(np.mean([e["cost_usd"] for e in X])), minutes=float(np.mean([e["wall_s"] / 60 for e in X]))) # ---------------------------------------------------------------- leaderboard: medium effort, 30 tasks ci = make_ci(np.random.default_rng(0)) paired = make_paired(ci) M = E["medium_effort"] models = sorted({e["model"] for e in M}) models = sorted(models, key=lambda m: -st.mean(tmeans([e for e in M if e["model"] == m]).values())) board = {} for m in models: # draw order 1: one interval per model, in rank order X = [e for e in M if e["model"] == m] tm = tmeans(X) tier = lambda c: r1(st.mean([e["score"] for e in X if c(e)])) board[m] = dict(score=r1(st.mean(tm.values())), ci95=ci(tm.values()), tasks=len(tm), **costs(X), build_procedural=tier(lambda e: e["kind"] == "build" and e["tier"] == "procedural"), build_nerf_synthetic=tier(lambda e: e["kind"] == "build" and e["tier"] == "nerf_synthetic"), build_captured=tier(lambda e: e["kind"] == "build" and e["tier"] == "captured"), reassembly=tier(lambda e: e["kind"] == "reassembly"), early_submits=sum(e["early_submit"] for e in X)) for x, y in zip(models, models[1:]): # draw order 2: neighbours in the ranking board[x]["gap_to_next"] = dict(model=y, **paired(tmeans([e for e in M if e["model"] == x]), tmeans([e for e in M if e["model"] == y]))) for m in models: # no draws below this line in this block X = [e for e in M if e["model"] == m] parts = [p for e in X if e["kind"] == "reassembly" for p in e["part_errors"] if p["rotation_error_deg"] is not None] build = [e for e in X if e["kind"] == "build"] board[m]["parts_within_15deg"] = round(float(np.mean([p["rotation_error_deg"] <= 15 for p in parts])), 3) board[m]["build_best_minus_final"] = r1(np.mean([e["best_score"] - e["score"] for e in build])) # ---------------------------------------------------------------- settings: effort, early submit refused, one-shot ci = make_ci(np.random.default_rng(0)) paired = make_paired(ci) med15 = [e for e in M if e["task_id"] in SUBSET] by_eff = {"medium": med15, "high": E["high_effort"], "max": E["max_effort"]} eff_models = sorted({e["model"] for e in E["high_effort"]} | {e["model"] for e in E["max_effort"]}) def summary(X): tm = tmeans(X) return dict(score=r1(st.mean(tm.values())), ci95=ci(tm.values()), tasks=len(tm), **costs(X), early_submits=sum(e["early_submit"] for e in X)) effort = dict(ranking={}, neighbours={}, models={m: {} for m in eff_models}) for eff, X in by_eff.items(): # draw order 1: neighbours at each effort level bm = {m: [e for e in X if e["model"] == m] for m in eff_models} order = sorted(bm, key=lambda m: -st.mean(tmeans(bm[m]).values())) effort["ranking"][eff] = order effort["neighbours"][eff] = [dict(a=x, b=y, **paired(tmeans(bm[x]), tmeans(bm[y]))) for x, y in zip(order, order[1:])] for m in eff_models: # draw order 2: per model, medium / high / max, each with its change vs medium med = tmeans([e for e in med15 if e["model"] == m]) for eff, X in by_eff.items(): Xm = [e for e in X if e["model"] == m] effort["models"][m][eff] = summary(Xm) if eff != "medium": effort["models"][m][eff]["vs_medium"] = paired(tmeans(Xm), med) refused = {} R = E["early_submit_refused"] for m in sorted({e["model"] for e in R}): # draw order 3 G = [e for e in R if e["model"] == m] S = [e for e in med15 if e["model"] == m] refused[m] = dict(standard=summary(S), refused=summary(G), refused_vs_standard=paired(tmeans(G), tmeans(S)), refusals=sum(1 for e in G if e["first_submit_step"] is not None and e["first_submit_step"] <= 20)) one_shot = {} O = E["one_shot"] for m in sorted({e["model"] for e in O}): # draw order 4 Om = [e for e in O if e["model"] == m] Fm = [e for e in M if e["model"] == m and e["task_id"] in BUILD] to, tf = tmeans(Om), tmeans(Fm) one_shot[m] = dict(one_shot=summary(Om), full=summary([e for e in Fm if e["task_id"] in to]), gain_from_feedback=paired(tf, to)) # separate streams, one per comparison (seed 0 each): are the leading three level on a single call? one_shot_pairs = {} for x, y in [("gpt-6-astra", "gpt-6.1-sol"), ("gpt-6-astra", "claude-opus-5.5"), ("gpt-6.1-sol", "claude-opus-5.5")]: for label, X in (("one_shot", O), ("full", [e for e in M if e["task_id"] in BUILD])): tx = tmeans([e for e in X if e["model"] == x]) ty = tmeans([e for e in X if e["model"] == y]) ts = sorted(set(tx) & set(ty)) d = np.array([tx[t] - ty[t] for t in ts]) rng = np.random.default_rng(0) b = d[rng.integers(0, len(d), (B, len(d)))].mean(1) one_shot_pairs[f"{label}: {x} - {y}"] = dict( mean_diff=r1(d.mean()), ci95=[r1(np.percentile(b, 2.5)), r1(np.percentile(b, 97.5))], wins=int((d > 0).sum())) out = dict(models={m: NAME[m] for m in NAME}, leaderboard=dict(order=models, models=board), effort=effort, early_submit_refused=refused, one_shot=one_shot, one_shot_pairs=one_shot_pairs, episodes={s: len(E[s]) for s in SETTINGS}) tasks = pq.read_table(Path(a.data) / "tasks" / "tasks.parquet", columns=["task_id", "kind", "baseline_one_gaussian", "baseline_gd64", "baseline_scrambled_start"]).to_pylist() out["reference"] = dict( one_gaussian=r1(np.mean([t["baseline_one_gaussian"] for t in tasks])), gd64=r1(np.mean([t["baseline_gd64"] for t in tasks])), scrambled_start=r1(np.mean([t["baseline_scrambled_start"] for t in tasks if t["kind"] == "reassembly"]))) Path(a.out).parent.mkdir(parents=True, exist_ok=True) Path(a.out).write_text(json.dumps(out, indent=1)) # ---------------------------------------------------------------- tables f = lambda v, d=1: "–" if v is None else f"{v:.{d}f}".replace("-", "−") cint = lambda c: "" if not c else f"[{f(c[0])}, {f(c[1])}]" usd = lambda v: f"${v:.3f}" if v < 0.1 else f"${v:.2f}" diff = lambda p: f"{'+' if p['mean_diff'] > 0 else ''}{f(p['mean_diff'])} {cint(p['ci95'])}" print(f"Leaderboard: medium effort, {len(SUBSET) * 2} tasks, 2 runs each ({len(M)} episodes)\n") print("| # | Model | SplatScore [95% CI] | Cost per episode | Time per episode | Gap to next [95% CI] | Tasks won vs next |") print("|---|---|---:|---:|---:|---:|---:|") for i, m in enumerate(models): b = board[m] g = b.get("gap_to_next") won = f"{g['wins']}/{g['tasks']}" if g else "" print(f"| {i + 1} | {NAME[m]} | {f(b['score'])} {cint(b['ci95'])} | {usd(b['cost_usd'])} | {b['minutes']:.1f} min | " f"{diff(g) if g else ''} | {won} |") print("\nReasoning effort: the 15-task subset\n") print("| Model | Medium | High | Max | Max − medium [95% CI] | Cost per episode (medium · high · max) |") print("|---|---:|---:|---:|---:|---:|") for m in effort["ranking"]["medium"]: r = effort["models"][m] print(f"| {NAME[m]} | {f(r['medium']['score'])} | {f(r['high']['score'])} | {f(r['max']['score'])} | " f"{diff(r['max']['vs_medium'])} | {usd(r['medium']['cost_usd'])} · {usd(r['high']['cost_usd'])} · {usd(r['max']['cost_usd'])} |") print("\nEarly submit refused once: the 15-task subset, medium effort\n") print("| Model | Standard | Early submit refused | Difference [95% CI] | Episodes with a refusal |") print("|---|---:|---:|---:|---:|") for m, r in refused.items(): print(f"| {NAME[m]} | {f(r['standard']['score'])} | {f(r['refused']['score'])} | {diff(r['refused_vs_standard'])} | " f"{r['refusals']}/{r['refused']['episodes']} |") print("\nOne-shot reconstruction: the 15 build tasks, medium effort\n") print("| Model | One-shot | Full episode | Gain from feedback [95% CI] |") print("|---|---:|---:|---:|") for m in sorted(one_shot, key=lambda m: -one_shot[m]["full"]["score"]): r = one_shot[m] print(f"| {NAME[m]} | {f(r['one_shot']['score'])} | {f(r['full']['score'])} | {diff(r['gain_from_feedback'])} |") print("\nLeading three, paired over the build tasks:", json.dumps(one_shot_pairs)) print("\nReference points, mean over tasks:", json.dumps(out["reference"])) print("Reassembly parts turned back to within 15° (medium):", {NAME[m]: board[m]["parts_within_15deg"] for m in models}) print("Build tasks, best intermediate score minus final score (medium):", {NAME[m]: board[m]["build_best_minus_final"] for m in models}) if a.write_table: import pyarrow as pa TASKS = {"medium_effort": "all 30 tasks", "high_effort": "15-task effort subset", "max_effort": "15-task effort subset", "early_submit_refused": "15-task effort subset", "one_shot": "15 build tasks"} rows = [] def row(setting, rank, m, s, **kw): c = s.get("ci95") or [None, None] rows.append(dict(setting=setting, tasks=TASKS[setting], rank=rank, model=m, model_name=NAME[m], episodes=s["episodes"], score=s["score"], ci95_low=c[0], ci95_high=c[1], cost_usd_per_episode=round(s["cost_usd"], 4), minutes_per_episode=round(s["minutes"], 2), early_submits=s["early_submits"], **kw)) def cmp(p, label, ref): c = p["ci95"] or [None, None] return dict(compared_with=label, score_compared=ref, difference=p["mean_diff"], difference_ci95_low=c[0], difference_ci95_high=c[1]) for i, m in enumerate(models): b, g = board[m], board[m].get("gap_to_next") or {} gc = g.get("ci95") or [None, None] row("medium_effort", i + 1, m, b, gap_to_next=g.get("mean_diff"), gap_to_next_ci95_low=gc[0], gap_to_next_ci95_high=gc[1], tasks_won_vs_next=g.get("wins"), build_procedural=b["build_procedural"], build_nerf_synthetic=b["build_nerf_synthetic"], build_captured=b["build_captured"], reassembly=b["reassembly"], parts_within_15deg=b["parts_within_15deg"]) for eff, setting in (("high", "high_effort"), ("max", "max_effort")): for i, m in enumerate(effort["ranking"][eff]): r = effort["models"][m] row(setting, i + 1, m, r[eff], **cmp(r[eff]["vs_medium"], "medium effort, same tasks", r["medium"]["score"])) for i, m in enumerate(sorted(refused, key=lambda m: -refused[m]["refused"]["score"])): r = refused[m] row("early_submit_refused", i + 1, m, r["refused"], **cmp(r["refused_vs_standard"], "standard protocol at medium effort, same tasks", r["standard"]["score"])) for i, m in enumerate(sorted(one_shot, key=lambda m: -one_shot[m]["one_shot"]["score"])): r = one_shot[m] g = r["gain_from_feedback"] neg = dict(g, mean_diff=-g["mean_diff"], ci95=[-g["ci95"][1], -g["ci95"][0]]) row("one_shot", i + 1, m, r["one_shot"], **cmp(neg, "full episode at medium effort, same tasks", r["full"]["score"])) keys = [] for r in rows: keys += [k for k in r if k not in keys] path = Path(a.data) / "leaderboard" / "leaderboard.parquet" path.parent.mkdir(parents=True, exist_ok=True) pq.write_table(pa.Table.from_pylist([{k: r.get(k) for k in keys} for r in rows]), path) print(f"\nwrote {path} ({len(rows)} rows)")