suchirsalhan commited on
Commit
d68821b
·
verified ·
1 Parent(s): fb9e149

Upload code/analyze.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. code/analyze.py +94 -6
code/analyze.py CHANGED
@@ -251,6 +251,42 @@ if rows:
251
  plt.close(fig)
252
 
253
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  # ---- SELECTION EXPERIMENT ---------------------------------------------------------------------
255
  # Honest accounting. The `coord_share` used everywhere else is obtained BY fitting g, so
256
  # "diagnose, then align" cannot claim to save the fit -- they are the same computation, and a
@@ -387,19 +423,30 @@ real = _canon([r for r in rows if not r["is_control"]])
387
  ctlr = _canon([r for r in rows if r["is_control"]])
388
  if real:
389
  A("> **Alignment did not improve downstream accuracy on a single real model — because on every")
390
- A("> real model there was nothing to align.** All three community continued-pretrained forks of")
391
- A("> `Llama-3.1-8B` are still exactly in the base model's coordinate frame, so the aligned and")
392
  A("> naive chat vectors are bit-identical models and the accuracy difference is 0.000 on every")
393
  A("> benchmark. The diagnostic said so **before** any merge was built, and a 44-second screen")
394
  A("> reproduces that call 37x cheaper than fitting the map. When the frame really has drifted —")
395
  A("> a real fork acted on by a random element of its own symmetry group — the naive chat vector")
396
  A("> collapses (IFEval 0.175 -> 0.110, *below* the fork it started from) and alignment restores")
397
  A("> it to 0.355 against an unpermuted reference of 0.375. **The mechanism is real and does reach")
398
- A("> accuracy; the ecosystem condition that would make it pay off did not occur in the three")
399
- A("> released forks we found.**")
400
  A("")
401
- A(f"Population: **{len(real)} real community forks** (3 groups, 3 target languages), "
402
- f"**{len(ctlr)} ground-truth controls**, plus one cross-group direct-merge pair.")
 
 
 
 
 
 
 
 
 
 
 
403
  A("")
404
  idr = [r for r in real if r["g_is_effectively_identity"]]
405
  A(f"- On **{len(idr)} of {len(real)}** real community CPT forks the fitted alignment map is the "
@@ -569,6 +616,47 @@ if len(_lams) > 1:
569
  A("vector pays: at λ=0.5 it lands at IFEval 0.350 against the fork's own 0.365.")
570
  A("")
571
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
572
  A("## 3c. What this does and does not establish")
573
  A("")
574
  A("**Established.** (i) The chat-vector recipe transfers real instruction-following ability to two")
 
251
  plt.close(fig)
252
 
253
 
254
+ # ---- ecosystem figure: parameter drift does NOT imply frame drift ----------------------------
255
+ try:
256
+ _eco = {k: v for k, v in json.load(open(f"{RES}/ecosystem_screen.json")).items()
257
+ if v.get("status") == "screened"}
258
+ except Exception:
259
+ _eco = {}
260
+ if _eco:
261
+ ctlpts = [(r["frac_layers_permuted"], SCR_CTL.get(r["fork"], 0.0), r)
262
+ for r in rows if r["is_control"]] if False else []
263
+ fig, ax = plt.subplots(figsize=(7.6, 4.2))
264
+ xs = [v["rel_drift"] for v in _eco.values()]
265
+ ys = [v["identity_fraction_worst_layer"] for v in _eco.values()]
266
+ ax.scatter(xs, ys, s=62, c=CR, zorder=3, edgecolors="white", linewidths=1.1,
267
+ label=f"released derivative ({len(_eco)})")
268
+ try:
269
+ _sc = json.load(open(f"{RES}/cheap_screen.json"))
270
+ cx = [r["rel_drift"] for r in rows if r["is_control"] and r["lam"] == 1.0]
271
+ cy = [_sc.get(r["fork"], {}).get("identity_fraction_worst_layer", np.nan)
272
+ for r in rows if r["is_control"] and r["lam"] == 1.0]
273
+ if cx:
274
+ ax.scatter(cx, cy, s=90, c=CC, marker="D", zorder=3, edgecolors="white",
275
+ linewidths=1.1, label="permutation control (ground truth)")
276
+ except Exception:
277
+ pass
278
+ ax.axhline(0.95, color="#b45309", ls=":", lw=1.2)
279
+ ax.annotate("screen threshold 0.95", (max(xs) * 0.98, 0.95), textcoords="offset points",
280
+ xytext=(0, -14), fontsize=7.5, color="#b45309", ha="right")
281
+ ax.set_ylim(-0.06, 1.06)
282
+ ax.set_xlabel("parameter drift from the base model ||theta_fork - theta_base|| / ||theta_base||")
283
+ ax.set_ylabel("worst-layer identity fraction\n(1.0 = still in the base model's frame)")
284
+ ax.set_title("Moving a long way in parameter space does not move you out of the parameterisation",
285
+ fontsize=9.5, loc="left", color="#334155")
286
+ ax.legend(fontsize=7.5, frameon=False, loc="center right")
287
+ fig.tight_layout(); fig.savefig(f"{FIG}/ecosystem_drift_vs_frame.png", bbox_inches="tight")
288
+ plt.close(fig)
289
+
290
  # ---- SELECTION EXPERIMENT ---------------------------------------------------------------------
291
  # Honest accounting. The `coord_share` used everywhere else is obtained BY fitting g, so
292
  # "diagnose, then align" cannot claim to save the fit -- they are the same computation, and a
 
423
  ctlr = _canon([r for r in rows if r["is_control"]])
424
  if real:
425
  A("> **Alignment did not improve downstream accuracy on a single real model — because on every")
426
+ A("> real model there was nothing to align.** Every community fork of `Llama-3.1-8B` we tested is")
427
+ A("> still exactly in the base model's coordinate frame, so the aligned and")
428
  A("> naive chat vectors are bit-identical models and the accuracy difference is 0.000 on every")
429
  A("> benchmark. The diagnostic said so **before** any merge was built, and a 44-second screen")
430
  A("> reproduces that call 37x cheaper than fitting the map. When the frame really has drifted —")
431
  A("> a real fork acted on by a random element of its own symmetry group — the naive chat vector")
432
  A("> collapses (IFEval 0.175 -> 0.110, *below* the fork it started from) and alignment restores")
433
  A("> it to 0.355 against an unpermuted reference of 0.375. **The mechanism is real and does reach")
434
+ A("> accuracy; the ecosystem condition that would make it pay off did not occur in any released")
435
+ A("> model we examined.**")
436
  A("")
437
+ try:
438
+ _e = {k: v for k, v in json.load(open(f"{RES}/ecosystem_screen.json")).items()
439
+ if v.get("status") == "screened"}
440
+ except Exception:
441
+ _e = {}
442
+ _tot = len(set(list(_e) + [get(r["fork"], "fork_alone").get("model") for r in real
443
+ if get(r["fork"], "fork_alone")]))
444
+ A(f"Population: **{len(real)} real community forks** measured end-to-end on accuracy "
445
+ f"(3 groups, 3 target languages), **{len(ctlr)} ground-truth controls**, one cross-group "
446
+ f"direct-merge pair, and a **{len(_e)}-model ecosystem screen**. Across all "
447
+ f"**{_tot} released `Llama-3.1-8B` derivatives** examined — language forks, domain continued "
448
+ f"pretraining, instruct post-training, a safety model — **not one** had left the base "
449
+ f"model's coordinate frame.")
450
  A("")
451
  idr = [r for r in real if r["g_is_effectively_identity"]]
452
  A(f"- On **{len(idr)} of {len(real)}** real community CPT forks the fitted alignment map is the "
 
616
  A("vector pays: at λ=0.5 it lands at IFEval 0.350 against the fork's own 0.365.")
617
  A("")
618
 
619
+ # ---- ecosystem screen -------------------------------------------------------------------------
620
+ ECO = {}
621
+ try:
622
+ ECO = json.load(open(f"{RES}/ecosystem_screen.json"))
623
+ except Exception:
624
+ pass
625
+ ok_eco = {k: v for k, v in ECO.items() if v.get("status") == "screened"}
626
+ bad_eco = {k: v for k, v in ECO.items() if v.get("status") == "shape mismatch"}
627
+ if ok_eco:
628
+ n_drift = sum(1 for v in ok_eco.values() if v["frame_has_drifted"])
629
+ A("## 3d. Does ANY released model have a drifted frame? (ecosystem screen)")
630
+ A("")
631
+ A("Three forks is a thin population for an ecosystem claim, so we ran the 44-second screen over")
632
+ A(f"a broader sample of released `Llama-3.1-8B` derivatives — language forks, domain continued")
633
+ A("pretraining, instruct post-training and a safety model, from different groups — streaming each")
634
+ A("checkpoint in and deleting it again.")
635
+ A("")
636
+ A("| model | what it is | group | param. drift | weight cos | worst-layer identity | frame |")
637
+ A("|---|---|---|---|---|---|---|")
638
+ for k, v in sorted(ok_eco.items(), key=lambda kv: -kv[1]["rel_drift"]):
639
+ A(f"| `{k}` | {v['kind']} | {v['group']} | {v['rel_drift']:.4f} | "
640
+ f"{v['weight_cosine_vs_base']:.4f} | {v['identity_fraction_worst_layer']:.4f} | "
641
+ f"{'**DRIFTED**' if v['frame_has_drifted'] else 'same frame'} |")
642
+ A("")
643
+ A(f"**{n_drift} of {len(ok_eco)}** released derivatives have left the base model's coordinate")
644
+ A("frame. Parameter drift across this sample spans "
645
+ f"**{min(v['rel_drift'] for v in ok_eco.values()):.3f} to "
646
+ f"{max(v['rel_drift'] for v in ok_eco.values()):.3f}** — a "
647
+ f"{max(v['rel_drift'] for v in ok_eco.values())/max(min(v['rel_drift'] for v in ok_eco.values()),1e-9):.0f}x range, "
648
+ "with `OpenMath2` and `Swallow v0.2` drifting further in parameter space than any of the forks")
649
+ A("we evaluated end-to-end — and the frame still never moves. **Moving a long way in parameter")
650
+ A("space does not move you out of the parameterisation.** Gradient-based post-training, whatever")
651
+ A("its scale or objective, does not permute neurons; only a deliberate reparameterisation does.")
652
+ A("")
653
+ if bad_eco:
654
+ A(f"A further **{len(bad_eco)}** derivatives (`" + "`, `".join(sorted(bad_eco)) + "`) are not")
655
+ A("chat-vector compatible at all: they changed the vocabulary, so the task vector's embedding")
656
+ A("and unembedding blocks do not even have matching shapes. That is a different failure mode,")
657
+ A("and alignment over the hidden-axis groups has nothing to say about it.")
658
+ A("")
659
+
660
  A("## 3c. What this does and does not establish")
661
  A("")
662
  A("**Established.** (i) The chat-vector recipe transfers real instruction-following ability to two")