Text becomes tokens
A language model never sees letters or words. It sees tokens, chunks learned by gluing the most common pairs together. Train a tokenizer and watch your text get chopped.
Before a language model can read a single word, the text has to become numbers. The step that does that is the tokenizer, and it shapes more of a model’s behaviour than most people realise.
Why not just use letters? Too many tiny steps: a page would be thousands of them, and the model would spend its effort spelling. Why not whole words? There are too many words, new ones appear every day (skibidi, GPT-5, your username), and the model would choke on anything it had never seen.
The answer most modern models use sits in between: subword tokens, learned by an algorithm borrowed from data compression called byte-pair encoding (BPE).
- Start with every single character as its own token.
- Count every pair of neighbouring tokens in a big pile of text.
- Glue the most common pair into one new token.
t+h→th. - Repeat, thousands of times.
th+e→the.+the→the.
Common words end up as one token. Rare words get split into familiar pieces. Nothing is ever unknown: in the worst case a word falls back to single characters.
Train one
This tokenizer has learned up to 400 merges from a short story about a panda learning tech. Drag the slider to see the text with no merges, then more and more. Hover a chip to see its token id, the number the model actually receives.
Try typing things the story never contained: a long made-up word, a number like 1234567, some code, another language. They break into many small tokens. That’s the tokenizer telling you this text was rare in its training data.
A word the tokenizer has never seen appears. What happens?
That's BPE's big advantage: it has no unknown words, only unfamiliar ones, which cost more tokens. The original subword paper pitched it exactly this way - encoding rare and unknown words as sequences of subword units.
Why does it matter how many tokens your text becomes?
Everything about running a model is counted in tokens: how much fits in the context window, how long generation takes, and usually the price. Languages and formats that were rare in the tokenizer's training data cost more tokens for the same meaning.
Sources
Missions and quizzes above earn their own XP. This marks the lesson done.