AI does not read letters. It reads chunks.
Token Chopper
Loading the real tokenizer…
Letters you see
10
Chunks the AI sees
0
Ten letters, but only a few chunks. The AI never sees the r's on their own.
Why it cannot count the r’s
- Letters
- Chunks
- Miscount
- Cost
You see 10 letters.
It sees chunks, not letters.
Next time you use ChatGPT
Do not ask it to count. Ask it to use a counter.
- Instead of
- How many words are in this paragraph?
- Try
- Write and run code that counts the words in this paragraph.
+Where do the chunks come from?Nobody chose them. They were counted into existence.
A model has a fixed vocabulary. The encoding used here has 199,998 entries, and every piece of text you send has to be expressed in them. That vocabulary was not written by linguists. It was grown, by an algorithm with no notion of words, prefixes or meaning.
It starts with raw bytes: no words, not even letters, just 10 separate things for a 10-letter word. Then it repeats one move. Find the pair of neighbours that occurs most often across the whole training corpus, and glue it into a single new entry. Do that a couple of hundred thousand times and the frequent chunks of English end up as single units. Everything rare stays in fragments.
Where the tokenizer starts. 10 bytes, nothing grouped
Best pair available: e + r → er
That chunk is token 259 out of 199,998. one of the first thousand it ever learned. Of every pair it could have joined here, this one was the most common, so it goes first.
Real o200k_base merges, in the order the tokenizer performs them.
Watch unbelievable in particular. A human would cut it un·believ·able. The tokenizer produces un·bel·ievable, because bel happened to be commoner than the meaningful piece. The split is a frequency accident, and the model has to work from it anyway.
And Ashwatthama shatters into 4pieces. Nothing about that name was common enough to be worth an entry, so it arrives as debris. Rare names, technical terms, new coinages and most of the world’s languages all arrive this way.
+Three surprises: spaces, numbers, languagesThe same word can cost three times as much.
1. The leading space
strawberry costs 3 tokens. A space then the same word costs 1. The space is part of the token after it, so the word mid-sentence and the word at the start are different objects to the model.
2. Numbers
Digit runs are cut into groups of at most three, then merged by frequency. A million arrives as 100|000|0. The boundaries have nothing to do with place value.
3. Your language
2.5×
The same sentence costs 8 tokens in English and 20in Hindi. You pay per token, your context fills per token, and you wait per token. So the same conversation is measurably more expensive in most of the world’s languages.
+What is actually going onIf the split is this crude, how does it ever work?Because the model never needed the letters. It needed something it could count, and chunks are countable.
A tokenizer is not trying to understand the word. It is trying to turn unlimited text into a finite alphabet the model can do arithmetic on, without ever failing on an input it has not seen. Byte-pair encoding does that with one guarantee: since it starts from raw bytes, any string can be expressed, worst case one token per byte. Emoji, code, a language the model has never met, a password. All of it can be represented.
The price is that the chunks carry no promise of meaning. Whatever structure a word has, the model has to reconstruct from the pieces it was handed, using what usually follows what. It mostly manages. Where it does not, the failure looks stupid rather than subtle: counting letters, spelling backwards, rhyming, and arithmetic on long numbers.
Take it apart yourself: What an LLM actually isBeat the Predictor · 7 min. Optional.
+What is actually going onWhy does the same word cost different amounts in different places?Because the token depends on what sits next to it. Spacing, capitals and punctuation all change the split.
The merge loop runs over the text as written, so anything that changes the neighbours changes the outcome. strawberry, strawberry, Strawberry and STRAWBERRY are four different sequences of ids, not four forms of one word. The model learns to treat them similarly because they appear in similar places, not because anything told it they were related.
This is also why the same paragraph can cost noticeably more after a reformat, and why stripping a trailing space from a prompt sometimes changes an answer. Nothing mystical is happening. A different split is a different input.
Take it apart yourself: Context is everythingContext Budget · 7 min. Optional.
+Watch somebody explain itWhere tokens sit in the whole pipeline, in a few minutes.
Optional: watch someone explain it
Large Language Models explained briefly
3Blue1Brown
Where tokens sit in the whole pipeline, in a few minutes.
+Go and try this on a real assistantTwo questions, and it contradicts itself between them.
Go and try this
Make an assistant contradict itself about spelling
Ask any assistant: how many r’s are in strawberry? Then ask it to spell the word out one letter at a time, numbering each, and count again.
Most will get it wrong the first way and right the second. Forcing the letters onto separate lines forces them into separate tokens. You have handed it the thing the tokenizer took away.
What to watch for: That the confident wrong answer and the correct one arrive in the same tone. Nothing in how it writes tells you which one you are looking at. That is the habit worth taking away, and it is what the next chapters are about.
+Check yourselfTwo beats. It marks itself, and nothing is sent anywhere.
Pair each piece of text with the way the tokenizer actually cuts it.
Tap one from the pool, then tap the row it belongs to.
- "strawberry"
- " strawberry"
- "unbelievable"
- "1000000"
The same sentence in English or in Hindi. Which costs more to send?
Sources
- tiktoken, the BPE tokeniser for OpenAI models
OpenAI
The o200k_base encoding behind every split, token id, merge and score on this page.
MIT
- gpt-tokenizer
Bane Sesevic
The JavaScript port that runs the tokenizer in your browser, and the published rank table the merge replay is driven from.
MIT
- Neural Machine Translation of Rare Words with Subword Units
Sennrich, Haddow & Birch (ACL 2016)
The paper that introduced byte-pair encoding for language models. It is the algorithm replayed in the figure.
- Language Model Tokenizers Introduce Unfairness Between Languages
Petrov, La Malfa, Torr & Bibi (NeurIPS 2023)
Independent measurement of the language cost gap shown in the chart.