Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions docs/v2/G5_PREREG_EVAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,42 @@
Status: DRAFT preregistration. Freeze (hash this file + test manifest) **before** any training run. SHADOW-only.

## Hypotheses
- H1 (T1): LoRA-tuned Nano 8B beats BASE on T1 sense accuracy on the hashed grouped test split. Exact McNemar, two-sided, alpha=0.05.
- H2 (T1): LoRA beats bag-of-terms (logistic regression on term+context unigrams) and the rule baseline (`observation_sense_v1`). Exact McNemar each, Holm correction across the 3 comparisons.
- H1 (T1): LoRA-tuned Nano 8B beats BASE on T1 sense accuracy on the hashed grouped test split. Term-level paired bootstrap (resample test **terms** with replacement, all of a term's rows together; 10k resamples, seed 7); two-sided 95% CI on the accuracy difference, reject H0 if the CI excludes 0 (alpha=0.05).
- H2 (T1): LoRA beats bag-of-terms (logistic regression on term+context unigrams) and the rule baseline (`observation_sense_v1`). Same term-level paired bootstrap each, Holm correction across the 3 comparisons.
- Why term-level, not row-level McNemar: test rows are clustered within ~37 terms (cap 10 gold/term), so rows are not independent; row-level McNemar overstates n. Resampling terms respects the grouping (Søgaard et al., EACL 2021, doi:10.18653/v1/2021.eacl-main.156; lexical memorization, Levy et al., NAACL 2015, doi:10.3115/v1/n15-1098). Row-level McNemar b/c counts stay reported as descriptive only.
- H3 (T3): macro-F1 on **unseen families** > 0.0725 (v1 holdout). Reported with bootstrap 95% CI (10k resamples, seed 7). Exploratory unless >= 8 families populated.

## Fixed design
- Test set: human-ruled gold rows with `split == test` from `slang.split.v1` (group split on `term_family`). Minimum 250 rows / 150 terms (G1). Manifest = sorted record_ids, SHA-256 recorded here at freeze.
- Test set: human-ruled gold rows with `split == test` from `slang.split.v1` (group split on `term_family`). Minimum 250 human-ruled rows covering **all test-lineage terms that have posts** (37 on 2026-10-16) (G1). The 150-term floor applies to the train pool / overall gold (G2/G3), not the test split: the hashed 10% test bucket holds only 40 terms (37 with posts), so 150 test terms is unreachable without breaking the group split. Per Danny 2026-10-16 approval of recommendation. Supporting refs: Levy et al. 2015 (doi:10.3115/v1/n15-1098), Søgaard et al. 2021 (doi:10.18653/v1/2021.eacl-main.156), Blevins & Zettlemoyer ACL 2020 (doi:10.18653/v1/2020.acl-main.95, rare-sense evaluation), Bandel et al. 2022 (arXiv:2210.12673, lexical-overlap generalization). Manifest = sorted record_ids, SHA-256 recorded here at freeze.
- Inputs: raw context + term only (no oracle slot). Reasoning off. Greedy decoding, max 8 tokens for labels.
- One training config (no sweeps): LoRA r=16, alpha=32, dropout 0.05, all linear layers, lr 2e-4 cosine, 3 epochs, seq 512, seed 7.
- Exclusions decided in advance: UNSURE and REJECT rulings excluded; rows failing G4 audit excluded from train only (never from test).
- No peeking: test labels are loaded only by `scripts/v2/prereg_eval.py --final`, run once; any rerun is reported.

## Reporting
Accuracy, macro-F1, McNemar b/c counts and exact p, per-family table, none-rate (v1 failure mode: 467/470 none). Negative results are published to the tracker as-is.
Accuracy, macro-F1, term-level bootstrap CIs (primary), McNemar b/c counts (descriptive), per-family table, none-rate (v1 failure mode: 467/470 none). Negative results are published to the tracker as-is.

## Compute / cost estimate (ASSUMPTION-labelled)
| Step | DGX Spark / Morpheus | Paid alternative |
| --- | --- | --- |
| LoRA SFT, ~1.5k rows x 3 epochs, 8B BF16 | ~1–2 h on one Spark, $0 marginal | GPU rental ~1x H100 1 h ~ $2–4 (UNVERIFIED) |
| Inference: 4 systems x ~470 test rows | <15 min | OpenRouter BASE only (tuned LoRA cannot run there): <$0.10 |
| Bootstrap/McNemar | CPU, seconds | — |
| Term-level bootstrap | CPU, seconds | — |

Recommendation: all G5 compute on Spark/Morpheus; paid path only for BASE cross-check, with cost shown first.


## Change log
- 2026-10-16: test floor redefined (250 rows covering all test terms with posts; 150 terms moved to train pool/overall gold) and row-level McNemar replaced by term-level bootstrap. Per Danny 2026-10-16 approval of recommendation. Supersedes the 2026-10 draft wording (history kept in git).

## Freeze record (2026-10-16, per Danny go 3:55 PM PT)

- Test manifest: 273 record_ids (sorted), SHA-256 `a03c8619ba91a0f3d3edb43a358adbb5a6fcc83fe462442b6cb66e94be8296b6`. Verified unchanged after the 2026-10-16 attestation load.
- Preregistration text above (this file before this section): SHA-256 `1954a35a5bba8586489c07bf5300f28da26a20e9160e6ed693926c13613e2cbe`.
- gold_test.jsonl SHA-256 prefix `06caba1397df`. 15 quarantined gold rows (suspect synthetic source id) are excluded from test and stay quarantined.
- Tag: `v2-test-freeze-2026-10-16`. Read-only copy kept in the private tracker. Any change to the manifest after this point voids the freeze.

### Freeze addendum (2026-10-16 4:20 PM PT, Danny 4:03 PM PT family ruling)
- Manifest unchanged: a03c8619… (273 ids). Gold labels unchanged.
- gold_test.jsonl family metadata updated on 17 rows (three family calls), new SHA-256 prefix `818ba1288dea`. Family-level (H3) analysis uses the updated families. One private family is excluded from H3 unseen-family claims, and the family gate is reported as 16.
- Six test-split rulings made after the freeze are held outside gold_test, for a future test version only.
27 changes: 24 additions & 3 deletions scripts/v2/prereg_eval.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env python3
"""G5 preregistered eval (draft): exact McNemar + bootstrap macro-F1. Inputs are private prediction
"""G5 preregistered eval (draft): term-level paired bootstrap (primary, per G5_PREREG_EVAL.md 2026-10-16) +
exact McNemar (descriptive) + bootstrap macro-F1. Inputs are private prediction
JSONL files keyed by record_id ({"record_id","pred"}) plus a gold JSONL ({"record_id","gold","family"})."""
import argparse, json, random
from math import comb
Expand Down Expand Up @@ -32,6 +33,25 @@ def holm(pvals):
return out


def term_bootstrap(ids, gold, tuned, base, n=10000, seed=7, key="family"):
"""Resample test terms (clusters) with replacement; all rows of a term move together.
Returns accuracy diff (tuned - base), 95% CI, two-sided bootstrap p, number of clusters."""
clusters = {}
for i in ids:
clusters.setdefault(gold[i].get(key) or i, []).append(i)
names = sorted(clusters)
stats = {c: (sum(tuned[i]["pred"] == gold[i]["gold"] for i in clusters[c]),
sum(base[i]["pred"] == gold[i]["gold"] for i in clusters[c]), len(clusters[c])) for c in names}
def diff(sample):
t = sum(stats[c][0] for c in sample); b = sum(stats[c][1] for c in sample); m = sum(stats[c][2] for c in sample)
return (t - b) / m if m else 0.0
obs = diff(names); rng = random.Random(seed)
boots = sorted(diff([rng.choice(names) for _ in names]) for _ in range(n))
lo, hi = boots[int(0.025 * n)], boots[int(0.975 * n) - 1]
p = min(1.0, 2 * min(sum(d <= 0 for d in boots), sum(d >= 0 for d in boots)) / n)
return {"acc_diff": obs, "ci95": [lo, hi], "p_boot": p, "n_terms": len(names)}


def load(p):
return {r["record_id"]: r for r in (json.loads(l) for l in open(p) if l.strip())}

Expand All @@ -52,8 +72,9 @@ def main():
name, path = spec.split("=", 1); base = load(path)
b = sum(1 for i in ids if tuned[i]["pred"] == gold[i]["gold"] and base[i]["pred"] != gold[i]["gold"])
c = sum(1 for i in ids if tuned[i]["pred"] != gold[i]["gold"] and base[i]["pred"] == gold[i]["gold"])
rep[name] = {"b": b, "c": c, "p_exact": mcnemar_exact(b, c)}
adj = holm({k: v["p_exact"] for k, v in rep.items() if isinstance(v, dict)})
rep[name] = {"term_bootstrap": term_bootstrap(ids, gold, tuned, base),
"mcnemar_descriptive": {"b": b, "c": c, "p_exact": mcnemar_exact(b, c)}}
adj = holm({k: v["term_bootstrap"]["p_boot"] for k, v in rep.items() if isinstance(v, dict)})
for k, p in adj.items():
rep[k]["p_holm"] = p; rep[k]["significant_0.05"] = p < 0.05
pairs = [(gold[i]["gold"], tuned[i]["pred"]) for i in ids]
Expand Down
Loading