Skip to content
nano-gpt-data-curation

claude-opus-4-8

nano-gpt-data-curation — graded by the task's verifier against a measured baseline.

backend
modal
variant
claude claude-opus-4-8
metric
held-out multi-domain perplexity
actions
87
duration
1h 21m
recorded
2026-08-04

run iddclm-nano-curation__7umcSHc

Everything claude-opus-4-8 did on this task, in order.

download JSON ↗
claude-codeclaude-opus-4-885 turns69 narration87 action87 observation16 reasoning1 final
#76
reasoning (redacted)

encrypted chain-of-thought — recorded, not exposed

toolBashGenerate and eval V5 (deeper quota, no fallback leak)
args
{
  "command": "cd /workspace/submission; export TOKENIZERS_PARALLELISM=false; python3 curate.py --out /tmp/sel_v5.json 2>&1 | grep -v -i warning | tail -2; echo \"=== eval V5 (STRAT_BUD=13.8M) ===\"; cd /workspace; bash dev_eval.sh /tmp/sel_v5.json 2>&1 | grep -Ei \"packed|HELDOUT_PPL\" | tail -2; echo \"timer:\"; cat /workspace/.timer/remaining_secs",
  "description": "Generate and eval V5 (deeper quota, no fallback leak)"
}
Bash result
Command did not complete within its 120s timeout and was moved to the background (ID: b8uv1vie2). Output is being written to: /tmp/claude-0/-workspace/d723e7a0-a155-47f3-b352-d47c686c4960/tasks/b8uv1vie2.output. You will be notified when it completes. To check interim output, use Read on that file path.
Session cwd remains /workspace/submission; directory changes made by the backgrounded command do not apply to subsequent commands.

[metadata] {"noOutputExpected": false, "backgroundTaskId": "b8uv1vie2", "timedOutAfterMs": 120000, "backgroundCwdHint": "Session cwd remains /workspace/submission; directory changes made by the backgrounded command do not apply to subsequent commands."}
#77
narration

The V5 generation + eval exceeded 120s (selection build + training). Let me wait for it:

toolTaskOutput
args
{
  "task_id": "b8uv1vie2",
  "block": true,
  "timeout": 120000
}
TaskOutput result
<retrieval_status>success</retrieval_status>

<task_id>b8uv1vie2</task_id>

<task_type>local_bash</task_type>

<status>completed</status>

<exit_code>0</exit_code>

<output>
selected per-register est tokens (M): [6.44 0.95 0.83 0.47 0.68 0.15 0.82 3.49]
wrote 17860 ids -> /tmp/sel_v5.json; ~15.0M est tokens (budget 12M)
=== eval V5 (STRAT_BUD=13.8M) ===
packed 12000000 tokens from 17860 ids -> /tmp/dev_train.npy
HELDOUT_PPL 343.857  loss 5.8402  train_s 56  /tmp/dev_train.npy
timer:
1332
</output>

[metadata] {"retrieval_status": "success", "task": {"task_id": "b8uv1vie2", "task_type": "local_bash", "status": "completed", "description": "Generate and eval V5 (deeper quota, no fallback leak)", "output": "selected per-register est tokens (M): [6.44 0.95 0.83 0.47 0.68 0.15 0.82 3.49]\nwrote 17860 ids -> /tmp/sel_v5.json; ~15.0M est tokens (budget 12M)\n=== eval V5 (STRAT_BUD=13.8M) ===\npacked 12000000 tokens from 17860 ids -> /tmp/dev_train.npy\nHELDOUT_PPL 343.857  loss 5.8402  train_s 56  /tmp/dev_train.npy\ntimer:\n1332\n", "exitCode": 0}}
#78
narration

V5 = 343.857 — another 4.4 ppl improvement over V4 (348.225)! Eliminating the fallback leak (keeping all 12M trained tokens inside the register-matched quota) confirms the mechanism: on-mixture tokens beat off-mixture high-affinity tokens. This is principled, not dev-tuning. That's now a 24.8% reduction from random (457.2 → 343.9).

Note: the round-robin pick order is scale-invariant in STRAT_BUD (quotas scale together), so 13.8M just extends the on-mixture portion past 12M actual — raising it further is neutral. This is the sweet spot. Adopting V5 as the deliverable:

toolBashRegenerate selection.json as V5, validate
args
{
  "command": "cd /workspace/submission; export TOKENIZERS_PARALLELISM=false; python3 curate.py 2>&1 | grep -v -i warning | tail -1; python3 -c \"\nimport json,numpy as np\na=json.load(open('/workspace/submission/selection.json')); b=json.load(open('/tmp/sel_v5.json'))\narr=np.array(a)\nprint('selection.json == eval\\\\'d V5:', a==b)\nprint('ids:',len(a),'| unique:',len(set(a))==len(a),'| range [%d,%d] in-bounds:'%(arr.min(),arr.max()), arr.min()>=0 and arr.max()<182016)\n\"; echo \"timer:\"; cat /workspace/.timer/remaining_secs",
  "description": "Regenerate selection.json as V5, validate"
}
Bash result
wrote 17860 ids -> /workspace/submission/selection.json; ~15.0M est tokens (budget 12M)
selection.json == eval'd V5: True
ids: 17860 | unique: True | range [17,181826] in-bounds: True
timer:
1252

[stdout]
wrote 17860 ids -> /workspace/submission/selection.json; ~15.0M est tokens (budget 12M)
selection.json == eval'd V5: True
ids: 17860 | unique: True | range [17,181826] in-bounds: True
timer:
1252
[metadata] {"noOutputExpected": false}
#79
narration

selection.json is now V5 (17,860 unique in-range ids), byte-identical to the eval'd file. Running the gold-standard certification on the exact deliverable, plus recomputing the register-mix observable for V5:

toolBashGold-standard re-certify deliverable selection.json
args
{
  "command": "cd /workspace; export TOKENIZERS_PARALLELISM=false; bash dev_eval.sh /workspace/submission/selection.json 2>&1 | grep -Ei \"packed|HELDOUT_PPL\" | tail -2",
  "description": "Gold-standard re-certify deliverable selection.json"
}
Bash result
packed 12000000 tokens from 17860 ids -> /tmp/dev_train.npy
HELDOUT_PPL 343.857  loss 5.8402  train_s 56  /tmp/dev_train.npy

[stdout]
packed 12000000 tokens from 17860 ids -> /tmp/dev_train.npy
HELDOUT_PPL 343.857  loss 5.8402  train_s 56  /tmp/dev_train.npy
[metadata] {"noOutputExpected": false}
toolBashRecompute V5 register-mix L1
args
{
  "command": "cd /workspace/submission; export TOKENIZERS_PARALLELISM=false; python3 -c \"\nimport json, numpy as np, math\nimport curate as C\ncache=C.load_cache(); seg_ng,seg_len=C.dev_segments(); lab=C.cluster_target(seg_ng)\nallf,off=cache['allfeats'],cache['off']; ids=cache['ids']; keep=cache['keep']\nCr=cache['Cr'].astype(np.float64); Nr=Cr.sum(); counts=np.diff(off); est=cache['nchars']/4.0\nK=C.K_CLUST; Ct_c=[np.zeros(C.T) for _ in range(K)]; tokc=np.zeros(K)\nfor si,g in enumerate(seg_ng):\n    c=lab[si]\n    if c<0 or len(g)==0: continue\n    Ct_c[c]+=np.bincount(g,minlength=C.T); tokc[c]+=seg_len[si]\nfrac=tokc/tokc.sum()\nS=np.full((len(ids),K),-1e18)\nfor c in range(K):\n    lrc=C._lr(Ct_c[c],Cr,Ct_c[c].sum(),Nr); S[:,c]=C._doc_scores(lrc,allf,off,counts)\nvalid=keep&(S.max(1)>-1e17); Sz=S.copy()\nfor c in range(K):\n    cc=S[valid,c]; Sz[:,c]=(S[:,c]-cc.mean())/(cc.std()+1e-9)\nSz[~valid]=-1e18; best_c=Sz.argmax(1)\nid2j={int(ids[j]):j for j in range(len(ids))}\ndef mix(selfile,budget=12_000_000):\n    sel=json.load(open(selfile)); tk=np.zeros(K); cum=0.0\n    for i in sel:\n        j=id2j[i]; cum+=est[j]\n        if valid[j]: tk[best_c[j]]+=est[j]\n        if cum>=budget: break\n    return tk/tk.sum()\nmv5=mix('/workspace/submission/selection.json')\nprint('V5 stratified register-mix L1 (first 12M est):', '%.4f'%np.abs(mv5-frac).sum())\n\"  2>&1 | grep -v -i warning | tail -1",
  "description": "Recompute V5 register-mix L1"
}
Bash result
V5 stratified register-mix L1 (first 12M est): 0.0019

[stdout]
V5 stratified register-mix L1 (first 12M est): 0.0019
[metadata] {"noOutputExpected": false}
#80
narration

CERTIFIED: HELDOUT_PPL 343.857, packing exactly 12,000,000 tokens from 17,860 ids. Register-mix L1 = 0.0019 (near-perfect target-mixture match). Final scoreboard:

selectionglobal affinityregister-mix L1ppl
random−0.799457.2
gates-only−0.707439.9
top-k + dedup−0.4980.429355.0
stratified (small leak)−0.530~0.002348.2
stratified sealed (deliverable)~−0.530.0019343.9

Now updating claim.md to the final V5 numbers with the mixture-fidelity ladder as the sharpened observable:

toolWrite
args
{
  "file_path": "/workspace/claim.md",
  "content": "# Claim: matching the target's *register mixture* (not just its average n‑gram profile), behind quality gates and dedup, minimizes held‑out perplexity under a fixed token budget\n\n## Hypothesis\nUnder a fixed 12M‑token budget (~6% of the ~193M‑token pool), held‑out perplexity\non the broad high‑quality target (Wikipedia / web prose / news / technical Q&A) is\nminimized **not by picking the individually \"best\" documents, but by making the\nselected token distribution match the target distribution** — spending no budget on\nweb junk or redundant copies. The target is a *mixture* of sub‑registers, and the\ndecisive move is to reproduce that mixture in the training data, not to maximize\naverage target‑affinity (which over‑selects one register and starves the others).\n\nConcretely: rank pool documents by their **per‑token target‑vs‑pool n‑gram\nlog‑likelihood ratio** (DSIR‑style importance), behind cheap English‑prose quality\ngates; then, rather than taking the global top‑k, **cluster the target into K\nsub‑registers and fill the budget by quota so each register contributes tokens in\nproportion to its share of the target** — sizing the quota so the whole 12M‑token\nbudget is drawn from register‑matched documents — deduplicating near‑copies as we go.\n\nMeasured (frozen 30M GPT, seed 1337, dev target):\n\n| selection | held‑out ppl |\n|---|---|\n| random pool sample (baseline) | 457.2 |\n| DSIR top‑k + gates + dedup | 355.0 |\n| **register‑stratified (this method, `selection.json`)** | **343.9** |\n\n→ **24.8% lower perplexity than random**, from data selection alone;\nregister‑stratification alone accounts for 11.1 ppl beyond the plain top‑k pipeline.\n\n## Mechanism — predicted observables *other* than final perplexity\nPerplexity is governed by the *distributional distance* between the training tokens\nand the target, which has **two** components. Both are training‑free and were\nmeasured directly.\n\n**(1) Mean per‑token target/pool log‑ratio (\"global affinity\") explains the large\ngain.** The more target‑matched the tokens, the lower the ppl, *before any training* —\nmonotone across the affinity‑increasing ablation:\n\n| selection | global affinity (↑) | ppl (↓) |\n|---|---|---|\n| random | −0.799 | 457.2 |\n| quality‑gates‑only | −0.707 | 439.9 |\n| DSIR top‑k + dedup | −0.498 | 355.0 |\n\n**(2) Register‑mixture distance explains the *final* gain — the sharper,\npre‑registered test, because it moves ppl *against* the affinity signal.**\nPrediction (made before running the stratified selection): forcing the *trained*\nregister proportions toward the target's lowers ppl *even though it slightly lowers\nglobal affinity* (quota admits lower‑affinity docs from starved registers, and seals\nout higher‑affinity but off‑mixture fallback tokens). Measured — the mixture‑fidelity\nladder over the 12M tokens actually trained on:\n\n| selection | global affinity | register‑mix L1 to target (↓) | ppl (↓) |\n|---|---|---|---|\n| DSIR top‑k + dedup | −0.498 | 0.429 | 355.0 |\n| stratified, ~2.5% off‑mixture fallback in budget | ≈ −0.53 | (leak) | 348.2 |\n| **stratified, budget fully register‑matched** | ≈ −0.53 | **0.0019** | **343.9** |\n\nTop‑k, chasing average affinity, crushes the target's second‑largest register\n(target share 0.253 → 0.073) and over‑fills the highest‑scoring one (L1 = 0.429).\nStratifying restores the mixture; **sealing the last ~2.5% of the budget so even the\ntail is register‑matched (L1 0.0019) drops ppl a further 4.4** — all while global\naffinity stays flat/slightly worse. So affinity is *not* a strictly monotone\npredictor once composition changes; the missing variable is register‑mixture\ndistance, and each increment of mixture fidelity (0.429 → ~0 → sealed) lowers ppl,\nexactly as predicted. Training is deterministic (seed 1337: identical data ⇒\nidentical ppl), so these 4–7 ppl steps are real signal, not run‑to‑run noise.\n\n**(3) The gain decomposes; junk‑removal is the *minor* term.** ~34% of pool\ndocuments fail basic English‑prose gates (non‑English, nav‑menu boilerplate,\nsymbol/number soup).\n\n| step added | ppl | Δ | share of the 113‑ppl gain |\n|---|---|---|---|\n| random → quality gates | 457.2 → 439.9 | −17.3 | 15% |\n| gates → target‑matching (DSIR rank) | 439.9 → 362.9 | −77.0 | **68%** |\n| matching → near‑dup dedup | 362.9 → 355.0 | −7.9 | 7% |\n| top‑k dedup → register‑stratified | 355.0 → 343.9 | −11.1 | 10% |\n\nThe dominant lever for a *broad* target is aligning the training distribution to it\n(68%), not merely filtering bad pages (15%); dedup adds 7% and register‑balance 10%.\n\n## Falsification\nThe hypothesis is falsified if any of the following held (none did):\n- Curated ppl ≥ random ppl (observed 343.9 ≪ 457.2).\n- **Register‑stratification does not beat plain top‑k** — i.e. forcing the trained\n  mixture to match the target (L1 0.429 → 0.002) fails to lower ppl, or raises it.\n  This is load‑bearing, because stratification *lowers* global affinity\n  (−0.498 → −0.530): if ppl tracked affinity alone it would have gone *up*. Observed\n  −11.1 ppl, so mixture‑matching is a genuine, separate lever.\n- **Sealing the off‑mixture budget tail does not help** — the extra prediction that\n  replacing the last ~2.5% high‑affinity‑but‑off‑register tokens with on‑register\n  ones lowers ppl. Observed −4.4 ppl, confirming it is the *mixture*, not the\n  affinity, of those tokens that matters.\n- Quality‑gates‑only matches or beats target‑matching (observed: matching adds\n  77 ppl, 4.5× the gate term).\n- Removing dedup does not raise ppl (observed +7.9 ppl without it).\n- The gains are within training noise (impossible: training is seed‑fixed and\n  deterministic; identical selections reproduce ppl to the digit).\nA further pre‑registered test: a selection built to *maximize* affinity but composed\nof gibberish/rare‑word documents (the naive‑DSIR failure mode we corrected by\nclamping rare‑n‑gram weights to ≤0) should **not** lower ppl — matching must be to\ngenuine target n‑grams, not to smoothing artifacts of rare tokens.\n\n## Transfer\n- **Other targets:** the criterion is target‑agnostic — rebuild the n‑gram profile\n  and the register clustering from any reference corpus and the same `curate.py`\n  curates for that domain's mixture.\n- **Hidden official target:** it is a disjoint sample of the *same* HQ domain, and\n  our features are aggregated over ~2,700 target segments and 8 register clusters\n  (domain‑level, not memorized documents). We matched the dev register mixture to\n  L1 ≈ 0.002; the hidden sample shares the same registers, so we predict a\n  comparable ~25% reduction vs random there.\n- **Budget / model scale:** the round‑robin ordering is scale‑invariant in the quota\n  base (per‑register quotas scale together), so a larger budget fills the same\n  register proportions deeper; a larger model still benefits from on‑distribution,\n  deduplicated, register‑balanced tokens — with diminishing returns as the budget\n  approaches the pool size (less to gain from being selective).\n- **Recipe portability:** importance‑ratio scoring + Gopher/C4 gates + register\n  stratification + MinHash dedup is a standard, reproducible pretraining‑curation\n  pipeline, requiring no labels and no target‑document memorization. `curate.py`\n  regenerates `selection.json` deterministically (crc32 hashing, fixed k‑means seed).\n"
}
Write result
The file /workspace/claim.md has been updated successfully. (file state is current in your context — no need to Read it back)

[metadata] {"type": "update", "filePath": "/workspace/claim.md", "content": "# Claim: matching the target's *register mixture* (not just its average n‑gram profile), behind quality gates and dedup, minimizes held‑out perplexity under a fixed token budget\n\n## Hypothesis\nUnder a fixed 12M‑token budget (~6% of the ~193M‑token pool), held‑out perplexity\non the broad high‑quality target (Wikipedia / web prose / news / technical Q&A) is\nminimized **not by picking the individually \"best\" documents, but by making the\nselected token distribution match the target distribution** — spending no budget on\nweb junk or redundant copies. The target is a *mixture* of sub‑registers, and the\ndecisive move is to reproduce that mixture in the training data, not to maximize\naverage target‑affinity (which over‑selects one register and starves the others).\n\nConcretely: rank pool documents by their **per‑token target‑vs‑pool n‑gram\nlog‑likelihood ratio** (DSIR‑style importance), behind cheap English‑prose quality\ngates; then, rather than taking the global top‑k, **cluster the target into K\nsub‑registers and fill the budget by quota so each register contributes tokens in\nproportion to its share of the target** — sizing the quota so the whole 12M‑token\nbudget is drawn from register‑matched documents — deduplicating near‑copies as we go.\n\nMeasured (frozen 30M GPT, seed 1337, dev target):\n\n| selection | held‑out ppl |\n|---|---|\n| random pool sample (baseline) | 457.2 |\n| DSIR top‑k + gates + dedup | 355.0 |\n| **register‑stratified (this method, `selection.json`)** | **343.9** |\n\n→ **24.8% lower perplexity than random**, from data selection alone;\nregister‑stratification alone accounts for 11.1 ppl beyond the plain top‑k pipeline.\n\n## Mechanism — predicted observables *other* than final perplexity\nPerplexity is governed by the *distributional distance* between the training tokens\nand the target, which has **two** components. Both are training‑free and were\nmeasured directly.\n\n**(1) Mean per‑token target/pool log‑ratio (\"global affinity\") explains the large\ngain.** The more target‑matched the tokens, the lower the ppl, *before any training* —\nmonotone across the affinity‑increasing ablation:\n\n| selection | global affinity (↑) | ppl (↓) |\n|---|---|---|\n| random | −0.799 | 457.2 |\n| quality‑gates‑only | −0.707 | 439.9 |\n| DSIR top‑k + dedup | −0.498 | 355.0 |\n\n**(2) Register‑mixture distance explains the *final* gain — the sharper,\npre‑registered test, because it moves ppl *against* the affinity signal.**\nPrediction (made before running the stratified selection): forcing the *trained*\nregister proportions toward the target's lowers ppl *even though it slightly lowers\nglobal affinity* (quota admits lower‑affinity docs from starved registers, and seals\nout higher‑affinity but off‑mixture fallback tokens). Measured — the mixture‑fidelity\nladder over the 12M tokens actually trained on:\n\n| selection | global affinity | register‑mix L1 to target (↓) | ppl (↓) |\n|---|---|---|---|\n| DSIR top‑k + dedup | −0.498 | 0.429 | 355.0 |\n| stratified, ~2.5% off‑mixture fallback in budget | ≈ −0.53 | (leak) | 348.2 |\n| **stratified, budget fully register‑matched** | ≈ −0.53 | **0.0019** | **343.9** |\n\nTop‑k, chasing average affinity, crushes the target's second‑largest register\n(target share 0.253 → 0.073) and over‑fills the highest‑scoring one (L1 = 0.429).\nStratifying restores the mixture; **sealing the last ~2.5% of the budget so even the\ntail is register‑matched (L1 0.0019) drops ppl a further 4.4** — all while global\naffinity stays flat/slightly worse. So affinity is *not* a strictly monotone\npredictor once composition changes; the missing variable is register‑mixture\ndistance, and each increment of mixture fidelity (0.429 → ~0 → sealed) lowers ppl,\nexactly as predicted. Training is deterministic (seed 1337: identical data ⇒\nidentical ppl), so these 4–7 ppl steps are real signal, not run‑to‑run noise.\n\n**(3) The gain decomposes; junk‑removal is the *minor* term.** ~34% of pool\ndocuments fail basic English‑prose gates (non‑English, nav‑menu boilerplate,\nsymbol/number soup).\n\n| step added | ppl | Δ | share of the 113‑ppl gain |\n|---|---|---|---|\n| random → quality gates | 457.2 → 439.9 | −17.3 | 15% |\n| gates → target‑matching (DSIR rank) | 439.9 → 362.9 | −77.0 | **68%** |\n| matching → near‑dup dedup | 362.9 → 355.0 | −7.9 | 7% |\n| top‑k dedup → register‑stratified | 355.0 → 343.9 | −11.1 | 10% |\n\nThe dominant lever for a *broad* target is aligning the training distribution to it\n(68%), not merely filtering bad pages (15%); dedup adds 7% and register‑balance 10%.\n\n## Falsification\nThe hypothesis is falsified if any of the following held (none did):\n- Curated ppl ≥ random ppl (observed 343.9 ≪ 457.2).\n- **Register‑stratification does not beat plain top‑k** — i.e. forcing the trained\n  mixture to match the target (L1 0.429 → 0.002) fails to lower ppl, or raises it.\n  This is load‑bearing, because stratification *lowers* global affinity\n  (−0.498 → −0.530): if ppl tracked affinity alone it would have gone *up*. Observed\n  −11.1 ppl, so mixture‑matching is a genuine, separate lever.\n- **Sealing the off‑mixture budget tail does not help** — the extra prediction that\n  replacing the last ~2.5% high‑affinity‑but‑off‑register tokens with on‑register\n  ones lowers ppl. Observed −4.4 ppl, confirming it is the *mixture*, not the\n  affinity, of those tokens that matters.\n- Quality‑gates‑only matches or beats target‑matching (observed: matching adds\n  77 ppl, 4.5× the gate term).\n- Removing dedup does not raise ppl (observed +7.9 ppl without it).\n- The gains are within training noise (impossible: training is seed‑fixed and\n  deterministic; identical selections reproduce ppl to the digit).\nA further pre‑registered test: a selection built to *maximize* affinity but composed\nof gibberish/rare‑word documents (the naive‑DSIR failure mode we corrected by\nclamping rare‑n‑gram weights to ≤0) should **not** lower ppl — matching must be to\ngenuine target n‑grams, not to smoothing artifacts of rare tokens.\n\n## Transfer\n- **Other targets:** the criterion is target‑agnostic — rebuild the n‑gram profile\n  and the register clustering from any reference corpus and the same `curate.py`\n  curates for that domain's mixture.\n- **Hidden official target:** it is a disjoint sample of the *same* HQ domain, and\n  our features are aggregated over ~2,700 target segments and 8 register clusters\n  (domain‑level, not memorized documents). We matched the dev register mixture to\n  L1 ≈ 0.002; the hidden sample shares the same registers, so we predict a\n  comparable ~25% reduction vs random there.\n- **Budget / model scale:** the round‑robin ordering is scale‑invariant in the quota\n  base (per‑register quotas scale together), so a larger budget fills the same\n  register proportions deeper; a larger model still benefits from on‑distribution,\n  deduplicated, register‑balanced tokens — with diminishing returns as the budget\n  approaches the pool size (less to gain from being selective).\n- **Recipe portability:** importance‑ratio scoring + Gopher/C4 gates + register\n  stratification + MinHash dedup is a standard, reproducible pretraining‑curation\n  pipeline, requiring no labels and no target‑document memorization. `curate.py`\n  regenerates `selection.json` deterministically (crc32 hashing, fixed k‑means seed).\n", "structuredPatch": [{"oldStart": 12, "oldLines": 8, "newStart": 12, "newLines": 9, "lines": [" Concretely: rank pool documents by their **per‑token target‑vs‑pool n‑gram", " log‑likelihood ratio** (DSIR‑style importance), behind cheap English‑prose quality", " gates; then, rather than taking the global top‑k, **cluster the target into K", "-sub‑registers, and fill the budget by quota so each register contributes tokens in", "-proportion to its share of the target**, deduplicating near‑copies as we go.", "+sub‑registers and fill the budget by quota so each register contributes tokens in", "+proportion to its share of the target** — sizing the quota so the whole 12M‑token", "+budget is drawn from register‑matched documents — deduplicating near‑copies as we go.", " ", " Measured (frozen 30M GPT, seed 1337, dev target):", " "]}, {"oldStart": 21, "oldLines": 10, "newStart": 22, "newLines": 10, "lines": [" |---|---|", " | random pool sample (baseline) | 457.2 |", " | DSIR top‑k + gates + dedup | 355.0 |", "-| **register‑stratified (this method, `selection.json`)** | **348.2** |", "+| **register‑stratified (this method, `selection.json`)** | **343.9** |", " ", "-→ **23.8% lower perplexity than random**, from data selection alone; the", "-register‑stratification step alone accounts for the final 6.7 ppl over plain top‑k.", "+→ **24.8% lower perplexity than random**, from data selection alone;", "+register‑stratification alone accounts for 11.1 ppl beyond the plain top‑k pipeline.", " ", " ## Mechanism — predicted observables *other* than final perplexity", " Perplexity is governed by the *distributional distance* between the training tokens"]}, {"oldStart": 32, "oldLines": 8, "newStart": 33, "newLines": 8, "lines": [" measured directly.", " ", " **(1) Mean per‑token target/pool log‑ratio (\"global affinity\") explains the large", "-gain.** Prediction: the more target‑matched the tokens, the lower the ppl, *before", "-any training*. Across the affinity‑increasing ablation this holds monotonically:", "+gain.** The more target‑matched the tokens, the lower the ppl, *before any training* —", "+monotone across the affinity‑increasing ablation:", " ", " | selection | global affinity (↑) | ppl (↓) |", " |---|---|---|"]}, {"oldStart": 41, "oldLines": 53, "newStart": 42, "newLines": 60, "lines": [" | quality‑gates‑only | −0.707 | 439.9 |", " | DSIR top‑k + dedup | −0.498 | 355.0 |", " ", "-**(2) Register‑mixture L1 distance explains the *final* gain — and is the sharper,", "+**(2) Register‑mixture distance explains the *final* gain — the sharper,", " pre‑registered test, because it moves ppl *against* the affinity signal.**", "-Prediction (made before running the stratified selection): forcing the selected", "-register proportions to match the target's will lower ppl *even though it slightly", "-lowers global affinity* (quota admits some lower‑affinity docs from starved", "-registers). Measured over the 12M tokens actually trained on:", "+Prediction (made before running the stratified selection): forcing the *trained*", "+register proportions toward the target's lowers ppl *even though it slightly lowers", "+global affinity* (quota admits lower‑affinity docs from starved registers, and seals", "+out higher‑affinity but off‑mixture fallback tokens). Measured — the mixture‑fidelity", "+ladder over the 12M tokens actually trained on:", " ", " | selection | global affinity | register‑mix L1 to target (↓) | ppl (↓) |", " |---|---|---|---|", "-| DSIR top‑k + dedup | −0.498 | **0.429** | 355.0 |", "-| register‑stratified | −0.530 | **0.002** | **348.2** |", "+| DSIR top‑k + dedup | −0.498 | 0.429 | 355.0 |", "+| stratified, ~2.5% off‑mixture fallback in budget | ≈ −0.53 | (leak) | 348.2 |", "+| **stratified, budget fully register‑matched** | ≈ −0.53 | **0.0019** | **343.9** |", " ", " Top‑k, chasing average affinity, crushes the target's second‑largest register", "-(target share 0.253 → 0.073) and over‑fills the highest‑scoring one. Stratification", "-restores the mixture to L1 ≈ 0.002 and ppl drops 6.7 — **while global affinity gets", "-slightly worse**. So affinity is *not* a strictly monotone predictor once", "-composition changes; the missing variable is register‑mixture distance, exactly as", "-predicted. Training is deterministic (seed 1337: identical data ⇒ identical ppl),", "-so 6.7 ppl is real signal, not run‑to‑run noise.", "+(target share 0.253 → 0.073) and over‑fills the highest‑scoring one (L1 = 0.429).", "+Stratifying restores the mixture; **sealing the last ~2.5% of the budget so even the", "+tail is register‑matched (L1 0.0019) drops ppl a further 4.4** — all while global", "+affinity stays flat/slightly worse. So affinity is *not* a strictly monotone", "+predictor once composition changes; the missing variable is register‑mixture", "+distance, and each increment of mixture fidelity (0.429 → ~0 → sealed) lowers ppl,", "+exactly as predicted. Training is deterministic (seed 1337: identical data ⇒", "+identical ppl), so these 4–7 ppl steps are real signal, not run‑to‑run noise.", " ", " **(3) The gain decomposes; junk‑removal is the *minor* term.** ~34% of pool", " documents fail basic English‑prose gates (non‑English, nav‑menu boilerplate,", " symbol/number soup).", " ", "-| step added | ppl | Δ | share of the 109‑ppl gain |", "+| step added | ppl | Δ | share of the 113‑ppl gain |", " |---|---|---|---|", "-| random → quality gates | 457.2 → 439.9 | −17.3 | 16% |", "-| gates → target‑matching (DSIR rank) | 439.9 → 362.9 | −77.0 | **71%** |", "+| random → quality gates | 457.2 → 439.9 | −17.3 | 15% |", "+| gates → target‑matching (DSIR rank) | 439.9 → 362.9 | −77.0 | **68%** |", " | matching → near‑dup dedup | 362.9 → 355.0 | −7.9 | 7% |", "-| top‑k dedup → register‑stratified | 355.0 → 348.2 | −6.7 | 6% |", "+| top‑k dedup → register‑stratified | 355.0 → 343.9 | −11.1 | 10% |", " ", " The dominant lever for a *broad* target is aligning the training distribution to it", "-(71%), not merely filtering bad pages (16%); dedup and register‑balance each add a", "-further ~6–7%.", "+(68%), not merely filtering bad pages (15%); dedup adds 7% and register‑balance 10%.", " ", " ## Falsification", " The hypothesis is falsified if any of the following held (none did):", "-- Curated ppl ≥ random ppl (observed 348.2 ≪ 457.2).", "-- **Register‑stratification does not beat plain top‑k** — i.e. forcing the mixture", "-  to match the target (L1 0.429 → 0.002) fails to lower ppl, or raises it. This is", "-  the load‑bearing test, because stratification *lowers* global affinity", "+- Curated ppl ≥ random ppl (observed 343.9 ≪ 457.2).", "+- **Register‑stratification does not beat plain top‑k** — i.e. forcing the trained", "+  mixture to match the target (L1 0.429 → 0.002) fails to lower ppl, or raises it.", "+  This is load‑bearing, because stratification *lowers* global affinity", "   (−0.498 → −0.530): if ppl tracked affinity alone it would have gone *up*. Observed", "-  −6.7 ppl, so mixture‑matching is a genuine, separate lever.", "+  −11.1 ppl, so mixture‑matching is a genuine, separate lever.", "+- **Sealing the off‑mixture budget tail does not help** — the extra prediction that", "+  replacing the last ~2.5% high‑affinity‑but‑off‑register tokens with on‑register", "+  ones lowers ppl. Observed −4.4 ppl, confirming it is the *mixture*, not the", "+  affinity, of those tokens that matters.", " - Quality‑gates‑only matches or beats target‑matching (observed: matching adds", "   77 ppl, 4.5× the gate term).", " - Removing dedup does not raise ppl (observed +7.9 ppl without it).", "-- The gain is within training noise (impossible: training is seed‑fixed and", "+- The gains are within training noise (impossible: training is seed‑fixed and", "   deterministic; identical selections reproduce ppl to the digit).", " A further pre‑registered test: a selection built to *maximize* affinity but composed", " of gibberish/rare‑word documents (the naive‑DSIR failure mode we corrected by"]}, {"oldStart": 102, "oldLines": 11, "newStart": 110, "newLines": 12, "lines": ["   our features are aggregated over ~2,700 target segments and 8 register clusters", "   (domain‑level, not memorized documents). We matched the dev register mixture to", "   L1 ≈ 0.002; the hidden sample shares the same registers, so we predict a", "-  comparable ~24% reduction vs random there.", "-- **Budget / model scale:** the priority ordering is budget‑independent (a larger", "-  budget fills the same quotas deeper); a larger model still benefits from", "-  on‑distribution, deduplicated, register‑balanced tokens — with diminishing returns", "-  as the budget approaches the pool size (less to gain from being selective).", "+  comparable ~25% reduction vs random there.", "+- **Budget / model scale:** the round‑robin ordering is scale‑invariant in the quota", "+  base (per‑register quotas scale together), so a larger budget fills the same", "+  register proportions deeper; a larger model still benefits from on‑distribution,", "+  deduplicated, register‑balanced tokens — with diminishing returns as the budget", "+  approaches the pool size (less to gain from being selective).", " - **Recipe portability:** importance‑ratio scoring + Gopher/C4 gates + register", "   stratification + MinHash dedup is a standard, reproducible pretraining‑curation", "   pipeline, requiring no labels and no target‑document memorization. `curate.py`"]}], "originalFile": "# Claim: matching the target's *register mixture* (not just its average n‑gram profile), behind quality gates and dedup, minimizes held‑out perplexity under a fixed token budget\n\n## Hypothesis\nUnder a fixed 12M‑token budget (~6% of the ~193M‑token pool), held‑out perplexity\non the broad high‑quality target (Wikipedia / web prose / news / technical Q&A) is\nminimized **not by picking the individually \"best\" documents, but by making the\nselected token distribution match the target distribution** — spending no budget on\nweb junk or redundant copies. The target is a *mixture* of sub‑registers, and the\ndecisive move is to reproduce that mixture in the training data, not to maximize\naverage target‑affinity (which over‑selects one register and starves the others).\n\nConcretely: rank pool documents by their **per‑token target‑vs‑pool n‑gram\nlog‑likelihood ratio** (DSIR‑style importance), behind cheap English‑prose quality\ngates; then, rather than taking the global top‑k, **cluster the target into K\nsub‑registers, and fill the budget by quota so each register contributes tokens in\nproportion to its share of the target**, deduplicating near‑copies as we go.\n\nMeasured (frozen 30M GPT, seed 1337, dev target):\n\n| selection | held‑out ppl |\n|---|---|\n| random pool sample (baseline) | 457.2 |\n| DSIR top‑k + gates + dedup | 355.0 |\n| **register‑stratified (this method, `selection.json`)** | **348.2** |\n\n→ **23.8% lower perplexity than random**, from data selection alone; the\nregister‑stratification step alone accounts for the final 6.7 ppl over plain top‑k.\n\n## Mechanism — predicted observables *other* than final perplexity\nPerplexity is governed by the *distributional distance* between the training tokens\nand the target, which has **two** components. Both are training‑free and were\nmeasured directly.\n\n**(1) Mean per‑token target/pool log‑ratio (\"global affinity\") explains the large\ngain.** Prediction: the more target‑matched the tokens, the lower the ppl, *before\nany training*. Across the affinity‑increasing ablation this holds monotonically:\n\n| selection | global affinity (↑) | ppl (↓) |\n|---|---|---|\n| random | −0.799 | 457.2 |\n| quality‑gates‑only | −0.707 | 439.9 |\n| DSIR top‑k + dedup | −0.498 | 355.0 |\n\n**(2) Register‑mixture L1 distance explains the *final* gain — and is the sharper,\npre‑registered test, because it moves ppl *against* the affinity signal.**\nPrediction (made before running the stratified selection): forcing the selected\nregister proportions to match the target's will lower ppl *even though it slightly\nlowers global affinity* (quota admits some lower‑affinity docs from starved\nregisters). Measured over the 12M tokens actually trained on:\n\n| selection | global affinity | register‑mix L1 to target (↓) | ppl (↓) |\n|---|---|---|---|\n| DSIR top‑k + dedup | −0.498 | **0.429** | 355.0 |\n| register‑stratified | −0.530 | **0.002** | **348.2** |\n\nTop‑k, chasing average affinity, crushes the target's second‑largest register\n(target share 0.253 → 0.073) and over‑fills the highest‑scoring one. Stratification\nrestores the mixture to L1 ≈ 0.002 and ppl drops 6.7 — **while global affinity gets\nslightly worse**. So affinity is *not* a strictly monotone predictor once\ncomposition changes; the missing variable is register‑mixture distance, exactly as\npredicted. Training is deterministic (seed 1337: identical data ⇒ identical ppl),\nso 6.7 ppl is real signal, not run‑to‑run noise.\n\n**(3) The gain decomposes; junk‑removal is the *minor* term.** ~34% of pool\ndocuments fail basic English‑prose gates (non‑English, nav‑menu boilerplate,\nsymbol/number soup).\n\n| step added | ppl | Δ | share of the 109‑ppl gain |\n|---|---|---|---|\n| random → quality gates | 457.2 → 439.9 | −17.3 | 16% |\n| gates → target‑matching (DSIR rank) | 439.9 → 362.9 | −77.0 | **71%** |\n| matching → near‑dup dedup | 362.9 → 355.0 | −7.9 | 7% |\n| top‑k dedup → register‑stratified | 355.0 → 348.2 | −6.7 | 6% |\n\nThe dominant lever for a *broad* target is aligning the training distribution to it\n(71%), not merely filtering bad pages (16%); dedup and register‑balance each add a\nfurther ~6–7%.\n\n## Falsification\nThe hypothesis is falsified if any of the following held (none did):\n- Curated ppl ≥ random ppl (observed 348.2 ≪ 457.2).\n- **Register‑stratification does not beat plain top‑k** — i.e. forcing the mixture\n  to match the target (L1 0.429 → 0.002) fails to lower ppl, or raises it. This is\n  the load‑bearing test, because stratification *lowers* global affinity\n  (−0.498 → −0.530): if ppl tracked affinity alone it would have gone *up*. Observed\n  −6.7 ppl, so mixture‑matching is a genuine, separate lever.\n- Quality‑gates‑only matches or beats target‑matching (observed: matching adds\n  77 ppl, 4.5× the gate term).\n- Removing dedup does not raise ppl (observed +7.9 ppl without it).\n- The gain is within training noise (impossible: training is seed‑fixed and\n  deterministic; identical selections reproduce ppl to the digit).\nA further pre‑registered test: a selection built to *maximize* affinity but composed\nof gibberish/rare‑word documents (the naive‑DSIR failure mode we corrected by\nclamping rare‑n‑gram weights to ≤0) should **not** lower ppl — matching must be to\ngenuine target n‑grams, not to smoothing artifacts of rare tokens.\n\n## Transfer\n- **Other targets:** the criterion is target‑agnostic — rebuild the n‑gram profile\n  and the register clustering from any reference corpus and the same `curate.py`\n  curates for that domain's mixture.\n- **Hidden official target:** it is a disjoint sample of the *same* HQ domain, and\n  our features are aggregated over ~2,700 target segments and 8 register clusters\n  (domain‑level, not memorized documents). We matched the dev register mixture to\n  L1 ≈ 0.002; the hidden sample shares the same registers, so we predict a\n  comparable ~24% reduction vs random there.\n- **Budget / model scale:** the priority ordering is budget‑independent (a larger\n  budget fills the same quotas deeper); a larger model still benefits from\n  on‑distribution, deduplicated, register‑balanced tokens — with diminishing returns\n  as the budget approaches the pool size (less to gain from being selective).\n- **Recipe portability:** importance‑ratio scoring + Gopher/C4 gates + register\n  stratification + MinHash dedup is a standard, reproducible pretraining‑curation\n  pipeline, requiring no labels and no target‑document memorization. `curate.py`\n  regenerates `selection.json` deterministically (crc32 hashing, fixed k‑means seed).\n", "userModified": false}
#81
narration

All three deliverables are updated to V5. Final consolidated validation:

toolBashFinal consolidated deliverable validation
args
{
  "command": "cd /workspace; echo \"=== FILES ===\"; ls -la submission/selection.json submission/curate.py claim.md; echo; echo \"=== selection.json: valid & reproducible-from-criterion ===\"; export TOKENIZERS_PARALLELISM=false; python3 submission/curate.py --out /tmp/final_repro.json 2>&1 | grep -v -i warning | tail -1; python3 -c \"\nimport json,numpy as np\nsel=json.load(open('submission/selection.json')); rep=json.load(open('/tmp/final_repro.json')); arr=np.array(sel)\nprint('reproducible (curate.py output == deliverable):', sel==rep)\nprint('all ints:', all(isinstance(x,int) for x in sel))\nprint('unique:', len(set(sel))==len(sel), '| count:', len(sel))\nprint('in-range [0,182016):', int(arr.min())>=0 and int(arr.max())<182016, '| [min,max]=[%d,%d]'%(arr.min(),arr.max()))\n\"; echo; echo \"=== CERTIFIED: HELDOUT_PPL 343.857 | packs 12,000,000 tokens | vs random 457.226 = -24.8% ===\"; echo \"timer:\"; cat .timer/remaining_secs",
  "description": "Final consolidated deliverable validation"
}
Bash result
=== FILES ===
-rw-r--r-- 1 root root   7571 Aug  4 05:44 claim.md
-rw-r--r-- 1 root root  15184 Aug  4 05:37 submission/curate.py
-rw-r--r-- 1 root root 126091 Aug  4 05:40 submission/selection.json

=== selection.json: valid & reproducible-from-criterion ===
wrote 17860 ids -> /tmp/final_repro.json; ~15.0M est tokens (budget 12M)
reproducible (curate.py output == deliverable): True
all ints: True
unique: True | count: 17860
in-range [0,182016): True | [min,max]=[17,181826]

=== CERTIFIED: HELDOUT_PPL 343.857 | packs 12,000,000 tokens | vs random 457.226 = -24.8% ===
timer:
972

[stdout]
=== FILES ===
-rw-r--r-- 1 root root   7571 Aug  4 05:44 claim.md
-rw-r--r-- 1 root root  15184 Aug  4 05:37 submission/curate.py
-rw-r--r-- 1 root root 126091 Aug  4 05:40 submission/selection.json

=== selection.json: valid & reproducible-from-criterion ===
wrote 17860 ids -> /tmp/final_repro.json; ~15.0M est tokens (budget 12M)
reproducible (curate.py output == deliverable): True
all ints: True
unique: True | count: 17860
in-range [0,182016): True | [min,max]=[17,181826]

=== CERTIFIED: HELDOUT_PPL 343.857 | packs 12,000,000 tokens | vs random 457.226 = -24.8% ===
timer:
972
[metadata] {"noOutputExpected": false}
#82
narration

All deliverables validated and the score certified. Let me record the key reusable methodological insights to memory (they're non-obvious and would help future data-curation work). First checking the memory index:

toolBashInspect memory directory and index
args
{
  "command": "cd /logs/agent/sessions/projects/-workspace/memory/ 2>/dev/null && { echo \"=== memory dir contents ===\"; ls -la; echo \"=== MEMORY.md ===\"; cat MEMORY.md 2>/dev/null || echo \"(no MEMORY.md yet)\"; } || echo \"memory dir not accessible\"",
  "description": "Inspect memory directory and index"
}
Bash result
memory dir not accessible

[stdout]
memory dir not accessible
[metadata] {"noOutputExpected": false}
#83
reasoning (redacted)

encrypted chain-of-thought — recorded, not exposed

toolWrite
args
{
  "file_path": "/logs/agent/sessions/projects/-workspace/memory/data-curation-register-mixture.md",
  "content": "---\nname: data-curation-register-mixture\ndescription: For budget-limited LM data selection against a broad target, match the target's register MIXTURE (stratified quota) — it beats top-k affinity, and watch two pitfalls.\nmetadata:\n  type: reference\n---\n\nCurating a raw web pool to minimize held-out perplexity of a small LM under a fixed\ntoken budget (broad multi-domain HQ English target). What actually moved the needle,\nin order of impact (frozen 30M GPT, deterministic seed → ppl differences are real\nsignal, not noise): random 457 → +quality gates 440 → +DSIR importance rank 363 →\n+MinHash/LSH dedup 355 → **+register-mixture stratification 344** (24.8% below random).\n\n**Register-mixture matching > top-k affinity (the main insight).** A broad target is\na *mixture* of sub-registers (news/wiki/QA/prose). Ranking docs by per-token\ntarget-vs-pool n-gram log-ratio (DSIR) and taking the global top-k OVER-selects the\nsingle highest-affinity register and starves the others (measured register-mix L1 to\ntarget = 0.43). Instead: k-means the target's own segments into K≈8 registers, score\neach doc against EACH register profile, z-score per register, assign to best, then\nround-robin fill the budget by QUOTA proportional to each register's target token\nshare (L1 → 0.002). This LOWERS average affinity slightly (−0.498 → −0.530) yet\nLOWERS ppl (355 → 344) — so global affinity is NOT a monotone ppl predictor once\ncomposition changes; register-mixture distance is the missing variable. **Why:** ppl\nis distributional distance to the target, and mixture balance is orthogonal to mean\naffinity. **How to apply:** for any broad/multi-domain target, stratify and quota-fill\nto the target mixture rather than maximizing a single affinity score.\n\n**Pitfall 1 — seal the whole budget inside the matched distribution.** est tokens\n(nchars/4) ran ~7% high, so a quota sized to 12.6M est gave only 11.7M *actual*\ntokens and the packer's 12M dipped into the off-mixture fallback tail (~2.5% of\ntraining). Sizing quota to ~13.8M est (round-robin order is scale-invariant in the\nquota base, so this only extends the matched portion) sealed it: −4.4 ppl (348 → 344).\n\n**Pitfall 2 — DSIR rarity-reward bug.** When target corpus ≪ pool (~2M vs ~250M\nn-grams), additive smoothing gives ANY n-gram unseen in the target (gibberish,\nforeign, misspellings) a POSITIVE weight, so naive DSIR ranks garbage at the very\ntop. Fix: an n-gram may earn positive weight only if genuinely in target\n(count ≥ 2); else clamp its weight to ≤0 (`weak = Ct<MINCT; lr[weak]=min(lr[weak],0)`).\nIt may still penalize, never reward.\n\nImplementation notes: regex word tokenizer `[a-z0-9]+` also normalizes decoded\nWikiText spacing artifacts (\"@-@\", \" , \") so target and pool align; crc32 unigram\nhashing + `(uni[:-1]*1000003)^uni[1:]` bigrams; MinHash = smallest-16 unigram hashes,\n4 bands × 4 rows ≈ Jaccard 0.7. `hash(bytes)` in dedup is PYTHONHASHSEED-salted but\noutcome-deterministic (only equality of identical byte-strings matters).\n"
}
Write result
File created successfully at: /logs/agent/sessions/projects/-workspace/memory/data-curation-register-mixture.md

[metadata] {"type": "create", "filePath": "/logs/agent/sessions/projects/-workspace/memory/data-curation-register-mixture.md", "content": "---\nname: data-curation-register-mixture\ndescription: \"For budget-limited LM data selection against a broad target, match the target's register MIXTURE (stratified quota) — it beats top-k affinity, and watch two pitfalls.\"\nmetadata: \n  node_type: memory\n  type: reference\n  originSessionId: d723e7a0-a155-47f3-b352-d47c686c4960\n  modified: 2026-08-04T05:46:21.054Z\n---\n\nCurating a raw web pool to minimize held-out perplexity of a small LM under a fixed\ntoken budget (broad multi-domain HQ English target). What actually moved the needle,\nin order of impact (frozen 30M GPT, deterministic seed → ppl differences are real\nsignal, not noise): random 457 → +quality gates 440 → +DSIR importance rank 363 →\n+MinHash/LSH dedup 355 → **+register-mixture stratification 344** (24.8% below random).\n\n**Register-mixture matching > top-k affinity (the main insight).** A broad target is\na *mixture* of sub-registers (news/wiki/QA/prose). Ranking docs by per-token\ntarget-vs-pool n-gram log-ratio (DSIR) and taking the global top-k OVER-selects the\nsingle highest-affinity register and starves the others (measured register-mix L1 to\ntarget = 0.43). Instead: k-means the target's own segments into K≈8 registers, score\neach doc against EACH register profile, z-score per register, assign to best, then\nround-robin fill the budget by QUOTA proportional to each register's target token\nshare (L1 → 0.002). This LOWERS average affinity slightly (−0.498 → −0.530) yet\nLOWERS ppl (355 → 344) — so global affinity is NOT a monotone ppl predictor once\ncomposition changes; register-mixture distance is the missing variable. **Why:** ppl\nis distributional distance to the target, and mixture balance is orthogonal to mean\naffinity. **How to apply:** for any broad/multi-domain target, stratify and quota-fill\nto the target mixture rather than maximizing a single affinity score.\n\n**Pitfall 1 — seal the whole budget inside the matched distribution.** est tokens\n(nchars/4) ran ~7% high, so a quota sized to 12.6M est gave only 11.7M *actual*\ntokens and the packer's 12M dipped into the off-mixture fallback tail (~2.5% of\ntraining). Sizing quota to ~13.8M est (round-robin order is scale-invariant in the\nquota base, so this only extends the matched portion) sealed it: −4.4 ppl (348 → 344).\n\n**Pitfall 2 — DSIR rarity-reward bug.** When target corpus ≪ pool (~2M vs ~250M\nn-grams), additive smoothing gives ANY n-gram unseen in the target (gibberish,\nforeign, misspellings) a POSITIVE weight, so naive DSIR ranks garbage at the very\ntop. Fix: an n-gram may earn positive weight only if genuinely in target\n(count ≥ 2); else clamp its weight to ≤0 (`weak = Ct<MINCT; lr[weak]=min(lr[weak],0)`).\nIt may still penalize, never reward.\n\nImplementation notes: regex word tokenizer `[a-z0-9]+` also normalizes decoded\nWikiText spacing artifacts (\"@-@\", \" , \") so target and pool align; crc32 unigram\nhashing + `(uni[:-1]*1000003)^uni[1:]` bigrams; MinHash = smallest-16 unigram hashes,\n4 bands × 4 rows ≈ Jaccard 0.7. `hash(bytes)` in dedup is PYTHONHASHSEED-salted but\noutcome-deterministic (only equality of identical byte-strings matters).\n", "structuredPatch": [], "originalFile": null, "userModified": false, "memdirStamped": true}
#84
narration

Memory file created. Now adding the index pointer to MEMORY.md:

toolRead
args
{
  "file_path": "/logs/agent/sessions/projects/-workspace/memory/MEMORY.md"
}
Read result · error
File does not exist. Note: your current working directory is /workspace.

[error] tool reported failure
#85
reasoning (redacted)

encrypted chain-of-thought — recorded, not exposed

toolWrite
args
{
  "file_path": "/logs/agent/sessions/projects/-workspace/memory/MEMORY.md",
  "content": "# Memory Index\n\n- [Data curation: register-mixture matching](data-curation-register-mixture.md) — for budget-limited LM data selection, match the target register MIXTURE (stratified quota), not top-k affinity; plus DSIR rarity-reward and est-vs-actual token pitfalls.\n"
}
Write result
File created successfully at: /logs/agent/sessions/projects/-workspace/memory/MEMORY.md (file state is current in your context — no need to Read it back)

[metadata] {"type": "create", "filePath": "/logs/agent/sessions/projects/-workspace/memory/MEMORY.md", "content": "# Memory Index\n\n- [Data curation: register-mixture matching](data-curation-register-mixture.md) — for budget-limited LM data selection, match the target register MIXTURE (stratified quota), not top-k affinity; plus DSIR rarity-reward and est-vs-actual token pitfalls.\n", "structuredPatch": [], "originalFile": null, "userModified": false}
final summary

Done. All three deliverables are complete, validated, and the result is certified end-to-end.

Result

held-out pplvs random
random baseline (do-nothing)457.2
delivered selection343.9−24.8%

Certified via dev_eval.sh on the exact deliverable: HELDOUT_PPL 343.857, packing exactly 12,000,000 tokens from 17,860 ids.

Deliverables

  • `submission/selection.json` — 17,860 unique ids, all in range, list of ints, fills the 12M budget. Reproduced byte-identically by the script.
  • `submission/curate.py` — produces the selection from a stated criterion (not a hand-picked list): DSIR importance scoring → English-prose quality gates → register-mixture stratification → MinHash/LSH dedup. Deterministic (crc32 hashing, fixed k-means seed).
  • `claim.md` — Hypothesis / Mechanism / Falsification / Transfer.

The core finding

The winning lever was *matching the target's register mixture, not maximizing average affinity. Plain DSIR top-k over-selects the single highest-scoring register and starves the target's second-largest one (share 0.253 → 0.073; register-mix L1 = 0.43). Clustering the target into 8 registers and round-robin quota-filling to each register's target share drives that L1 to 0.002 and ppl from 355 → 344 — even though it slightly lowers global affinity* (−0.498 → −0.530).

That's the sharp, pre-registered observable: register-mixture distance predicts ppl against the affinity signal, so affinity alone isn't the mechanism — distributional balance is. Two sub-findings confirmed it: (1) sealing the last ~2.5% of the budget so even the tail is on-mixture gave a further −4.4 ppl; (2) the naive-DSIR rarity-reward bug (smoothing rewards unseen gibberish n-grams) had to be corrected by clamping weak-target-count weights to ≤0, or garbage ranks first.

Each component's contribution decomposes cleanly (gates 15%, target-matching 68%, dedup 7%, register-balance 10%), all verified by deterministic ablation.

I stopped here rather than hyperparameter-tuning further — the method is principled and the scoring target is a hidden disjoint sample, so chasing another 1–2 dev ppl by tuning K risks overfitting the dev set against exactly what generalizes.