mp-juuuns's picture
Add the sealed final test and expand the 65-arm field with seven figures
a589253 verified
Raw
History Blame Contribute Delete
25.4 kB
"""Figures for the model card: the sealed final test, and the 65-arm field.
Run from benchmark/figures/ . Figures 14-17 need only benchmark/full/*.csv, which ships here.
Sources, all read-only:
final test agents/sessions/2026-09-23/S-20260923-final-test-preflight-v1/{RESULTS,PER_LABEL}.csv
... BASELINE.json
65-arm field benchmark/full/61_arm_bf16.csv + benchmark/full/taskblind_grid.csv
Writes PNGs next to this file.
"""
import csv
import json
import os
import re
import collections
import math
import statistics as st
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
from matplotlib.patches import Patch
from matplotlib.colors import LinearSegmentedColormap, Normalize
from matplotlib.cm import ScalarMappable
# Paths are resolved relative to this file's repository, or overridden by env vars.
HERE = os.path.dirname(os.path.abspath(__file__))
REPO = os.path.abspath(os.path.join(HERE, "..", ".."))
# Final-test inputs are not redistributed in this repository; point SESS at a local copy of
# agents/sessions/2026-09-23/S-20260923-final-test-preflight-v1/ to rebuild figures 11-13.
SESS = os.environ.get("FINAL_TEST_DIR", os.path.join(REPO, "final_test")) + os.sep
BENCH = os.path.join(REPO, "benchmark", "full") + os.sep
OUT = os.path.join(HERE, "")
FLOOR_TEST = json.load(open(SESS + "BASELINE.json"))["always_positive"]["macro_f1"]
FLOOR_CAL = 0.475627 # all-positive predictor on the opened calibration split
INK, MUTED, FAINT = "#1a1a1a", "#6a6a72", "#9a9aa2"
GRID = "#e6e6ea"
# Series hues, checked pairwise in OKLab and under deuter/prot/trit simulation:
# minimum normal-vision dE 18.3, minimum CVD dE 8.6, all >= 30 against white.
ROOTC, GRIDC, QWENC, ENCC = "#1a5496", "#0d7a52", "#b05512", "#9a9aa2"
# Status, never a series colour: always carries a dash pattern, an arrow direction,
# a marker shape or a text label as well.
DOWN = "#c0392b"
ACC = QWENC
def style(ax, xgrid=True, ygrid=False):
ax.grid(axis="both" if (xgrid and ygrid) else ("x" if xgrid else "y"),
color=GRID, lw=.8)
ax.set_axisbelow(True)
for s in ("top", "right"):
ax.spines[s].set_visible(False)
for s in ("bottom", "left"):
ax.spines[s].set_color("#c9c9cf")
ax.tick_params(length=0, colors="#4a4a52")
def footer(fig, text):
fig.text(.006, .012, text, fontsize=8.6, color=MUTED, ha="left")
# ---------------------------------------------------------------- final test
FT_NAMES = {
"qwen35-taskblind-base4l-N32768-commonhead": "task-blind 4L N=32,768",
"qwen35-taskblind-base4l-N65536-commonhead": "task-blind 4L N=65,536",
"qwen35-taskblind-base4l-N16384-commonhead": "task-blind 4L N=16,384",
"qwen35-taskblind-base4l-N8192-commonhead": "task-blind 4L N=8,192",
"qwen35-taskfree-base24l-v248k-commonhead": "historical 24L v248k",
"qwen35-taskfree-base8l-v248k-commonhead": "historical 8L v248k",
"qwen35-taskfree-base4l-v248k-commonhead": "historical 4L v248k",
"qwen35-taskfree-base4l-v128k-commonhead": "historical 4L v128k",
"roberta-base-commonhead": "RoBERTa-base 12L",
"roberta-base-6l-commonhead": "RoBERTa-base 6L",
}
FT_FAM = {"published": (ROOTC, "published root (N=32,768)"),
"grid": (GRIDC, "other task-blind grid points"),
"historical": (ENCC, "historical qwen arms"),
"roberta": (QWENC, "RoBERTa references")}
def ft_family(arm):
if arm == "qwen35-taskblind-base4l-N32768-commonhead":
return "published"
if arm.startswith("qwen35-taskblind"):
return "grid"
if arm.startswith("roberta"):
return "roberta"
return "historical"
def ft_arms():
rows = list(csv.DictReader(open(SESS + "RESULTS.csv")))
g = collections.defaultdict(list)
for r in rows:
g[(r["arm_id"], r["precision"])].append(r)
arms = []
for (a, p), rs in g.items():
cal = [float(x["calibration_macro_f1"]) for x in rs]
tst = [float(x["test_macro_f1"]) for x in rs]
arms.append({"label": FT_NAMES[a] + (" Q8_0" if p != "BF16" else ""),
"fam": ft_family(a), "n": len(rs),
"cal": st.mean(cal), "test": st.mean(tst),
"seeds": sorted(tst),
"sd": st.stdev(tst) if len(tst) > 1 else 0.0})
arms.sort(key=lambda d: d["test"])
return arms
def fig_calibration_to_test():
arms = ft_arms()
fig, ax = plt.subplots(figsize=(10.6, 6.4))
fig.patch.set_facecolor("white")
XMIN, XMAX, XVAL = .468, .646, .624
for i, d in enumerate(arms):
c = FT_FAM[d["fam"]][0]
up = d["test"] >= d["cal"]
if d["sd"]:
ax.plot([d["test"] - d["sd"], d["test"] + d["sd"]], [i, i],
color=c, lw=7, alpha=.20, solid_capstyle="butt", zorder=2)
ax.annotate("", xy=(d["test"], i), xytext=(d["cal"], i),
arrowprops=dict(arrowstyle="-|>", lw=2.0,
color=c if up else DOWN, shrinkA=0, shrinkB=0, alpha=.9))
ax.plot([d["cal"]], [i], "o", ms=7, mfc="white", mec=c, mew=2.0, zorder=3)
ax.plot([d["test"]], [i], "o", ms=9.5, color=c, zorder=4,
mec="white", mew=1.6)
bold = "bold" if d["fam"] == "published" else "normal"
ax.text(XVAL, i, f"{d['test']:.4f}", va="center", ha="right",
fontsize=9.5, color=INK, fontweight=bold)
dl = d["test"] - d["cal"]
ax.text(XMAX - .002, i, f"{dl:+.4f}", va="center", ha="right", fontsize=9,
color=DOWN if dl < 0 else "#4a7a4a", fontweight=bold)
ax.axvline(FLOOR_TEST, color=DOWN, ls=(0, (5, 3)), lw=1.6, zorder=1)
ax.text(FLOOR_TEST + .003, -.62, f"all-positive floor {FLOOR_TEST:.4f}",
va="bottom", ha="left", fontsize=8.8, color=DOWN)
ax.text(XVAL, len(arms) - .34, "test", ha="right", va="bottom", fontsize=8.6, color=FAINT)
ax.text(XMAX - .002, len(arms) - .34, "Δ", ha="right", va="bottom",
fontsize=8.6, color=FAINT)
ax.set_yticks(range(len(arms)))
ax.set_yticklabels([d["label"] for d in arms], fontsize=9.5)
for t, d in zip(ax.get_yticklabels(), arms):
if d["fam"] == "published":
t.set_fontweight("bold")
ax.set_xlabel("macro F1 (14-label fixed denominator)", fontsize=10)
ax.set_xlim(XMIN, XMAX)
ax.set_ylim(-.95, len(arms) - .15)
ax.set_xticks([.48, .50, .52, .54, .56, .58, .60])
style(ax, xgrid=True)
ax.spines["left"].set_visible(False)
handles = [Line2D([], [], marker="o", ls="", color=c, ms=8, label=l)
for c, l in FT_FAM.values()]
handles.append(Line2D([], [], color=DOWN, lw=2.2, label="moved down on test"))
ax.legend(handles=handles, fontsize=8.6, frameon=False, ncol=1,
loc="center left", bbox_to_anchor=(.005, .30), labelspacing=.55)
ax.set_title("Calibration → sealed test\n"
"hollow = calibration mean, filled = test mean, band = sample SD over 3 seeds",
fontsize=11.5, loc="left", color=INK, pad=12)
footer(fig, "Nine of eleven arms moved up and the two RoBERTa references moved up the most, "
"so the direction belongs to the split pair, not to any model.")
fig.tight_layout(rect=(0, .035, 1, 1))
fig.savefig(OUT + "11_final_test_calibration_to_test.png", dpi=170, facecolor="white")
plt.close(fig)
def fig_per_label():
pl = [r for r in csv.DictReader(open(SESS + "PER_LABEL.csv"))
if r["job_id"].startswith("qwen35-taskblind-base4l-N32768-commonhead")
and r["job_id"].endswith("BF16")]
by = collections.defaultdict(list)
for r in pl:
by[r["label"]].append(r)
num = lambda v: float(v) if v not in ("", "null", None) else None
pts = []
for lab, rs in by.items():
pts.append({"lab": lab.replace("_", " ").replace(",", " / "),
"sup": int(rs[0]["support"]),
"f1": st.mean([num(r["f1"]) for r in rs]),
"p": st.mean([num(r["precision"]) for r in rs]),
"r": st.mean([num(r["recall"]) for r in rs])})
pts.sort(key=lambda d: d["f1"])
ramp = LinearSegmentedColormap.from_list("sup", ["#cfe0f0", "#14406f"])
norm = Normalize(vmin=min(p["sup"] for p in pts), vmax=max(p["sup"] for p in pts))
fig, ax = plt.subplots(figsize=(10.2, 6.2))
fig.patch.set_facecolor("white")
ax.barh(range(len(pts)), [p["f1"] for p in pts], height=.64,
color=[ramp(norm(p["sup"])) for p in pts], zorder=3)
for i, p in enumerate(pts):
ax.text(p["f1"] - .012, i, f"{p['f1']:.3f}", va="center", ha="right",
fontsize=8.8, color="white", fontweight="bold", zorder=4)
ax.text(p["f1"] + .014, i, f"n={p['sup']} P {p['p']:.2f} / R {p['r']:.2f}",
va="center", ha="left", fontsize=8.4, color="#5a5a62", zorder=4)
macro = st.mean([p["f1"] for p in pts])
ax.axvline(macro, color="#14406f", ls=(0, (5, 3)), lw=1.5, zorder=2)
ax.text(macro + .006, len(pts) - .42, f"macro F1 {macro:.4f}",
fontsize=9, color="#14406f", ha="left", va="bottom")
ax.set_yticks(range(len(pts)))
ax.set_yticklabels([p["lab"] for p in pts], fontsize=9)
ax.set_xlabel("per-label F1 (3-seed mean)", fontsize=10)
ax.set_xlim(0, 1.16)
ax.set_ylim(-.7, len(pts) - .15)
ax.set_xticks([0, .2, .4, .6, .8, 1.0])
style(ax, xgrid=True)
ax.spines["left"].set_visible(False)
ax.set_title("Published root on the sealed test, per label\n"
"bar shade = support in the 55 test documents",
fontsize=11.5, loc="left", color=INK, pad=12)
cb = fig.colorbar(ScalarMappable(norm=norm, cmap=ramp), ax=ax,
orientation="horizontal", fraction=.030, pad=.12, aspect=44)
cb.set_label("label support (documents)", fontsize=8.6, color=MUTED)
cb.ax.tick_params(labelsize=8, length=0, colors=MUTED)
cb.outline.set_visible(False)
footer(fig, "Recall exceeds precision on all fourteen labels: at these thresholds the head "
"over-predicts. F1 tracks support almost monotonically.")
fig.tight_layout(rect=(0, .035, 1, 1))
fig.savefig(OUT + "12_final_test_per_label.png", dpi=170, facecolor="white")
plt.close(fig)
def fig_seed_spread():
arms = [a for a in ft_arms() if a["n"] == 3]
arms.sort(key=lambda d: d["test"])
fig, ax = plt.subplots(figsize=(10.6, 5.8))
fig.patch.set_facecolor("white")
for i, d in enumerate(arms):
c = FT_FAM[d["fam"]][0]
ax.plot([min(d["seeds"]), max(d["seeds"])], [i, i], color=c, lw=2, alpha=.35,
solid_capstyle="round", zorder=2)
for s in d["seeds"]:
ax.plot([s], [i], "o", ms=7, color=c, alpha=.85, zorder=3, mec="white", mew=1.2)
ax.plot([d["test"]], [i], "|", ms=17, color=INK, mew=2.0, zorder=4)
ax.text(.638, i, f"spread {max(d['seeds']) - min(d['seeds']):.4f}",
va="center", ha="right", fontsize=8.8,
color=DOWN if max(d["seeds"]) - min(d["seeds"]) > .05 else MUTED)
ax.set_yticks(range(len(arms)))
ax.set_yticklabels([d["label"] for d in arms], fontsize=9.5)
ax.set_xlabel("test macro F1, one dot per seed (41 / 42 / 43); tick = mean", fontsize=10)
ax.set_xlim(.478, .642)
ax.set_ylim(-.7, len(arms) - .3)
style(ax, xgrid=True)
ax.spines["left"].set_visible(False)
ax.set_title("Seed spread swamps the gaps between arms\n"
"every arm and seed lands inside a 0.103-wide band on 55 documents",
fontsize=11.5, loc="left", color=INK, pad=12)
footer(fig, "N=16,384 is the extreme case: one seed at 0.5951 and two near 0.51. "
"Three seeds give a sample SD, not a confidence interval.")
fig.tight_layout(rect=(0, .038, 1, 1))
fig.savefig(OUT + "13_final_test_seed_spread.png", dpi=170, facecolor="white")
plt.close(fig)
# ------------------------------------------------------------- the 65 arms
BASE_LAYERS = {"bert-base": 12, "roberta-base": 12, "xlmr-base": 12, "deberta-v3-base": 12,
"mdeberta-v3": 12, "albert-base-v2": 12, "electra-base": 12, "mpnet-base": 12,
"modernbert-base": 22, "distilbert-base": 6, "mbert": 12,
"minilm-multilingual": 12}
def encoder_family(arm_id):
s = arm_id.replace("-commonhead", "")
m = re.match(r"^(.*?)-(\d+)l$", s)
if m and m.group(1) in BASE_LAYERS:
return m.group(1), int(m.group(2))
if s in BASE_LAYERS:
return s, BASE_LAYERS[s]
return None, None
def field():
"""61 measured arms plus the 4 task-blind grid points = 65."""
out = []
for r in csv.DictReader(open(BENCH + "61_arm_bf16.csv")):
fam, _ = encoder_family(r["arm_id"])
out.append({"id": r["arm_id"], "q": float(r["macro_f1_mean"]),
"sd": float(r["macro_f1_sd"]), "p50": float(r["p50_ms"]),
"mib": float(r["weight_file_mib"]), "j": float(r["gpu_j_per_doc"]),
"rss": float(r["peak_rss_mib"]),
"floor": r["degenerate_at_floor"] == "True",
"grp": "encoder" if fam else "qwen"})
for r in csv.DictReader(open(BENCH + "taskblind_grid.csv")):
n = int(r["grid_point_N"])
out.append({"id": f"qwen35-taskblind-base4l-N{n}", "q": float(r["macro_f1_mean"]),
"sd": float(r["macro_f1_sd"]), "p50": float(r["bf16_p50_ms"]),
"mib": float(r["root_mib"]), "j": float(r["bf16_gpu_j_per_doc"]),
"rss": float("nan"), "floor": False,
"grp": "root" if n == 32768 else "grid"})
return out
GRP = {"root": (ROOTC, "this root (N=32,768)"),
"grid": (GRIDC, "task-blind grid"),
"qwen": (QWENC, "other Qwen (3.5 and 2.5)"),
"encoder": (ENCC, "encoder families (10)")}
def pareto(rows, key):
keep = []
for r in rows:
if not any(o["q"] >= r["q"] and o[key] <= r[key] and
(o["q"] > r["q"] or o[key] < r[key]) for o in rows):
keep.append(r)
return sorted(keep, key=lambda r: r[key])
def fig_quality_vs_cost():
F = field()
fig, axes = plt.subplots(1, 2, figsize=(14.6, 6.2), sharey=True)
fig.patch.set_facecolor("white")
for ax, key, xlab, unit in (
(axes[0], "p50", "document p50 latency (ms, log scale)", "ms"),
(axes[1], "j", "GPU energy per document (J, log scale)", "J")):
front = pareto(F, key)
ax.plot([r[key] for r in front], [r["q"] for r in front],
color=INK, lw=1.3, alpha=.45, zorder=2, ls=(0, (4, 3)))
for grp in ("encoder", "qwen", "grid", "root"):
pts = [r for r in F if r["grp"] == grp]
if not pts:
continue
big = grp == "root"
ax.scatter([r[key] for r in pts], [r["q"] for r in pts],
s=150 if big else 46, color=GRP[grp][0], zorder=5 if big else 3,
edgecolor="white", linewidth=1.6 if big else .9,
marker="D" if big else "o", alpha=1 if big else .92)
ax.axhline(FLOOR_CAL, color=DOWN, ls=(0, (5, 3)), lw=1.4, zorder=1)
ax.set_xscale("log")
ax.set_xlabel(xlab, fontsize=10)
style(ax, xgrid=True, ygrid=True)
labelled = []
for j, r in enumerate(front):
if r["grp"] in ("root", "grid"):
continue
nm = r["id"].replace("-commonhead", "").replace("qwen35-", "")
# skip a label that would land on top of one already placed
if any(abs(math.log10(r[key]) - math.log10(o)) < .17 and abs(r["q"] - q) < .012
for o, q in labelled):
continue
labelled.append((r[key], r["q"]))
ax.annotate(nm, (r[key], r["q"]), textcoords="offset points",
xytext=(9, -13 if j % 2 == 0 else 9), fontsize=7.6, color=MUTED)
rt = [r for r in F if r["grp"] == "root"][0]
ax.annotate("this root", (rt[key], rt["q"]), textcoords="offset points",
xytext=(13, 9), fontsize=8.8, color=ROOTC, fontweight="bold")
axes[0].set_ylabel("macro F1 (3-seed mean)", fontsize=10)
axes[0].set_ylim(.466, .582)
axes[0].text(6.1, FLOOR_CAL + .0018, f"all-positive floor {FLOOR_CAL:.4f}",
fontsize=8.5, color=DOWN, va="bottom")
handles = [Line2D([], [], marker="D" if k == "root" else "o", ls="", color=c,
ms=9 if k == "root" else 7, label=l) for k, (c, l) in GRP.items()]
handles.append(Line2D([], [], color=INK, lw=1.3, ls=(0, (4, 3)), alpha=.45,
label="Pareto frontier"))
handles.append(Line2D([], [], color=DOWN, lw=1.4, ls=(0, (5, 3)),
label="all-positive floor"))
fig.legend(handles=handles, fontsize=8.8, frameon=False, ncol=6,
loc="upper left", bbox_to_anchor=(.006, .945), columnspacing=1.5)
fig.suptitle("65 arms, one frozen protocol: quality barely moves, cost moves by orders of magnitude",
fontsize=12.5, x=.006, ha="left", y=.975, color=INK)
footer(fig, "Dashed line is the Pareto frontier. The RoBERTa family owns the cheap half of it; "
"the Qwen3.5 arms own the top. Every arm lives within 0.093 of a trivial all-positive predictor.")
fig.tight_layout(rect=(0, .038, 1, .895))
fig.savefig(OUT + "14_field_quality_vs_cost.png", dpi=170, facecolor="white")
plt.close(fig)
def fig_metric_spans():
F = field()
specs = [("macro F1", [r["q"] for r in F], "", 4),
("peak RSS", [r["rss"] for r in F if r["rss"] == r["rss"]], "MiB", 0),
("document p50", [r["p50"] for r in F], "ms", 0),
("GPU energy / doc", [r["j"] for r in F], "J", 2),
("weight file", [r["mib"] for r in F], "MiB", 0)]
rows = []
for name, vals, unit, dec in specs:
lo, hi = min(vals), max(vals)
rows.append((name, lo, hi, hi / lo if lo > 0 else float("inf"), unit, dec))
rows.sort(key=lambda t: t[3])
fig, ax = plt.subplots(figsize=(11.0, 4.4))
fig.patch.set_facecolor("white")
for i, (name, lo, hi, ratio, unit, dec) in enumerate(rows):
c = ROOTC if ratio > 5 else QWENC
ax.plot([1, ratio], [i, i], color=c, lw=9, solid_capstyle="round",
alpha=.85, zorder=3)
ax.text(ratio * 1.09, i, f"{ratio:.1f}×", va="center", ha="left",
fontsize=11, color=c, fontweight="bold")
ax.text(ratio * 1.09, i - .30, f"{lo:,.{dec}f} → {hi:,.{dec}f} {unit}".strip(),
va="center", ha="left", fontsize=8.3, color=MUTED)
ax.set_yticks(range(len(rows)))
ax.set_yticklabels([r[0] for r in rows], fontsize=10)
ax.set_xscale("log")
ax.set_xlim(.92, 260)
ax.set_ylim(-.7, len(rows) - .3)
ax.set_xlabel("ratio of the largest arm to the smallest, across all 65 arms (log scale)",
fontsize=10)
style(ax, xgrid=True)
ax.spines["left"].set_visible(False)
ax.set_title("What actually varies across the field\n"
"the answers are nearly identical; what they cost to produce is not",
fontsize=11.5, loc="left", color=INK, pad=12)
footer(fig, f"The best arm beats a trivial all-positive predictor ({FLOOR_CAL:.4f}) by 0.0930, "
"and the worst three tie it exactly. Peak RSS is dominated by the harness, not the model.")
fig.tight_layout(rect=(0, .05, 1, 1))
fig.savefig(OUT + "15_field_metric_spans.png", dpi=170, facecolor="white")
plt.close(fig)
def fig_depth_effect():
rows = list(csv.DictReader(open(BENCH + "61_arm_bf16.csv")))
fams = collections.defaultdict(list)
for r in rows:
fam, L = encoder_family(r["arm_id"])
if fam:
fams[fam].append((L, float(r["macro_f1_mean"]),
r["degenerate_at_floor"] == "True"))
order = sorted(fams, key=lambda k: -max(q for _, q, _ in fams[k]))
fig, axes = plt.subplots(3, 4, figsize=(14.2, 7.4), sharex=True, sharey=True)
fig.patch.set_facecolor("white")
shallow_wins = 0
for ax, fam in zip(axes.ravel(), order):
pts = sorted(fams[fam])
xs = [p[0] for p in pts]
ys = [p[1] for p in pts]
deepest = max(xs)
best_L = max(pts, key=lambda t: t[1])[0]
win = best_L != deepest
shallow_wins += win
c = ROOTC if win else QWENC
ax.plot(xs, ys, "-", color=c, lw=2, zorder=3, alpha=.9)
for L, q, fl in pts:
ax.plot([L], [q], "X" if fl else "o", ms=8.5 if fl else (8 if L == best_L else 6),
color=DOWN if fl else c, zorder=4, mec="white", mew=1.3)
ax.axhline(FLOOR_CAL, color=DOWN, ls=(0, (4, 3)), lw=1.1, zorder=1)
ax.set_title(fam, fontsize=9.5, loc="left", color=INK, pad=4)
ax.text(.97, .18, "best at %dL" % best_L, transform=ax.transAxes,
ha="right", va="bottom", fontsize=8.2,
color=ROOTC if win else MUTED, fontweight="bold" if win else "normal")
ax.set_xticks([4, 6, 8, 12, 22])
ax.set_ylim(.468, .566)
style(ax, xgrid=False, ygrid=True)
for ax in axes[-1]:
ax.set_xlabel("layers", fontsize=9)
for ax in axes[:, 0]:
ax.set_ylabel("macro F1", fontsize=9)
fig.suptitle(f"Depth does not reliably buy quality: in {shallow_wins} of {len(order)} encoder "
f"families the best arm is not the deepest one",
fontsize=12.5, x=.006, ha="left", y=.978, color=INK)
handles = [Line2D([], [], color=ROOTC, lw=2.4, label="a shallower variant wins"),
Line2D([], [], color=QWENC, lw=2.4, label="the deepest variant wins"),
Line2D([], [], marker="X", ls="", color=DOWN, ms=8,
label="failed to train: sits exactly on the all-positive floor")]
fig.legend(handles=handles, fontsize=9, frameon=False, ncol=3,
loc="lower left", bbox_to_anchor=(.006, .035))
footer(fig, "Same frozen protocol, three seeds, same split. Each family's own full-depth "
"checkpoint is the rightmost point.")
fig.tight_layout(rect=(0, .10, 1, .948))
fig.savefig(OUT + "16_field_depth_effect.png", dpi=170, facecolor="white")
plt.close(fig)
def fig_resolution_floor():
F = sorted(field(), key=lambda r: r["q"])
med_sd = st.median([r["sd"] for r in F if r["sd"] > 0])
top = max(r["q"] for r in F)
band = top - med_sd
fig, ax = plt.subplots(figsize=(10.4, 9.4))
fig.patch.set_facecolor("white")
ax.axvspan(band, top + .004, color=ROOTC, alpha=.08, zorder=1)
for i, r in enumerate(F):
c = GRP[r["grp"]][0]
if r["sd"]:
ax.plot([r["q"] - r["sd"], r["q"] + r["sd"]], [i, i], color=c, lw=3.4,
alpha=.30, solid_capstyle="butt", zorder=2)
if r["floor"]:
ax.plot([r["q"]], [i], "X", ms=7.5, color=DOWN, zorder=4, mec="white", mew=1.0)
else:
ax.plot([r["q"]], [i], "D" if r["grp"] == "root" else "o",
ms=8 if r["grp"] == "root" else 5.4, color=c,
zorder=4, mec="white", mew=1.0)
ax.axvline(FLOOR_CAL, color=DOWN, ls=(0, (5, 3)), lw=1.5, zorder=3)
ax.text(FLOOR_CAL - .0015, len(F) * .55, f"all-positive floor {FLOOR_CAL:.4f}",
rotation=90, va="center", ha="right", fontsize=8.6, color=DOWN)
n_in = sum(1 for r in F if r["q"] >= band)
ax.set_yticks(range(len(F)))
ax.set_yticklabels([r["id"].replace("-commonhead", "") for r in F], fontsize=6.9)
for t, r in zip(ax.get_yticklabels(), F):
if r["grp"] == "root":
t.set_fontweight("bold")
t.set_color(ROOTC)
ax.set_xlabel("macro F1 (3-seed mean, bar = sample SD)", fontsize=10)
ax.set_xlim(.466, .607)
ax.set_ylim(-1.2, len(F) - .3)
style(ax, xgrid=True)
ax.spines["left"].set_visible(False)
ax.set_title("All 65 arms on one axis\n"
f"shaded band = one median seed-SD ({med_sd:.4f}) below the best arm; "
f"{n_in} arms fall inside it",
fontsize=11.5, loc="left", color=INK, pad=12)
handles = [Line2D([], [], marker="D" if k == "root" else "o", ls="", color=c,
ms=8 if k == "root" else 6, label=l) for k, (c, l) in GRP.items()]
handles.append(Line2D([], [], marker="X", ls="", color=DOWN, ms=7.5,
label="failed to train (on the floor)"))
ax.legend(handles=handles, fontsize=8.6, frameon=False, loc="upper left",
bbox_to_anchor=(.012, .995), labelspacing=.5)
footer(fig, "Three arms — mdeberta-v3-4l, deberta-v3-base-6l, deberta-v3-base-8l — score exactly "
"the floor. They are reported rather than dropped.")
fig.tight_layout(rect=(0, .026, 1, 1))
fig.savefig(OUT + "17_field_resolution_floor.png", dpi=170, facecolor="white")
plt.close(fig)
if __name__ == "__main__":
os.makedirs(OUT, exist_ok=True)
for fn in (fig_calibration_to_test, fig_per_label, fig_seed_spread,
fig_quality_vs_cost, fig_metric_spans, fig_depth_effect,
fig_resolution_floor):
fn()
print("ok", fn.__name__)