albedo_training / README.md
cryptoDev23's picture
SN97 training set: 41,463 rows + runbook, analysis, local scorer
7e7bd6a verified
|
Raw History Blame Contribute Delete
9.04 kB
# duel_corpus — credit-assigned SFT data from SN97 duel artifacts
Built from the 200 eval runs the dashboard still exposes. The core idea: the
judge answers questions about a whole trajectory, but 81% of its explanations
name the `CANDIDATE OUTPUT N` block that satisfied each question. That citation
is the only per-turn reward signal SN97 emits, and it is free — other miners'
GPU time already paid for it.
## Pipeline
| step | script | output |
|---|---|---|
| 0 | `harvest_all.py` | `raw/` — 400 artifacts, 5.93 GB, 19,811 scored samples |
| 1 | `build_turn_corpus.py` | `turns.jsonl` (506,201 turns), `samples.jsonl` (39,622 sides) |
| 2 | `select_targets.py` | `sft_duel_credit_v1.jsonl` — 4,751 rows |
| 4 | `validate.py` | `sft_duel_credit_v1.clean.jsonl` — **4,664 rows, 22,762 train turns** |
Re-runnable end to end; the harvest resumes if interrupted.
## Output format
Drop-in for `sft/data.py`: a full `messages` list where assistant turns that
should receive gradient carry `train: true`. Everything else stays as context,
which is the point — the model must see the states it will generate from,
including the failed ones.
Each row also carries `train_meta` (per-turn earned weight, tags, `is_recovery`,
`cmd_kind`) so composition can be reweighted at training time without a rebuild.
## What the corpus says
Turn credit is not uniform. Mean credit earned by a turn, by command:
| command | share of turns | mean credit | % earning |
|---|---|---|---|
| `cat -n` | 9.8% | 1.350 | 44.3% |
| `sed -n` | 14.1% | 1.165 | 40.6% |
| `cat` | 14.6% | 0.866 | 37.0% |
| edit | 1.9% | 0.716 | 41.3% |
| `grep -r` | 4.2% | 0.487 | 30.0% |
| `pytest`/`python` | 11.2% | 0.247 | 21.8% |
| `find`/`ls` | 10.4% | 0.186 | 18.1% |
| submit | 0.4% | 0.153 | 9.5% |
Displaying file content earns 5-7x what `find`/`ls`/`pytest` earn, and those two
low-value kinds are 21.6% of all turns in the wild. That is the waste.
Credit is also strongly front-loaded — turn 1 earns 1.523, turn 15 earns 0.186.
The first three turns are where a sample is won.
Exposure bias is measurable here: 19.2% of turns get a failed observation, and a
turn following a failure earns credit only 18.8% of the time against a 30.3%
baseline. A single bad command costs ~40% of the next turn's expected credit.
## Composition of the built dataset
24,472 selected train turns before validation, 22,762 after:
- command mix: `cat -n` 18.1%, `sed -n` 16.9%, `cat` 16.2% (51% display), `find`/`ls` down to 5.9%
- earned tags: grounding 35.6%, explore 29.6%, claims 20.9% — 86% on the three tags carrying 89% of duel weight
- 2,841 recovery turns (earned credit immediately after a failed observation), present in 41% of rows
- source sides average 0.941 score, deduped to one side per `sample_id`
- 4.2M trainable tokens; mean sequence 9,394 tokens, 0.4% over a 32,768 limit
## Gates applied
Run with the validator's own `loop_check` and `observation_format`:
- source side must be non-looped, score >= 0.85, `dup_cmd_ratio` <= 0.45, `max_cmd_run` <= 3
(validator kills at 0.65 / 6, so there is margin)
- a repeated command never receives gradient
- train turns must contain exactly one bash block, no unclosed `<think>`, no
duplicate command among targets — violations are demoted to context, not dropped
- 100% of train turns tokenize with `sft/data.py` and their label span decodes
back to exactly the assistant content
## The escape set — `build_escape_set.py`
The Phase 2 filter above selects per *side*, and that quietly recreated the
problem it was supposed to fix: requiring score >= 0.85 and low repetition threw
out every trajectory that demonstrates being stuck. It kept 8,021 of 39,622
sides and captured only 16.8% of the available recovery material (2,805 of
16,650 turns).
`build_escape_set.py` selects per *turn* instead. A turn qualifies when it
earned judge credit and the state before it was bad — previous observation
failed, or previous commands were repeating. The degenerate prefix is kept
verbatim with no gradient; only the escape trains. A side that scored 0.3
overall still contributes its one good escape, because per-turn credit is
verified per-question regardless of the side's total.
`sft_escape_v1.jsonl` — 13,979 rows, 7,655 unique samples:
- **73.7% come from sides Phase 2 rejected** — that is the material that matters
- 98.3% follow a failed observation, 1.8% follow a repeat run
- prior consecutive failures: mean 1.29, max 10
- escapes are mostly reads: `cat` 19.2%, `grep` 18.5%, `cat -n` 14.1%, `sed -n` 13.5%
- 100% tokenize clean, median 8,006 tokens, 1.8% over 32,768
## Combined output
`sft_final_v1.jsonl` — 18,643 rows, 36,741 gradient-bearing turns, 861 MB.
4,664 credit rows (what winning looks like) + 13,979 escape rows (how to get
out of trouble). Rows carry `mix` = `credit` | `escape` for reweighting.
## Judge-free local scorer
SN97 scores a trajectory by asking an LLM judge yes/no questions. The questions
are *in the artifacts* — what we lack is only the judge. So `build_local_scorer.py`
featurizes each question against a trajectory and `fit_local_scorer.py` fits a
classifier to answer it. Train/test split is by eval run, so evaluation never
sees a duel it was fit on.
| step | script | output |
|---|---|---|
| features | `build_local_scorer.py` | `scorer_features.jsonl` — 39,622 sides, 565k questions |
| fit | `fit_local_scorer.py` | `local_scorer.pkl` (gradient boosting) |
| use | `score_local.py --build-index` then `--trajectories mine.jsonl` | `local_scores.jsonl` |
Requires the venv at `/root/.venv-tok` (numpy, scikit-learn).
### Measured accuracy, held out
| what | number |
|---|---|
| per-question accuracy / AUC | 0.771 / 0.849 |
| per-side score correlation | pearson 0.727, **MAE 0.140** |
| paired same-sample: picks the better side | 70.0% |
| duel margin sign agreement | 73.3% |
| per-model ranking (57 models) | spearman 0.561 |
| loop detection | **exact** — runs the validator's own `loop_check` |
| catastrophic flag at <0.35 | precision 0.820, recall 0.384 |
### What this is and is not good for
**Trustworthy:** catching loops before you submit (exact, and it is what banned
two of your hotkeys); flagging which specific samples the model falls apart on
(82% precision), which matters because 70% of the gap to the king lives in
samples scoring under 0.34.
**Only with enough samples:** the per-sample error is 0.207, so a 100-sample run
gives +/-0.041 at 95% — wider than the 0.025 margin that decides a duel. It takes
**500+ paired samples to resolve 0.025**, 1000 to be comfortable. Generate on
500–1000 samples, not 100.
**Not trustworthy:** any single sample's score (MAE 0.140), and ranking two
models that are genuinely close.
End-to-end check on a held-out run: predicted 0.5804 against the judge's 0.5779.
## Window B — `../mini_coder/mine_window_b.py`
Duel artifacts stop at turn 16, so they contained only **243** escapes out of a
repeat run and nothing at all past the cutoff where pre-eval's tail judge looks.
`mini-coder` (`ricdomolm/mini-coder-trajs-400k`, 9.4 GB, 396,382 trajectories)
covers exactly that region: mean 33 assistant turns, and 99.9% end in a submit.
Two products, suffix-masked the same way:
| product | rows | what it teaches |
|---|---|---|
| `escape` | 6,820 (**28x** the duel corpus; 41.3% past turn 16) | a command repeats, a *different* command breaks out — gradient on the escape only |
| `finish` | 177,559 mined, capped to 16,000 | concrete non-repeating tail work on verified tasks, plus the closing submit |
`finish` is capped at one row per instance because 177,559 rows come from only
20,267 instances; uncapped it would swamp the duel material and pull the model
toward mini-coder's style in the window that decides duels.
## Final mix — `build_final_mix.py` -> `sft_final_v2.jsonl`
**41,463 rows, 59,561 gradient-bearing turns, 1.69 GB.**
| mix | rows | share | train turns | window | purpose |
|---|---|---|---|---|---|
| `credit` | 4,664 | 11.2% | 22,762 | 1–16 | what earns judge credit |
| `escape_duel` | 13,979 | 33.7% | 13,979 | 1–16 | recovery from a failed command, on-policy |
| `escape_mini` | 6,820 | 16.4% | 6,820 | 5–32 | breaking out of a repeat run |
| `finish_mini` | 16,000 | 38.6% | 16,000 | 17–32 | surviving to a submit in 32 turns |
Every row carries `mix`, so ratios can be changed without a rebuild.
Tokenizer validation across all four mixes: **100% of sampled train turns
encode cleanly and their label spans decode back to exactly the assistant
content.** Median sequence 7,798–9,110 tokens; only `escape_duel` has material
overflow past 32,768 (2.0%).
### Coverage against the two gates
| failure | share of chelsea-blue's pre-eval failures | covered by |
|---|---|---|
| looping | 5/10 | `escape_mini` (6,820, 41% past cutoff) + `escape_duel` |
| no submission / no edits in 32 turns | 2/10 | `finish_mini` (16,000, 8,776 submit turns available) |
| duel score gap | — | `credit` + `escape_duel` |