"""Experiment SR1-H06 (amendment 3.3 D6): the value of the released base weights by the amount of KOHTD training data. Descriptive only. Falsifying experiment as written in records/R4/SR1_stages/hypotheses.jsonl: medium recognizer, base against scratch, at 10 % and 100 % of the KOHTD train forms, one seed, 5 % of the planned passes each, KOHTD validation only. The prediction (base more than 10 % relative better at 10 % of the data, less than 5 % better at 100 %) is falsified if the base start is still more than 10 % better at 100 %. Choices made here (stated, not from the file): "5 % of the planned passes" is read as P_short = 150,016 samples per run, because P_short is 5 % of the 3,000,000 line-passes of the version-3 design and the same size as the learning-rate probe; "base" is A1 (kraken medium weights), "scratch" is A1s (same architecture, random start); same recipe as A1 and A1s of the main runs (batch 32, lr 5e-4, 3 % warm-up, cosine), same union codec; the 10 % subset is 10 % of the KOHTD train forms (seed 20261121, whole forms); data = KOHTD train crops only; scored on V1 and kohtd_val. prep: python -m linedet.h06 prep writes the 10 % manifest and the two mix yaml files report: python -m linedet.h06 report reads the four prediction metas and writes h06_result.json """ import csv import json import os import sys import numpy as np from .common import DATA, LD_OUT, load_json, read_manifest, save_json, utcnow, write_tsv MAN = DATA + "/data/processed/r5/manifests/kohtd_train.tsv" H = LD_OUT + "/h06" PRED = H + "/preds" RUNS = {"base10": "A1", "base100": "A1", "scratch10": "A1s", "scratch100": "A1s"} def prep(manifest=MAN, out=H): rows = read_manifest(manifest) groups = sorted({r["group"] for r in rows}) rng = np.random.default_rng(20261121) n10 = max(1, int(round(0.1 * len(groups)))) pick = set(np.array(groups)[rng.permutation(len(groups))[:n10]].tolist()) sub = [r for r in rows if r["group"] in pick] hdr = list(rows[0].keys()) write_tsv(out + "/kohtd_train_10pct.tsv", hdr, [[r[h] for h in hdr] for r in sub]) for nm, man in (("h06_10", out + "/kohtd_train_10pct.tsv"), ("h06_100", manifest)): with open("%s/%s.yaml" % (out, nm), "w") as f: f.write("components:\n - name: %s\n manifest: %s\n share: 1.0\n" % (nm, man)) info = {"created": utcnow(), "source": manifest, "forms_total": len(groups), "forms_10pct": n10, "crops_total": len(rows), "crops_10pct": len(sub), "seed": 20261121, "form_ids_10pct_sha": __import__("hashlib").sha256(",".join(sorted(pick)).encode()).hexdigest()} save_json(out + "/h06_prep.json", info) print(info) def report(): res = {"created": utcnow(), "experiment": "SR1-H06", "runs": {}, "note": "descriptive; one seed; P_short samples per run; validation only"} for nm, arm in RUNS.items(): p = "%s/h06_%s/short/meta.json" % (PRED, nm) if not os.path.exists(p): res["runs"][nm] = {"missing": p} continue m = load_json(p) res["runs"][nm] = {"arm": arm, "samples_seen": m["samples_seen"], "cer": {k: v.get("cer") for k, v in m["per_set"].items()}} for s in ("V1", "kohtd_val"): row = {} for pct in ("10", "100"): b = res["runs"].get("base" + pct, {}).get("cer", {}).get(s) c = res["runs"].get("scratch" + pct, {}).get("cer", {}).get(s) if b is not None and c is not None and c > 0: row["relative_advantage_of_base_at_%spct" % pct] = (c - b) / c row["cer_base_%spct" % pct] = b row["cer_scratch_%spct" % pct] = c if "relative_advantage_of_base_at_100pct" in row: row["prediction_falsified_(base_still_more_than_10pct_better_at_100pct)"] = row["relative_advantage_of_base_at_100pct"] > 0.10 res["on_" + s] = row save_json(LD_OUT + "/h06_result.json", res) print(json.dumps(res, indent=1)) try: # clarification H9: gated LM predictions (file work only) from .lm_gate import gate_all print("lm_gate:", gate_all()) except Exception as e: print("lm_gate hook failed:", repr(e)[:200]) if __name__ == "__main__": {"prep": prep, "report": report}[sys.argv[1]]()