Buckets:
| """Build the selection corpus from published dumps — no GPU, no teacher, no cost. | |
| The 2026-08-10 contract change dropped L1lift: the ranking term is now Λ2 alone, | |
| Λ2 = lpC(y_C|z_A) − lpC(y_C|∅) | |
| which is TEACHER-side. Selecting on it would normally mean serving GLM-4.5-Air | |
| (~106 GB) alongside the king (~70 GB) just to score candidate thoughts. | |
| None of that is necessary, because the validator already did it. Every published | |
| pair carries the king's own thought `z_a`, its action `y_a`, and both logprobs | |
| needed for Λ2. af10 appears in 16 duels at exactly one revision, giving 1,066 | |
| turns of its OWN thoughts, each with ~4 independent samples, already scored. | |
| So the corpus is a pure read: per turn, keep the sample with the highest Λ2. | |
| That is on-policy best-of-4 selection against the real metric, for $0. | |
| Two guards that matter more than the saving: | |
| * the screen slice is excluded, or the screen would be scoring its own training set; | |
| * only the CURRENT king's revision is admitted, or the corpus would mix policies. | |
| python harness/select_dumps.py --out data/best.jsonl | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import gzip | |
| import json | |
| import re | |
| import pathlib | |
| import statistics as st | |
| import screen | |
| ROOT = pathlib.Path(__file__).resolve().parent.parent | |
| EVALS = ROOT / "evals" | |
| def lam2(p: dict) -> float: | |
| return p["lpC_yc_za"] - p["lpC_yc_e"] | |
| # Recorded z_a carries rollout-parsing debris: 22% are the same sentence twice, | |
| # 13% keep a leading `<think>`, 10% an inline `THOUGHT:`, and some a truncated | |
| # label like "THO\n". The validator scored the text as-is, so the debris is | |
| # harmless to the METRIC -- but it is a training target here, and copying it | |
| # teaches the model to emit stray tags and repeat itself. Strip only the | |
| # mechanical artifacts; never touch the reasoning. | |
| _LABEL = re.compile(r"</?think>|\bTHOUGHT:|^\s*THO(?:U(?:G(?:H(?:T)?)?)?)?\b", re.I | re.M) | |
| def clean_thought(z: str) -> str: | |
| """Strip structural debris, then collapse a duplicated body. | |
| Order matters. The common shape is `X\\nTHOUGHT: X` — the same sentence | |
| twice with a label wedged between — so a split-in-half test run BEFORE | |
| label removal never matches (the halves differ by len("THOUGHT: ")) and the | |
| duplicate survives into the training target. Remove every label first, then | |
| dedupe. | |
| """ | |
| s = re.sub(r"[ \t]+", " ", _LABEL.sub(" ", z)).strip() | |
| h = len(s) // 2 | |
| if h and s[:h].strip() and s[:h].strip() == s[h:].strip(): | |
| return s[:h].strip() | |
| # tolerate an odd character or two of drift between the two copies | |
| for cut in range(max(1, h - 4), min(len(s), h + 5)): | |
| a, b = s[:cut].strip(), s[cut:].strip() | |
| if a and a == b: | |
| return a | |
| return s | |
| def collect(repo: str, revision: str, exclude_ref: str) -> tuple[dict, set]: | |
| """Richest per-turn sample grid produced by `repo`@`revision`.""" | |
| excl = set(json.load(gzip.open(EVALS / f"{exclude_ref}.json.gz"))["turn_ids"]) | |
| grids: dict[str, list] = {} | |
| for f in sorted(EVALS.glob("chal-*.json.gz")): | |
| d = json.load(gzip.open(f)) | |
| r = d["request"] | |
| for side, rp, rv in (("king_rows", r.get("king_repo"), r.get("king_revision")), | |
| ("challenger_rows", r.get("challenger_repo"), | |
| r.get("challenger_revision"))): | |
| if rp != repo or (revision and rv != revision): | |
| continue | |
| for row in (d.get(side) or []): | |
| if not row.get("valid"): | |
| continue | |
| g = [p for p in row["pairs"] if p.get("z_a") and p.get("y_a")] | |
| if len(g) >= 2 and len(g) > len(grids.get(row["turn_id"], [])): | |
| grids[row["turn_id"]] = g | |
| return grids, excl | |
| def main() -> None: | |
| ap = argparse.ArgumentParser(description=__doc__.split("\n")[0]) | |
| ap.add_argument("--repo", default="Tok331102/affine-5EqYW8McUc-af10") | |
| ap.add_argument("--revision", default="eb8bf9a356a254f71faaa439e8abc3cfba572c53") | |
| ap.add_argument("--exclude-ref", default="chal-00388") | |
| ap.add_argument("--max-prefix-chars", type=int, default=23700, | |
| help="skip turns the trainer would drop at max_len 8192") | |
| ap.add_argument("--top", type=int, default=1) | |
| ap.add_argument("--no-clean", dest="clean", action="store_false", | |
| help="keep z_a verbatim, debris and all") | |
| ap.add_argument("--out", required=True) | |
| args = ap.parse_args() | |
| grids, excl = collect(args.repo, args.revision, args.exclude_ref) | |
| corpus = screen.load_corpus() | |
| outp = pathlib.Path(args.out) | |
| outp.parent.mkdir(parents=True, exist_ok=True) | |
| kept, all_l, sel_l, dropped_len, dropped_slice = [], [], [], 0, 0 | |
| cleaned = dropped_empty = 0 | |
| for tid, g in sorted(grids.items()): | |
| if tid in excl: | |
| dropped_slice += 1 | |
| continue | |
| if tid not in corpus: | |
| continue | |
| if args.max_prefix_chars and corpus[tid].get("n_prefix_chars", 0) > args.max_prefix_chars: | |
| dropped_len += 1 | |
| continue | |
| lifts = [lam2(p) for p in g] | |
| all_l.extend(lifts) | |
| for p in sorted(g, key=lam2, reverse=True)[: args.top]: | |
| z = clean_thought(p["z_a"]) if args.clean else p["z_a"] | |
| if not z: # nothing left after stripping debris | |
| dropped_empty += 1 | |
| continue | |
| if z != p["z_a"]: | |
| cleaned += 1 | |
| sel_l.append(lam2(p)) | |
| kept.append({"turn_id": tid, "source": "dump-selected", | |
| "prefix": corpus[tid]["prefix"], | |
| "target": "</think>\nTHOUGHT: " + z + "\n\n" + p["y_a"], | |
| "lambda2": lam2(p), "n_samples": len(g)}) | |
| with outp.open("w") as fh: | |
| for r in kept: | |
| fh.write(json.dumps(r) + "\n") | |
| gain = st.mean(sel_l) - st.mean(all_l) if all_l else 0.0 | |
| stats = {"examples": len(kept), "turns": len({r["turn_id"] for r in kept}), | |
| "repo": args.repo, "revision": args.revision, | |
| "mean_lambda2_all": st.mean(all_l) if all_l else None, | |
| "mean_lambda2_selected": st.mean(sel_l) if sel_l else None, | |
| "selection_gain": gain, | |
| "dropped_screen_slice": dropped_slice, "dropped_too_long": dropped_len, | |
| "cleaned": cleaned, "dropped_empty": dropped_empty} | |
| pathlib.Path(args.out + ".stats.json").write_text(json.dumps(stats, indent=2)) | |
| print(f" wrote {len(kept)} examples from {stats['turns']} turns -> {args.out}") | |
| print(f" dropped: {dropped_slice} screen-slice, {dropped_len} over length, " | |
| f"{dropped_empty} empty after cleaning") | |
| print(f" cleaned {cleaned}/{len(kept)+dropped_empty} thoughts of parse debris") | |
| print(f" mean Λ2, all samples {stats['mean_lambda2_all']:+.5f}") | |
| print(f" mean Λ2, SELECTED {stats['mean_lambda2_selected']:+.5f}") | |
| print(f" selection gain {gain:+.5f}") | |
| if __name__ == "__main__": | |
| main() | |
Xet Storage Details
- Size:
- 7.08 kB
- Xet hash:
- 962fc72e685c5efc4c13007d153ea66f994d70df18ed76a10fa9cbaf0f5c55e2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.