arithmetic-transitions · e33e5feeadcc
Browse filesFiles changed (8)
106 unmodified lines107108109110111112113114106 unmodified lines const vals=Object.entries(cal?.evaluations ?? {}).filter(([,v])=>v).map(([k,v])=>k+" "+v.correct+"/"+v.n); byId("learned").textContent=cal?.learning ? "Learning criterion "+(cal.learning.demonstrated?"met. ":"unmet. ")+vals.join(" · ") : vals.length ? "Fresh validation outcomes · "+vals.join(" · ") : "The positive-control test compares exact-reward training with the starting solver and shuffled rewards."; const arithmetic=cal?.learning?.by_parse?.base?.groups?.find(g=>g.stratum==="Both parsed"); if (arithmetic) byId("learned").textContent += " Among "+arithmetic.n+" already parseable pairs, training corrected "+arithmetic.gains+" arithmetic traces and broke "+arithmetic.losses+"."; byId("results").replaceChildren(); for (const r of study.runs) row(byId("results"),[r.name,r.role,r.updates,pct(r.dev),r.dev_n,pct(r.test),r.test_n]); const current=byId("run").value || study.runs.find(r=>r.name!=="base" && r.updates==null)?.name;21 unmodified lines2223242526272829303121 unmodified lines
On the confirmed family, separately replay matched correct and single-error solutions from sixteen problems through the frozen three-judge chain. Report each judge’s sensitivity and specificity, balanced accuracy, malformed reports and whole-evidence correctness. Run the evidence-altered Judge 2 twins with Judge 3. A learnable arithmetic population can still have an unreliable learned reward. Train and report matched recursive solvers under the selected configuration before drawing conclusions about depth. Preserve the harder original evaluation as a transfer target. The original and calibrated protocols have separate result paths.
### Distinguishing arithmetic gains from formatting gains
Before collecting calibration outcomes, we specified a descriptive decomposition of the same validation contrasts. For each pair of checkpoints classify each problem by whether both parses succeeded, only the trained solver parsed, only the comparator parsed, or neither parsed. Count complete-trace gains and losses within each class. A correction when both answers already parse is an arithmetic correction. Newly parseable and correct answers may improve both arithmetic and formatting, so their two contributions cannot be disentangled. These counts must reconcile to the paired gain across all problems. No stratum can change the registered learning decision. Report a matched example of each observed type of change in canonical-key order.
## Amended depth comparison after a demonstrated learning gain
Freeze the chosen arithmetic family and prompt style across every arm. Repeat the original run matrix with distinct calibrated checkpoint names, including a fresh D3 solver. Keep the timing-selected update count, within-seed prompt order, call budgets, stage order and three-seed decision rule. The calibrated primary uses the first 2,048 canonical problems from the reserved benchmark partition of the selected family. The next 128 distinct IDs serve the mechanism intervention. Apply the registered paired interval and three-point practical target to the calibrated D3-minus-D2 contrast. This is a new, conditional population and estimand.6 unmodified lines7891010111213143 unmodified lines1571581591601601611621621631641651661676 unmodified linesfrom .design import PILOTS, Runfrom .evaluate import mechanisms, weights_digestfrom .judging import chainfrom .learnability_analysis import cell_metrics, choose_cell, confirmed, learning_resultfrom .learnability_analysis import cell_metrics, changes_by_parse, choose_cell, confirmed, learning_resultfrom .records import expected, parse, render, solver_truth, sound, terminalfrom .storage import RESULTS, Journal, append, read_json, rows, stamp, write_json
143 unmodified lines
def compare(): where=directory()/"evaluations" samples=[{r["key"]:r["correct"] for r in rows(where/(name+".jsonl"))} samples=[{r["key"]:r for r in rows(where/(name+".jsonl"))} if (where/(name+".json")).is_file() else {} for name in ("base",*PILOTS)] result=learning_result(*samples) result=learning_result(*({key:r["correct"] for key,r in records.items()} for records in samples)) if result["status"]=="complete": base, trained, shuffled = samples result["by_parse"] = {"base":changes_by_parse(trained,base), "shuffled":changes_by_parse(trained,shuffled)} write_json(directory()/"learning.json",dict(time=stamp(),**result)) return result35 unmodified lines3637383940414243444546474849505152535455565758596061626335 unmodified lines fixed=int((d>0).sum()),harmed=int((d<0).sum()))
def changes_by_parse(after, before): """Partition the paired accuracy change; choose the first canonical example per kind.""" if before.keys() != after.keys(): raise ValueError("Parse transitions require identical problem IDs") labels = {(True,True):"Both parsed", (True,False):"Only trained parsed", (False,True):"Only comparator parsed", (False,False):"Neither parsed"} counts = {label:dict(stratum=label, n=0, gains=0, losses=0) for label in labels.values()} examples = {} for key in sorted(before): trained, comparator = after[key], before[key] label = labels[bool(trained["parsed"]), bool(comparator["parsed"])] counts[label]["n"] += 1 change = trained["correct"] - comparator["correct"] if change: direction = "gain" if change > 0 else "loss" counts[label]["gains" if change > 0 else "losses"] += 1 examples.setdefault((label,direction),dict(key=key, stratum=label, change=direction, expression=trained["expression"], expected=trained["expected_values"], comparator=comparator["trace"], trained=trained["trace"])) return dict(groups=list(counts.values()), examples=list(examples.values()))
def learning_result(base,exact,shuffled): if len(base)!=256 or base.keys()!=exact.keys() or base.keys()!=shuffled.keys(): return {"status":"pending"}123456721 unmodified lines293031323334353613 unmodified lines505152535455565758596061626364656667"""Summarize calibration cells and paired validation independently of the original benchmark."""
from html import escape
from .design import PILOTSfrom .storage import read_jsonfrom .tables import markdown, points, rate21 unmodified lines chosen=screen["selected"] out.append(f"The registered rule selected {chosen['family']} with {chosen['style']} prompts." if chosen else "No configuration qualified under the registered rule.") if chosen and chosen["family"]=="one": out.append("With one operation, final-answer accuracy and complete-trace accuracy coincide. The harder signed transfer cohort tests intermediate-step correctness.") if data["confirmation"]: c=data["confirmation"]["cell"] passed="passed" if data["confirmation"]["confirmed"] else "failed"13 unmodified lines if data["learning"]: result=data["learning"] out.append("The registered learning criterion was "+("met." if result["demonstrated"] else "unmet.")) out.append("The paired comparison also supports a reward-specific improvement." if result["reward_specific"] else "The evidence did not meet the registered criterion for a reward-specific improvement.") out.append(markdown(["Exact-trained minus","Gain (pp)","95% lower (pp)","95% upper (pp)","Fixed","Harmed"], [[label,points(r["delta"]),*(points(x) for x in r["interval"]),r["fixed"],r["harmed"]] for label,r in (("Frozen base",result["over_base"]),("Shuffled control",result["over_shuffled"]))])) for comparator, breakdown in result.get("by_parse", {}).items(): out.extend([f"### Formatting and arithmetic changes against {comparator}", markdown(["Parse status","Problems","Gained complete correctness","Lost complete correctness"], [[g["stratum"],g["n"],g["gains"],g["losses"]] for g in breakdown["groups"]])]) for ex in breakdown["examples"]: reference = ",".join(map(str,ex["expected"])) text = (f"Problem {ex['expression']}\nExpected {reference}\nComparator\n{ex['comparator']}" f"\nExact-trained\n{ex['trained']}") out.append(f"{ex['stratum']} · {ex['change']}\n\n<pre>{escape(text)}</pre>") return "\n\n".join(out)+"\n"58 unmodified lines5960616262636465666758 unmodified lines f"[Study, run matrix and evaluation]({GITHUB}). " f"[Raw data, logs and paper](https://huggingface.co/datasets/{DATA}). " f"[Load an adapter]({GITHUB}/blob/main/docs/usage.md#using-a-published-adapter).\n\n" +(ROOT/"reports/summary.md").read_text(encoding="utf-8").replace("(preregistration.md)",f"({GITHUB}/blob/main/reports/preregistration.md)")) +(ROOT/"reports/summary.md").read_text(encoding="utf-8") .replace("(preregistration.md)",f"({GITHUB}/blob/main/reports/preregistration.md)") .replace("(learnability.md)",f"({GITHUB}/blob/main/reports/learnability.md)")) api.upload_file(path_or_fileobj=card.encode(),path_in_repo="README.md",repo_id=MODELS, commit_message=f"Update study card at {release}") if run and (adapter(run)/"adapter_config.json").is_file() and milestone.endswith("-trained"):319 unmodified lines32032132232332432532632717 unmodified lines345346347348349350351352353354355106 unmodified lines4624634644654664674684694704714724734744754764774784794804814827 unmodified lines490491492471493494495496319 unmodified lines line(f"The amended primary population uses {config['family']} arithmetic with {config['style']} prompts for every arm. Learning was measured on a separate validation partition before this population was frozen. The primary comparison uses 2,048 new canonical problems. The following 128 form the evidence cohort. The original signed population is also evaluated for transfer.") if config["family"]=="registered": line("The signed-difficulty transfer and the amended primary coincide for this selection.") elif config["family"]=="one": line("The amended primary has one operation per problem, so its final answer is the complete trace. Multi-step evidence comes from the signed, layout and length transfer cohorts.") if data["original_development"]: table(["Original development","Correct complete trace","Problems"], [[r["name"],r["correct"],r["n"]] for r in data["original_development"]])17 unmodified lines if learning["learning"]: gain=learning["learning"]["over_base"] line(f"Exact-reward training changed held-out development accuracy by {100*gain['delta']:+.2f} percentage points relative to the starting solver. The paired 95% interval was [{100*gain['interval'][0]:+.2f}, {100*gain['interval'][1]:+.2f}] points. The full shuffled control is in the learnability report.") if "by_parse" in learning["learning"]: groups = learning["learning"]["by_parse"]["base"]["groups"] table(["Formatting on the same problem","Problems","Gains","Losses"], [[g["stratum"],g["n"],g["gains"],g["losses"]] for g in groups]) line("A gain when both responses already parse requires a corrected arithmetic trace. A gain in a newly parseable response can combine arithmetic and formatting changes.") primary = data["primary"] if "delta" in primary: line(f"The equally weighted paired difference is {primary['delta']*100:.2f} percentage points. The conditional 95% problem-bootstrap interval is [{primary['ci'][0]*100:.2f}, {primary['ci'][1]*100:.2f}] points. The registered decision is {primary['status']}.")106 unmodified lines if "delta" in primary: status += f" Difference {100*primary['delta']:.2f} percentage points, conditional 95% interval [{100*primary['ci'][0]:.2f}, {100*primary['ci'][1]:.2f}]." summary = status+"\n\n"+score learning = data["learnability"] if learning["screen"]: chosen = learning["screen"]["selected"] if chosen: summary += (f"\n\n**Benchmark difficulty.** The frozen-model screen selected {chosen['family']} with {chosen['style']} prompts. " f"On {chosen['problems']} screening problems it produced a mix of correct and incorrect answers on " f"{chosen['mixed_groups']} problems. [All difficulty levels](reports/learnability.md).") else: summary += "\n\n**Benchmark difficulty.** No setting passed the registered difficulty screen. [All difficulty levels](reports/learnability.md)." if learning["learning"]: change=learning["learning"]["over_base"] summary += (f"\n\n**Solver learning.** Exact-reward training changed complete-trace accuracy on {change['n']} fresh " f"problems by {100*change['delta']:+.1f} percentage points relative to the starting solver " f"(paired 95% interval {100*change['interval'][0]:+.1f} to {100*change['interval'][1]:+.1f}). " "[Shuffled control and arithmetic corrections](reports/learnability.md).") if data["original_development"]: summary += "\n\nOn the original signed development population, "+", ".join( f"{r['name']} solved {r['correct']}/{r['n']}" for r in data["original_development"])+"."7 unmodified lines if comparisons: summary += "\n\n" + markdown(["Contrast", "Seed", "Difference (pp)", "95% lower", "95% upper"], comparisons) explanation = "Solver scores require every intermediate value. Judge scores require all fields of the evidence record. Intervals condition on the trained checkpoints." atomic(REPORTS/"summary.md","# Study summary\n\n"+summary+"\n\n"+explanation+" [Preregistration](preregistration.md).\n") atomic(REPORTS/"summary.md","# Study summary\n\n"+summary.replace("(reports/learnability.md)","(learnability.md)")+"\n\n"+explanation+" [Preregistration](preregistration.md).\n") readme = (ROOT/"README.md").read_text(encoding="utf-8") pre, tail = readme.split("<!-- RESULTS:START -->",1) _, post = tail.split("<!-- RESULTS:END -->",1)53 unmodified lines5455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110253 unmodified lines assert learning_result(baseline,dict(list(perfect.items())[:-1]),baseline)["status"]=="pending"
def test_arithmetic_and_format_transitions_account_for_every_matched_gain(): from study.learnability_analysis import changes_by_parse
def row(parsed, correct): return dict(parsed=parsed, correct=correct, expression="2+3", trace="5" if correct else "wrong", expected_values=[5]) before=[row(1,0),row(1,1),row(0,0),row(1,1),row(0,0),row(0,0)] after =[row(1,1),row(1,0),row(1,1),row(0,0),row(0,0),row(1,1)] result = changes_by_parse(dict(enumerate(after)), dict(enumerate(before))) assert [(group["n"], group["gains"], group["losses"]) for group in result["groups"]] == [ (2,1,1), (2,2,0), (1,0,1), (1,0,0)] assert [(e["stratum"], e["change"], e["key"]) for e in result["examples"]] == [ ("Both parsed","gain",0),("Both parsed","loss",1),("Only trained parsed","gain",2), ("Only comparator parsed","loss",3)]
def test_learnability_report_regenerates_arithmetic_examples_from_validation_files(tmp_path,monkeypatch): import pytest learner=pytest.importorskip("study.learnability") from study.design import PILOTS from study.learnability_report import collect_learnability, learnability_text from study.storage import append, write_json
monkeypatch.setattr(learner,"RESULTS",tmp_path) root = tmp_path/"learnability" write_json(root/"screen.json", {"cells":[], "selected":{"family":"one","style":"demonstrated"}}) for name in ("base", *PILOTS): hits = 0 for i in range(256): correct = name == PILOTS[0] or i % 4 == 0 parsed = correct or i % 2 == 0 hits += correct append(root/"evaluations"/(name+".jsonl"), dict(key=str(i),correct=int(correct),parsed=parsed,trace="5" if correct else "6" if parsed else "<wrong>", expected_values=[5],expression="2+3")) write_json(root/"evaluations"/(name+".json"), {"n":256, "parsed":256 if name==PILOTS[0] else 128,"correct":hits}) outcome=learner.compare() assert outcome["reward_specific"] and outcome["over_base"]["fixed"]==192 assert sum(g["gains"] for g in outcome["by_parse"]["base"]["groups"])==192 text=learnability_text(collect_learnability(tmp_path)) assert "Both parsed | 128 | 64 | 0" in text and "<wrong>" in text
def test_frozen_screen_confirmation_and_resume_with_an_artificial_backend(tmp_path,monkeypatch): import pytest learner=pytest.importorskip("study.learnability")docs/explorer.js+2
reports/learnability-preregistration.md+4
src/study/learnability.py+5-3
src/study/learnability_analysis.py+22
src/study/learnability_report.py+15
src/study/publish.py+3-1
src/study/report.py+23-1
tests/test_learnability.py+43