What has been built so far, drawn out: the memory budget, the data pipeline, the leaks we found in GitHub data, and a live tokenizer you can train by clicking.
Training needs far more memory than the model itself. For every parameter the GPU holds the weight, its gradient, and two numbers the Adam optimizer keeps. That is 16 bytes per parameter before any activations.
We predicted 192 MB for a 12.6M-parameter test model and measured 208 MB. The 8.5% gap is activations held for the backward pass. That rule of thumb is why 125M parameters is our ceiling on 8 GB.
The model never sees files. It sees long rows of numbers. This pipeline turns 1.2 million GitHub Python files plus English articles into those numbers, removing anything we cannot legally share or that would let the model cheat on its exam.
We hold back 0.5% of repositories as an exam the model never studies. But people fork projects and copy files between them, so an exam file often had a near-twin in the study material under another project's name.
We measured it by checking whether the rare lines in each exam file (lines that appear in 5 files or fewer across all of GitHub) also show up in the study set. A rare line on both sides means a copy.
Splitting by repository helped a little. Removing near-duplicates with fingerprints (MinHash) helped a lot. We needed both, because each one catches a kind of copy the other misses.
A model can only read numbers, so text has to be cut into pieces called tokens, each with an id. The tokenizer learns which pieces to use by counting. It starts from raw bytes (256 possible values, so any text in any language works) and repeats one move thousands of times.
This runs the same algorithm as stages/01_tokenizer/bpe.py. The highlighted pieces are the pair that will merge next. Press Merge once and watch them fuse into one blue token. It opens with 12 merges done.
Once trained, the tokenizer handles text it has never seen. It starts from bytes and applies the merges it learned, always the earliest-learned one first. This rebuilds the pieces the same way training did.
The steps on the right use the merges from the lab above, so they change as you train more. Type anything.
The step that cuts text before merging decides what can never be merged. For numbers there are three common choices. If 2024 is one token, the digit 2 gets a different id depending on which number it sits in, which makes numbers harder for a model to learn.
We trained all three on 36 MB of real Python and English and measured them on code they never saw. Splitting every digit costs only 1.3% in compression and gives every digit a stable id, so that is the one we kept.
x = 2024 + 1234567; port=8080. The kept rule is marked.A good tokenizer fits more text into each token, so the model sees more code per step. We measured bytes of held-out Python per token.
GPT-2's tokenizer has six times our vocabulary and still loses on code by a wide margin. It was trained on web pages and never learned tokens for runs of spaces, so every space of Python indentation costs it a whole token. On English it still wins, as you would expect.
Doubling our vocabulary to 16,384 would gain 6% more but add 4.2M parameters, about a sixth of the first model. We kept 8,192.