Upload code/make_report.py with huggingface_hub
Browse files- code/make_report.py +114 -40
code/make_report.py
CHANGED
|
@@ -69,17 +69,19 @@ L.append("""## Read this first: what substrate, and what metric
|
|
| 69 |
|
| 70 |
| | SET 1 | SET 4 |
|
| 71 |
|---|---|---|
|
| 72 |
-
| **Substrate** | `EleutherAI/pythia-{14m,70m,160m}-seed{1..9}` (PolyPythia) — real reseeded LMs | `goldfish-models/eng_latn_1000mb` × `{nld,spa,ell,pol}_*_1000mb` — the real bilingual-composition models, GPT-2 arch, 125M |
|
| 73 |
| **What varies between the two parents** | the init/data-order **seed only**. Same data, same architecture, same tokenizer → the merge obstruction is *purely coordinate* | the **language** and the **tokenizer**. Independently initialised, independently trained |
|
| 74 |
| **Held-out corpus** | FLORES-200 devtest `eng_Latn` | FLORES-200 devtest, `eng_Latn` + the partner language |
|
| 75 |
-
| **Metric** | Δfloor in **nats/token** vs the better parent | Δfloor in **nats per UTF-8 byte** vs the better parent (bytes, because the two parents use different tokenizers and nats/token is not comparable across them) |
|
| 76 |
-
| **What the metric is** | a **likelihood** metric | a **likelihood** metric |
|
| 77 |
-
|
| 78 |
-
> **Δfloor is a likelihood metric, not benchmark accuracy
|
| 79 |
-
>
|
| 80 |
-
>
|
| 81 |
-
>
|
| 82 |
-
>
|
|
|
|
|
|
|
| 83 |
""")
|
| 84 |
|
| 85 |
# ---------------- headline summary (computed, so it cannot drift from the tables)
|
|
@@ -270,9 +272,17 @@ if set4:
|
|
| 270 |
L.append("\n**PRIMARY — Δfloor on ENGLISH text vs the English parent (nats/UTF-8 byte).** This "
|
| 271 |
"cell has no tokenizer artifact: the merge is asked only to retain what the English "
|
| 272 |
"parent already had.\n")
|
| 273 |
-
|
| 274 |
-
|
| 275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
L.append("\n**Δfloor vs the better parent, mean over the two languages, nats/UTF-8 byte** "
|
| 277 |
"(lower is better; 0 would mean the merge matches the better parent):\n")
|
| 278 |
L.append(md_table(hdr, body))
|
|
@@ -443,6 +453,31 @@ if mb:
|
|
| 443 |
accuracy standing. Whichever of the two you report, the other does not follow from it.
|
| 444 |
""")
|
| 445 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 446 |
rev = load("set4_reverse.jsonl")
|
| 447 |
if rev:
|
| 448 |
L.append("\n## SET 4 · reverse direction (the partner language is the anchor)\n")
|
|
@@ -575,23 +610,43 @@ init-plus-data-order number, not an init-only one.
|
|
| 575 |
|
| 576 |
L.append("\n## Coverage — what ran and what did not\n")
|
| 577 |
cov = []
|
| 578 |
-
for sz in ["14m", "70m", "160m"]:
|
| 579 |
n = len([r for r in set1 if r["size"] == sz])
|
| 580 |
-
|
| 581 |
-
|
| 582 |
-
|
| 583 |
-
|
| 584 |
-
|
| 585 |
-
|
| 586 |
-
|
| 587 |
-
|
| 588 |
-
|
|
|
|
|
|
|
| 589 |
"RAN" if blimp else "**NOT RUN**",
|
| 590 |
-
"67 paradigms from `nyu-mll/blimp`, minimal-pair sentence-logprob scoring, on the SAME merges
|
| 591 |
-
|
| 592 |
-
|
| 593 |
-
cov.append(["
|
| 594 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 595 |
L.append(md_table(["cell", "n", "status", "what was measured"], cov))
|
| 596 |
|
| 597 |
L.append("""
|
|
@@ -614,23 +669,42 @@ L.append("""
|
|
| 614 |
|
| 615 |
L.append("\n## Files\n")
|
| 616 |
L.append("""```
|
| 617 |
-
results/set1_{14m,70m,160m}.jsonl
|
| 618 |
-
results/set1_pairs.csv
|
| 619 |
-
results/
|
| 620 |
-
results/
|
| 621 |
-
results/
|
| 622 |
-
results/
|
| 623 |
-
results/
|
| 624 |
-
|
| 625 |
-
|
| 626 |
-
|
| 627 |
-
|
| 628 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 629 |
|
| 630 |
open("/root/compose-audit/RESULTS_COMPOSE_AUDIT.md", "w").write("\n".join(L) + "\n")
|
| 631 |
|
| 632 |
if rung_rows:
|
| 633 |
-
keys =
|
|
|
|
|
|
|
|
|
|
| 634 |
with open(f"{R}/rung_summary.csv", "w") as f:
|
| 635 |
f.write(",".join(keys) + "\n")
|
| 636 |
for r in rung_rows:
|
|
|
|
| 69 |
|
| 70 |
| | SET 1 | SET 4 |
|
| 71 |
|---|---|---|
|
| 72 |
+
| **Substrate** | `EleutherAI/pythia-{14m,31m,70m,160m,410m}-seed{1..9}` (PolyPythia) — real reseeded LMs | `goldfish-models/eng_latn_1000mb` × `{nld,spa,ell,pol}_*_1000mb` — the real bilingual-composition models, GPT-2 arch, 125M |
|
| 73 |
| **What varies between the two parents** | the init/data-order **seed only**. Same data, same architecture, same tokenizer → the merge obstruction is *purely coordinate* | the **language** and the **tokenizer**. Independently initialised, independently trained |
|
| 74 |
| **Held-out corpus** | FLORES-200 devtest `eng_Latn` | FLORES-200 devtest, `eng_Latn` + the partner language |
|
| 75 |
+
| **Metric** | Δfloor in **nats/token** vs the better parent; **BLiMP accuracy** on the same merges | Δfloor in **nats per UTF-8 byte** vs the better parent (bytes, because the two parents use different tokenizers and nats/token is not comparable across them); **MultiBLiMP 1.0 accuracy** on the same merges |
|
| 76 |
+
| **What the metric is** | Δfloor is a **likelihood** metric; BLiMP is an **accuracy** metric | Δfloor is a **likelihood** metric; MultiBLiMP is an **accuracy** metric |
|
| 77 |
+
|
| 78 |
+
> **Δfloor is a likelihood metric, not benchmark accuracy — and here they come apart.** The audit's
|
| 79 |
+
> sharpest point is that a likelihood rescue has not been shown to transfer to accuracy. We tested
|
| 80 |
+
> that transfer directly, on the same merges, with BLiMP (SET 1) and MultiBLiMP 1.0 (SET 4), and it
|
| 81 |
+
> **does not hold in either direction**: in SET 1 a ~70% Δfloor rescue buys ~0.03 BLiMP accuracy over
|
| 82 |
+
> the naive merge, and in SET 4 a merge whose Δfloor says it is destroyed still scores 0.68 on
|
| 83 |
+
> MultiBLiMP-English. Neither metric may be reported as a proxy for the other. Every table below
|
| 84 |
+
> states which one it is.
|
| 85 |
""")
|
| 86 |
|
| 87 |
# ---------------- headline summary (computed, so it cannot drift from the tables)
|
|
|
|
| 272 |
L.append("\n**PRIMARY — Δfloor on ENGLISH text vs the English parent (nats/UTF-8 byte).** This "
|
| 273 |
"cell has no tokenizer artifact: the merge is asked only to retain what the English "
|
| 274 |
"parent already had.\n")
|
| 275 |
+
_b = [[f"eng–{r['lang']}"] + [fmt(r["rungs"][k]["delta_floor_eng"]) for k in rung_keys] for r in set4]
|
| 276 |
+
_b.append(["**mean of the 4**"] + ["**" + fmt(float(np.mean([r["rungs"][k]["delta_floor_eng"] for r in set4]))) + "**"
|
| 277 |
+
for k in rung_keys])
|
| 278 |
+
L.append(md_table(["pair"] + rung_keys, _b))
|
| 279 |
+
L.append("\nAveraged over the four pairs the best M1 rung removes **"
|
| 280 |
+
+ fmt(100 * (1 - min(np.mean([r["rungs"][k]["delta_floor_mean"] for r in set4]) for k in rung_keys if k.startswith("M1"))
|
| 281 |
+
/ np.mean([r["rungs"]["M0_naive_avg"]["delta_floor_mean"] for r in set4])), 1)
|
| 282 |
+
+ "%** of the naive merge's Δfloor. For contrast, on SET 1 — where the two parents share "
|
| 283 |
+
"data, architecture and tokenizer and differ only in seed — the same family of aligners "
|
| 284 |
+
"removes 70% at 14M. The Goldfish obstruction is not the kind of obstruction alignment "
|
| 285 |
+
"addresses.\n")
|
| 286 |
L.append("\n**Δfloor vs the better parent, mean over the two languages, nats/UTF-8 byte** "
|
| 287 |
"(lower is better; 0 would mean the merge matches the better parent):\n")
|
| 288 |
L.append(md_table(hdr, body))
|
|
|
|
| 453 |
accuracy standing. Whichever of the two you report, the other does not follow from it.
|
| 454 |
""")
|
| 455 |
|
| 456 |
+
bgc = load("bgpt_ceiling.jsonl")
|
| 457 |
+
if bgc:
|
| 458 |
+
L.append("\n## SET 4 · what would SUCCESS look like? The jointly-trained bilingual ceiling\n")
|
| 459 |
+
L.append("A merge that fails is only interpretable against what a bilingual model of the same "
|
| 460 |
+
"budget actually achieves. B-GPT (Arnett et al.) trains English+X **jointly** with one "
|
| 461 |
+
"shared tokenizer — the target the composition literature is trying to reach without "
|
| 462 |
+
"joint training. B-GPT's context window is 128 tokens, so **every arm in this table, "
|
| 463 |
+
"including the Goldfish parents and merges, is re-scored at a matched 128-token "
|
| 464 |
+
"context**; these numbers are therefore not directly comparable to the 512-token SET 4 "
|
| 465 |
+
"tables above, only to each other.\n")
|
| 466 |
+
arms = list(bgc[0]["arms"])
|
| 467 |
+
for metric, lbl in (("nats_per_byte_eng", "nats/byte, English"), ("nats_per_byte_x", "nats/byte, partner"),
|
| 468 |
+
("multiblimp_eng", "MultiBLiMP-English"), ("multiblimp_x", "MultiBLiMP-partner")):
|
| 469 |
+
L.append(f"\n**{lbl}**" + (" (lower is better)" if "nats" in metric else " (higher is better, chance 0.500)") + "\n")
|
| 470 |
+
L.append(md_table(["pair"] + arms,
|
| 471 |
+
[[f"eng–{r['lang']}"] + [fmt(r["arms"][a][metric]) for a in arms] for r in bgc]))
|
| 472 |
+
L.append("""
|
| 473 |
+
This is the cleanest single statement the audit can make about SET 4. A jointly trained bilingual
|
| 474 |
+
model of the same parameter budget is **good at both languages at once** — near the monolingual
|
| 475 |
+
parents on likelihood and on MultiBLiMP. The merge of two monolingual models is not close, on either
|
| 476 |
+
metric, under any rung, in either anchoring direction. The gap is not a coordinate gap that a better
|
| 477 |
+
aligner might close; the joint model also has a *shared vocabulary*, which is exactly the axis the
|
| 478 |
+
alignment group cannot act on.
|
| 479 |
+
""")
|
| 480 |
+
|
| 481 |
rev = load("set4_reverse.jsonl")
|
| 482 |
if rev:
|
| 483 |
L.append("\n## SET 4 · reverse direction (the partner language is the anchor)\n")
|
|
|
|
| 610 |
|
| 611 |
L.append("\n## Coverage — what ran and what did not\n")
|
| 612 |
cov = []
|
| 613 |
+
for sz in ["14m", "31m", "70m", "160m", "410m"]:
|
| 614 |
n = len([r for r in set1 if r["size"] == sz])
|
| 615 |
+
tot = 36 if sz != "410m" else 15
|
| 616 |
+
cov.append([f"SET 1 Δfloor · pythia-{sz}", f"{n}/{tot} seed pairs",
|
| 617 |
+
"complete" if n >= tot else ("partial" if n else "NOT RUN"),
|
| 618 |
+
"M0 naive · M1 permutation · M1 Procrustes · M2 task-arithmetic · M3 TIES; LMC barrier for M0 and M1-perm"])
|
| 619 |
+
if abl:
|
| 620 |
+
for sz in sorted({r["size"] for r in abl}):
|
| 621 |
+
cov.append([f"SET 1 control · pythia-{sz}", f"{len([r for r in abl if r['size'] == sz])}/3 pairs",
|
| 622 |
+
"complete", "init-seed-only vs data-order-only, same rungs"])
|
| 623 |
+
nb = {}
|
| 624 |
+
for b in blimp: nb[b["size"]] = nb.get(b["size"], 0) + 1
|
| 625 |
+
cov.append(["SET 1 accuracy · BLiMP", ", ".join(f"pythia-{k}: {v}/36" for k, v in sorted(nb.items(), key=lambda kv: int(kv[0][:-1]))) or "0",
|
| 626 |
"RAN" if blimp else "**NOT RUN**",
|
| 627 |
+
"67 paradigms from `nyu-mll/blimp`, minimal-pair sentence-logprob scoring, on the SAME merges"])
|
| 628 |
+
nr = {}
|
| 629 |
+
for r_ in rep: nr[r_["size"]] = nr.get(r_["size"], 0) + 1
|
| 630 |
+
cov.append(["SET 1 · REPAIR rung", ", ".join(f"pythia-{k}: {v}/36" for k, v in sorted(nr.items(), key=lambda kv: int(kv[0][:-1]))) or "0",
|
| 631 |
+
"RAN" if rep else "**NOT RUN**", "M4 = permutation-aligned average + pre-activation statistics repair; M5 = naive + repair; Δfloor and BLiMP on the same merges"])
|
| 632 |
+
cov.append(["SET 4 Δfloor · English-anchored", f"{len(set4)}/4 language pairs ({', '.join(r['lang'] for r in set4) or '—'})",
|
| 633 |
+
"complete" if len(set4) == 4 else ("partial" if set4 else "NOT RUN"),
|
| 634 |
+
"M0 naive · M1a vocab-transport · M1b/c vocab+unit-aligned · M1d/e forced-residual · M1f units-only · M1g/h embedding-row Procrustes"])
|
| 635 |
+
cov.append(["SET 4 Δfloor · partner-anchored (reverse)", f"{len(rev)}/4 language pairs",
|
| 636 |
+
"complete" if len(rev) == 4 else ("partial" if rev else "NOT RUN"), "same rungs, roles swapped"])
|
| 637 |
+
cov.append(["SET 4 accuracy · MultiBLiMP 1.0", f"{len(mb)}/4 language pairs",
|
| 638 |
+
"RAN" if mb else "**NOT RUN**", "`jumelet/multiblimp`, English + partner, on the SAME merges; UNK rate reported per cell"])
|
| 639 |
+
bg = load("bgpt_ceiling.jsonl")
|
| 640 |
+
cov.append(["SET 4 · jointly-trained bilingual ceiling", f"{len(bg)}/4 language pairs",
|
| 641 |
+
"RAN" if bg else "**NOT RUN**",
|
| 642 |
+
"`catherinearnett/B-GPT_en_X_simultaneous` vs the Goldfish parents and merges, all scored at a matched 128-token context"])
|
| 643 |
+
cov.append(["SET 4 · task-arithmetic / TIES", "0", "**NOT APPLICABLE**",
|
| 644 |
+
"Both operators need a shared ancestor. Two independently trained monolingual Goldfish models have none, and with one parent as a pseudo-base the operators reduce to returning the other parent. Excluded on definition, not on time."])
|
| 645 |
+
cov.append(["SET 1 · pythia-410m full grid", f"{len([r for r in set1 if r['size'] == '410m'])}/36 possible pairs", "partial",
|
| 646 |
+
"6 seeds only (15 possible pairs) and a reduced eval budget; the per-pair alignment cost is ~9 min at this width. Treat 410m as directional."])
|
| 647 |
+
cov.append(["Goldfish other tiers / other languages", "0", "NOT RUN", "Only the 1000mb tier and the four audit languages."])
|
| 648 |
+
cov.append(["Any downstream task beyond BLiMP/MultiBLiMP", "0", "NOT RUN",
|
| 649 |
+
"Both benchmarks are minimal-pair grammaticality tests. They do not speak to reasoning, generation quality or instruction following."])
|
| 650 |
L.append(md_table(["cell", "n", "status", "what was measured"], cov))
|
| 651 |
|
| 652 |
L.append("""
|
|
|
|
| 669 |
|
| 670 |
L.append("\n## Files\n")
|
| 671 |
L.append("""```
|
| 672 |
+
results/set1_{14m,31m,70m,160m,410m}.jsonl SET 1 per-pair raw records (predictors, rungs, barriers)
|
| 673 |
+
results/set1_pairs.csv SET 1 per-pair flat table
|
| 674 |
+
results/abl_160m-{weight,data}.jsonl init-seed-only vs data-order-only control
|
| 675 |
+
results/blimp_{size}.jsonl, blimp_pairs.csv SET 1 BLiMP accuracy, per pair and per rung
|
| 676 |
+
results/repair_{size}.jsonl REPAIR rung (Δfloor + BLiMP on the same merges)
|
| 677 |
+
results/set4_goldfish.jsonl, set4_pairs.csv SET 4 Δfloor, English-anchored
|
| 678 |
+
results/set4_reverse.jsonl SET 4 Δfloor, partner-language-anchored
|
| 679 |
+
results/set4_multiblimp.jsonl SET 4 MultiBLiMP accuracy
|
| 680 |
+
results/set4_tokenizer_diag.json UNK rates / bytes-per-token per (tokenizer, language)
|
| 681 |
+
results/rung_summary.csv rung x substrate x metric summary
|
| 682 |
+
results/predictor_auroc.csv P0-2: held-out-by-seed AUROC, seed-cluster null, BH q
|
| 683 |
+
results/predictor_transfer_across_size.csv P0-2: leave-one-substrate-out transfer
|
| 684 |
+
results/set4_predictors.csv P0-2 on SET 4 (n=4, descriptive only)
|
| 685 |
+
figs/set1_dfloor_by_rung.png Δfloor by rung, per size
|
| 686 |
+
figs/set1_scale_trend.png obstruction and rescue vs model size
|
| 687 |
+
figs/set1_rescue_vs_predictor.png realised rescue vs coordinate share / CKA
|
| 688 |
+
figs/set1_roc.png held-out-by-seed ROC
|
| 689 |
+
figs/set1_blimp_dissociation.png likelihood rescue vs accuracy rescue
|
| 690 |
+
figs/set4_dfloor.png Δfloor by rung, Goldfish
|
| 691 |
+
code/*.py every script that produced the above
|
| 692 |
+
```
|
| 693 |
+
|
| 694 |
+
**Reproducing.** `common.py` holds the corpora and evaluation; `gpt2_align.py` holds the GPT-2
|
| 695 |
+
(Conv1D) symmetry factors that `mergeschool.core.alignment`'s row-major aligners do not cover; the
|
| 696 |
+
`set1_*`/`set4_*` scripts are the drivers, each with a resumable JSONL ledger; `analyze.py` builds
|
| 697 |
+
the tables and figures and `make_report.py` writes this document. Merge operators, aligners, quotient
|
| 698 |
+
metrics and the barrier are imported unmodified from `mergeschool.core`.
|
| 699 |
+
""")
|
| 700 |
|
| 701 |
open("/root/compose-audit/RESULTS_COMPOSE_AUDIT.md", "w").write("\n".join(L) + "\n")
|
| 702 |
|
| 703 |
if rung_rows:
|
| 704 |
+
keys = []
|
| 705 |
+
for r in rung_rows:
|
| 706 |
+
for k in r:
|
| 707 |
+
if k not in keys: keys.append(k)
|
| 708 |
with open(f"{R}/rung_summary.csv", "w") as f:
|
| 709 |
f.write(",".join(keys) + "\n")
|
| 710 |
for r in rung_rows:
|