Upload code/make_report.py with huggingface_hub
Browse files- code/make_report.py +102 -22
code/make_report.py
CHANGED
|
@@ -134,9 +134,25 @@ if set1:
|
|
| 134 |
f"{np.mean([r['rungs']['M0_naive_avg']['mb_eng'] for r in _mb]):.2f} on "
|
| 135 |
f"MultiBLiMP-English (parent {_mb[0]['parents']['eng_on_mb_eng']:.2f}, chance 0.50). "
|
| 136 |
f"Δfloor and benchmark accuracy dissociate in **both** directions; neither implies the other.")
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
if _rp:
|
| 141 |
hl.append("8. **This is not an under-trying artifact.** REPAIR-style statistics correction on "
|
| 142 |
"top of the alignment — the strongest training-free merge here — improves the "
|
|
@@ -508,6 +524,37 @@ follow that the English-anchored direction alone could not support:
|
|
| 508 |
""")
|
| 509 |
|
| 510 |
L.append("\n## P0-2 · Do the pre-merge predictors predict the realised rescue?\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
if os.path.exists(f"{R}/predictor_auroc.csv"):
|
| 512 |
rows = [l.rstrip("\n").split(",") for l in open(f"{R}/predictor_auroc.csv")]
|
| 513 |
hdr, dat = rows[0], rows[1:]
|
|
@@ -562,27 +609,60 @@ if os.path.exists(f"{R}/set4_predictors.csv"):
|
|
| 562 |
for d in dat]))
|
| 563 |
|
| 564 |
# coverage
|
| 565 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 566 |
### What P0-2 comes to
|
| 567 |
|
| 568 |
-
**
|
| 569 |
-
|
| 570 |
-
(
|
| 571 |
-
|
| 572 |
-
|
| 573 |
-
|
| 574 |
-
|
| 575 |
-
|
| 576 |
-
**
|
| 577 |
-
|
| 578 |
-
|
| 579 |
-
instrument
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 586 |
""")
|
| 587 |
|
| 588 |
abl = load("abl_*.jsonl")
|
|
|
|
| 134 |
f"{np.mean([r['rungs']['M0_naive_avg']['mb_eng'] for r in _mb]):.2f} on "
|
| 135 |
f"MultiBLiMP-English (parent {_mb[0]['parents']['eng_on_mb_eng']:.2f}, chance 0.50). "
|
| 136 |
f"Δfloor and benchmark accuracy dissociate in **both** directions; neither implies the other.")
|
| 137 |
+
_cf = []
|
| 138 |
+
if os.path.exists(f"{R}/predictor_confirmatory.csv"):
|
| 139 |
+
_rw = [l.rstrip("\n").split(",") for l in open(f"{R}/predictor_confirmatory.csv")]
|
| 140 |
+
_ii = {h: i for i, h in enumerate(_rw[0])}
|
| 141 |
+
for d in _rw[1:]:
|
| 142 |
+
try: _cf.append((d[_ii["substrate"]], d[_ii["predictor"]],
|
| 143 |
+
float(d[_ii["auroc_heldout_by_seed"]]),
|
| 144 |
+
float(d[_ii["bh_q_within_confirmatory_family"]] or "nan")))
|
| 145 |
+
except Exception: pass
|
| 146 |
+
_sg = [c for c in _cf if c[3] == c[3] and c[3] < 0.05]
|
| 147 |
+
_tt = [c for c in _cf if c[3] == c[3]]
|
| 148 |
+
hl.append(f"7. **P0-2: the pre-merge predictors do not reliably predict the realised rescue.** "
|
| 149 |
+
f"Held out by seed pair, with a seed-cluster permutation null and BH within the "
|
| 150 |
+
f"five-predictor family the audit brief itself names: **{len(_sg)} of {len(_tt)} cells "
|
| 151 |
+
f"significant**"
|
| 152 |
+
+ (" (" + "; ".join(f"{c[0]}, {c[1]}, AUROC {c[2]:.2f}, q={c[3]:.3f}" for c in _sg) + ")" if _sg else "")
|
| 153 |
+
+ ". It does not replicate across substrates — the same predictor sits below 0.5 at the "
|
| 154 |
+
"largest size — and nothing survives BH across the wider exploratory family. Reported "
|
| 155 |
+
"as the negative transfer result it is.")
|
| 156 |
if _rp:
|
| 157 |
hl.append("8. **This is not an under-trying artifact.** REPAIR-style statistics correction on "
|
| 158 |
"top of the alignment — the strongest training-free merge here — improves the "
|
|
|
|
| 524 |
""")
|
| 525 |
|
| 526 |
L.append("\n## P0-2 · Do the pre-merge predictors predict the realised rescue?\n")
|
| 527 |
+
if os.path.exists(f"{R}/predictor_confirmatory.csv"):
|
| 528 |
+
rows = [l.rstrip("\n").split(",") for l in open(f"{R}/predictor_confirmatory.csv")]
|
| 529 |
+
hdr, dat = rows[0], rows[1:]
|
| 530 |
+
ix = {h: i for i, h in enumerate(hdr)}
|
| 531 |
+
L.append("""### The confirmatory test
|
| 532 |
+
|
| 533 |
+
Outcome = **realised rescue**: the fraction of the naive merge's Δfloor that the best M1 rung removes.
|
| 534 |
+
Label = above the within-substrate median. **Held out by seed**: fold *k* is every pair touching seed
|
| 535 |
+
*k*, fitted on the pairs touching neither, so the predictor's direction never sees the held-out pairs.
|
| 536 |
+
Null = a **seed-cluster permutation** (2000 draws): permute the seed identities and re-map each pair's
|
| 537 |
+
outcome to the permuted pair, leaving the predictor vector untouched. That preserves the pair
|
| 538 |
+
dependence structure a plain label shuffle destroys, and it is why the null means below sit at 0.50
|
| 539 |
+
rather than drifting.
|
| 540 |
+
|
| 541 |
+
The family below is the five predictors **the audit brief itself names** — weight cosine, coordinate
|
| 542 |
+
share, QMD, CKA, task-vector cosine — on the one outcome it asks about. It was fixed from the brief,
|
| 543 |
+
not selected after looking at the results, and BH is applied within this family only. The larger
|
| 544 |
+
exploratory table follows it.
|
| 545 |
+
|
| 546 |
+
""")
|
| 547 |
+
L.append(md_table(["substrate", "predictor", "n", "Spearman", "AUROC (held out by seed)",
|
| 548 |
+
"null mean", "perm p", "BH q (within family)"],
|
| 549 |
+
[[d[ix["substrate"]], d[ix["predictor"]], d[ix["n_pairs"]],
|
| 550 |
+
fmt(float(d[ix["spearman"]]) if d[ix["spearman"]] else None),
|
| 551 |
+
fmt(float(d[ix["auroc_heldout_by_seed"]]) if d[ix["auroc_heldout_by_seed"]] else None),
|
| 552 |
+
fmt(float(d[ix["perm_null_mean"]]) if d[ix["perm_null_mean"]] else None),
|
| 553 |
+
fmt(float(d[ix["perm_p"]]) if d[ix["perm_p"]] else None),
|
| 554 |
+
fmt(float(d[ix["bh_q_within_confirmatory_family"]]) if d[ix["bh_q_within_confirmatory_family"]] else None)]
|
| 555 |
+
for d in dat]))
|
| 556 |
+
L.append("\n### The exploratory table\n")
|
| 557 |
+
|
| 558 |
if os.path.exists(f"{R}/predictor_auroc.csv"):
|
| 559 |
rows = [l.rstrip("\n").split(",") for l in open(f"{R}/predictor_auroc.csv")]
|
| 560 |
hdr, dat = rows[0], rows[1:]
|
|
|
|
| 609 |
for d in dat]))
|
| 610 |
|
| 611 |
# coverage
|
| 612 |
+
_conf = []
|
| 613 |
+
if os.path.exists(f"{R}/predictor_confirmatory.csv"):
|
| 614 |
+
_rows = [l.rstrip("\n").split(",") for l in open(f"{R}/predictor_confirmatory.csv")]
|
| 615 |
+
_ix = {h: i for i, h in enumerate(_rows[0])}
|
| 616 |
+
for d in _rows[1:]:
|
| 617 |
+
try:
|
| 618 |
+
_conf.append({"sub": d[_ix["substrate"]], "pred": d[_ix["predictor"]],
|
| 619 |
+
"auroc": float(d[_ix["auroc_heldout_by_seed"]]),
|
| 620 |
+
"q": float(d[_ix["bh_q_within_confirmatory_family"]] or "nan")})
|
| 621 |
+
except Exception:
|
| 622 |
+
pass
|
| 623 |
+
_sig = [c for c in _conf if c["q"] == c["q"] and c["q"] < 0.05]
|
| 624 |
+
_tested = [c for c in _conf if c["q"] == c["q"]]
|
| 625 |
+
L.append(f"""
|
| 626 |
### What P0-2 comes to
|
| 627 |
|
| 628 |
+
**The confirmatory family gives {len(_sig)} significant cell{'' if len(_sig) == 1 else 's'} out of
|
| 629 |
+
{len(_tested)} tested** (BH q < 0.05 within the family){':' if _sig else '.'}
|
| 630 |
+
""" + ("".join(f"\n- {c['sub']} · {c['pred']} · AUROC {c['auroc']:.3f} · q = {c['q']:.3f}" for c in _sig) if _sig else "") + """
|
| 631 |
+
|
| 632 |
+
That is a real effect and it should not be rounded down to zero. It should also not be rounded up.
|
| 633 |
+
The predictor that carries it is the **coordinate share** — exactly the quantity the manuscript's
|
| 634 |
+
thesis is about — and the honest summary is:
|
| 635 |
+
|
| 636 |
+
- **It does not replicate across substrates.** The same predictor's held-out AUROC across the sizes
|
| 637 |
+
we ran is not stable, and at the largest size it sits *below* 0.5, i.e. pointing the wrong way. A
|
| 638 |
+
quantity that predicts the rescue on one substrate and anti-predicts it on another is not a
|
| 639 |
+
validated instrument for "representational alignment predicts merging".
|
| 640 |
+
- **The exploratory table looks better than the confirmatory one, and that is the point of having
|
| 641 |
+
both.** Across ~150 predictor × substrate × outcome cells there are plenty of AUROCs in the
|
| 642 |
+
0.70–0.81 range with raw permutation p below 0.05; none survives BH across that family. Quoting
|
| 643 |
+
the best of them would be exactly the error the audit exists to catch.
|
| 644 |
+
- **Across-substrate transfer is likewise partial.** Fitting on the other sizes and testing on a
|
| 645 |
+
held-out one, the coordinate share transfers to some substrates and not to others (table above).
|
| 646 |
+
|
| 647 |
+
One thing worth noticing before concluding, because it is partly a power story rather than a signal
|
| 648 |
+
story: **detectability tracks how much the outcome varies at all.** The within-substrate standard
|
| 649 |
+
deviation of the realised rescue is 0.067 at 14m, 0.143 at 31m, 0.127 at 70m and 0.095 at 160m
|
| 650 |
+
(against a between-substrate spread of 0.143 in the means). 14m — where the rescue is both largest
|
| 651 |
+
and most uniform across pairs — is the substrate where nothing predicts, and 70m, with roughly twice
|
| 652 |
+
the spread, is where the one significant cell appears. So part of the null is that at some sizes
|
| 653 |
+
every pair is rescued by nearly the same amount and there is very little left to rank. That is a
|
| 654 |
+
caveat in the predictors' favour and it does not rescue the positive claim: a predictor that only
|
| 655 |
+
resolves when the outcome happens to be dispersed is not the instrument the thesis needs.
|
| 656 |
+
|
| 657 |
+
Against them: the seed-cluster null is
|
| 658 |
+
conservative by construction, but so is the design that needs it; these are 36 pairs built from 9
|
| 659 |
+
seeds, not 36 independent observations, and any analysis that treats them as independent will
|
| 660 |
+
overstate its significance.
|
| 661 |
+
|
| 662 |
+
**Verdict, stated as the audit asks.** On real reseeded LMs, the pre-merge alignment predictors do
|
| 663 |
+
not reliably predict how much of the merge obstruction alignment will actually remove. The one
|
| 664 |
+
substrate where the coordinate share does predict it does not generalise to the others. This is a
|
| 665 |
+
negative transfer result from the synthetic/S3 setting to real models, and it is reported as one.
|
| 666 |
""")
|
| 667 |
|
| 668 |
abl = load("abl_*.jsonl")
|