"""Grafici della corsa di conferma: PNG + un HTML autonomo (SVG in linea, nessuna dipendenza esterna). Uso: ~/.hermes/cache/scratch/mpl-venv/bin/python analysis/charts.py (matplotlib solo per disegnare)""" import io import json from pathlib import Path import matplotlib matplotlib.use("Agg") import matplotlib.pyplot as plt # noqa: E402 import stats as S # noqa: E402 OUT = Path(__file__).resolve().parents[1] / "charts" OUT.mkdir(exist_ok=True) A = Path(__file__).resolve().parent summ = json.load(open(A / "summary.json")) xsum = json.load(open(A / "extra.json")) POLS = ["A", "D", "B", "T"] NAMES = {"A": "full window", "D": "mnemonic-proxy", "B": "summary (LLM compaction)", "T": "truncation"} COL = {"A": "#7f7f7f", "D": "#1f77b4", "B": "#ff7f0e", "T": "#2ca02c"} SVGS = {} LAB = {"unite": "64k + 128k pooled"} def save(fig, name): fig.savefig(OUT / (name + ".png"), dpi=130, bbox_inches="tight") buf = io.StringIO() fig.savefig(buf, format="svg", bbox_inches="tight") s = buf.getvalue() SVGS[name] = s[s.index("= 20 else "black") ax.imshow(m, cmap="Blues", vmin=0, vmax=45) ax.set_xticks([0, 1]) ax.set_xticklabels(["summary right", "summary wrong"]) ax.set_yticks([0, 1]) ax.set_yticklabels(["proxy right", "proxy wrong"]) ax.set_title(f"{LAB.get(key, key)}: n = {c['n']}, McNemar exact p = {c['p_mcnemar']:.2g}", fontsize=9) fig.suptitle("Primary comparison (confirmation run): mnemonic-proxy vs summary, paired", fontsize=10) save(fig, "discordance_D_B") # HTML autonomo html = ["AgentLongBench confirmation run — mnemonic-proxy", "", "AgentLongBench confirmation run (window 32K, 64k + 128k)", "Qwen3.8 Flash Next IQ3_XXS on Strata 0.1.40, RTX 4070 Ti 12 GB, KV int8, seed 1. kf-c tool_response, " "Count Frequency + Find Duplicates, 25 + 25 questions per length, max_tokens 4,096. Full window = 81,920 / 163,840; " "mnemonic-proxy 0.3.5 (b8d4920), summary (LLM compaction, at most 2,048 tokens) and truncation at 32,768. " "Same questions as the main run plus one note that says which tool output \u201cround N\u201d refers to; " "official answers and scorer unchanged."] html.append("set" + "".join(f"{NAMES[p]}" for p in POLS) + "") for key in ["64k", "128k", "unite"]: html.append(f"{LAB.get(key, key)}" + "".join( f"{summ['correct']['off'][key][p][0]}/{summ['correct']['off'][key][p][1]}" for p in POLS) + "") html.append("") for name, cap in (("correct_by_policy", "Fully correct answers per method and length."), ("main_vs_confirm", "Main run vs confirmation run."), ("discordance_D_B", "Primary comparison: mnemonic-proxy vs summary, paired."), ("time_per_question", "Median time per question.")): html.append(f"{cap}") html.append(SVGS[name]) html.append("") (OUT / "confirm-charts.html").write_text("\n".join(html)) print("ok", sorted(p.name for p in OUT.iterdir()))
Qwen3.8 Flash Next IQ3_XXS on Strata 0.1.40, RTX 4070 Ti 12 GB, KV int8, seed 1. kf-c tool_response, " "Count Frequency + Find Duplicates, 25 + 25 questions per length, max_tokens 4,096. Full window = 81,920 / 163,840; " "mnemonic-proxy 0.3.5 (b8d4920), summary (LLM compaction, at most 2,048 tokens) and truncation at 32,768. " "Same questions as the main run plus one note that says which tool output \u201cround N\u201d refers to; " "official answers and scorer unchanged.