# Phase 01 — tokenizer results Trained on 2,119,719 TinyStories documents (full train split); measured on 2,000 held-out validation documents. Measured on the TinyStories **validation** split, which no tokenizer was trained on. Holding out by document rather than by offset matters: a random-offset split leaks the tail of a training document into validation. ## The comparison | vocab | actual | fertility (tok/word) | bytes/token | tokens/doc | embedding params | % of 12.6M budget | |---|---|---|---|---|---|---| | 2,048 | 2,048 | 1.399 | 3.67 | 217.3 | 786,432 | 6.2% | | 8,192 | 8,192 | 1.226 | 4.19 | 190.4 | 3,145,728 | 25.0% | | 32,768 | 32,768 | 1.214 | 4.23 | 188.5 | 12,582,912 | 99.9% | ### What the embedding column means At `d_model = 384` and a 12.6M parameter budget, a 32,768 vocabulary costs 12,582,912 parameters — **100% of the whole model**, tied. Untie the output projection and it is double that. The model would be almost entirely vocabulary and almost no transformer, which is why small models use small vocabularies. ## Sequence-length inflation | vocab | tokens/doc | vs 8k | consequence at fixed seq_len | |---|---|---|---| | 2,048 | 217.3 | 1.14x | 0.88x the documents per batch | | 8,192 | 190.4 | 1.00x | 1.00x the documents per batch | | 32,768 | 188.5 | 0.99x | 1.01x the documents per batch | This is the confound Ablation 1 has to control for. A 2k model at a fixed `seq_len` sees fewer *documents* per step than a 32k model, so a raw comparison of final loss is not a comparison of the vocabulary alone. ## Dead vocabulary entries Entries occurring fewer than 100 times in the held-out set: | vocab | never seen | seen < threshold | dead total | dead % | live | |---|---|---|---|---|---| | 2,048 | 222 | 1,148 | 1,370 | 66.9% | 678 | | 8,192 | 2,266 | 5,482 | 7,748 | 94.6% | 444 | | 32,768 | 26,228 | 6,100 | 32,328 | 98.7% | 440 | LEARNING.md 1.6 cites a TinyStories reproduction finding roughly 42k of a ~50k vocabulary effectively dead. The table above is this project's own measurement; see the discussion in `results/phase01.md` for whether it confirms or refutes that. ## Naive vs fast The hand-written implementation from `slm/tokenizer/bpe_naive.py`, on 10.0MB: - 256 merges in **730.1s** (2852ms per merge) - projected to 32,512 merges: **~25.8 hours** (an upper bound — per-merge cost falls as the stream shortens) - the Rust implementation trained the same 32,768 vocabulary on the **full** corpus in 1054s The naive loop is O(corpus) per merge: it rescans and rewrites every sequence to apply one merge. Production implementations pre-tokenize on a regex and count over a word-frequency dictionary instead of the raw stream, so each merge touches unique words rather than every occurrence.