In this lesson: what a language model actually receives when you type to it. Not letters or words, but a list of numbers made by a tokenizer. You'll see why the same sentence can cost far more in one language than in another, and why models miscount letters. Read the lesson and take the 5-question quiz: each question has a hint if you get stuck, and its explanation shows once you get it right (all of them at full marks). Pass the quiz to finish the lesson and earn its badge.
1. Two sentences, one meaning
We gave two sentences with the same meaning to two tokenizers: DeepSeek-V3's, from a current model trained on a lot of Chinese, and GPT-2's from 2019, which the small English model distilgpt2 still uses. Before you look: the Chinese sentence has 16 characters and the English 51. Which do you think takes more tokens, and does the tokenizer change the answer? Here is what came out, with each sentence's tokens turned back into their text (decoded) one by one (the full lists are in section 6):
Same meaning: 11, 9 or 34 tokens
Both tokenizers cut the English sentence into the same 11 tokens: almost one per word, with the space glued to the front of the word (" exam", " class"). DeepSeek-V3's cut the Chinese sentence into 9 tokens, mostly whole words (期末考试, 庆祝). GPT-2's turned the same 16 characters into 34 tokens, and most of them printed as �: same meaning, three times the tokens of the English. The rest of this lesson explains why, starting with the small English tokenizer.
2. A tokenizer cuts text into pieces
A model can't read text. It reads numbers. The tokenizer is the step before the model. It cuts the text into pieces called tokens, looks each one up in a fixed vocabulary, and hands the model a list of ids, one integer per piece. distilgpt2's vocabulary has 50,257 entries. " exam" is id 2814, wherever it appears.
Think of an exam marked by candidate number: the marker sees 2814, not your name or anything about you. The model only ever gets the numbers: for our sentence, the eleven numbers 3260, 262, 938, 2814, 11, 616, 1398, 3066, 284, 10648 and 13.
The model gets ids, not text
3. Where the pieces come from: BPE
The vocabulary isn't written by hand. It is learned with byte-pair encoding (BPE):
- Start from single bytes, the numbers 0–255 that computers store text as (one per English letter).
- Find the pair that sits side by side most often in a big pile of text.
- Merge it into a new token, and repeat tens of thousands of times.
In the figure's toy pile, three merges make "test" one token. Frequent real words end up as one token too (" celebrate"). Rarer ones are built from pieces: "unbelievable" is un|bel|iev|able, four ids. These pieces are called subwords. So the vocabulary is a record of what was common in the text the tokenizer was built from.
BPE: merge the most frequent pair, repeat
4. Why Chinese and emoji cost more
distilgpt2 uses GPT-2's tokenizer, built for English web text. A common Chinese character is 3 bytes, and few Chinese characters were common enough for all 3 of their bytes to be merged into one token, so most stay as 2 or 3 tokens, each holding part of a character. A token that holds only part of a character's bytes isn't a character, which is why it prints as �. "一" and "。" happened to be common enough to get a token of their own. An emoji like 🍓 is 4 bytes and takes 3 tokens; "体育考试" (PE test) takes 9, against 2 for "PE test".
Tokens are what a model is measured in. How much text it takes in at once (its context window), and what it costs are both counted in tokens, not words. So with a tokenizer like this one, a student who writes in Chinese pays about three times as much for a sentence like ours and fits about a third as much text in the same window. Today's Chinese-trained models close that gap. Their tokenizers learned their merges from a lot of Chinese text, so common characters and words get tokens of their own: DeepSeek-V3's takes 9 tokens for our Chinese sentence and Qwen3's 10, against 11 for the English, and "体育考试" is 2 tokens (体育|考试) in both. When you choose a model for an app in Chinese, its tokenizer is part of the price.
Bytes that weren't merged cost more tokens
5. Why it can't see letters
"strawberry" is st|raw|berry: three ids, 301, 1831 and 8396. Nothing in those numbers says how many r's there are. A model only knows a token's spelling indirectly, from patterns in its training text, so counting letters is harder for it than it looks. When a model counts letters for you, check it: it sees three numbers, not ten letters. And " strawberry" with a space in front is a different, single token, id 41236: the same word can have several ids. "Strawberry", with a capital S and no space, is cut again, St|raw|berry: the vocabulary matches exact characters, capitals and spaces included.
Here is a wrong explanation you might read: "The model sees every letter in each word, so counting the r's in strawberry is easy for it." Asking the tokenizer for the ids of "strawberry" catches it: it gives three ids with no letters in them. Another: "Every Chinese character is one token, so Chinese always takes fewer tokens." The run in section 1 breaks it both ways: GPT-2's tokenizer took 34 tokens for 16 characters, and DeepSeek-V3's took 9, fewer than one per character. "Always" is a warning word; one counter-example is enough.
Ids carry no letters
6. Look at the tokens and ids
Every distilgpt2 count and list above comes from one run of its tokenizer on our own computer. For each piece of text we asked it for two things: the ids the model really sees, and the text behind each id when that id is turned back into text on its own. A piece that holds only part of a character's bytes has no text of its own, so it shows as �. The vocabulary has 50,257 entries.
| Text | Tokens | Ids | The pieces |
|---|
| "strawberry" | 3 | 301, 1831, 8396 | "st", "raw", "berry" |
| " strawberry" (a space in front) | 1 | 41236 | " strawberry" |
| "unbelievable" | 4 | 403, 6667, 11203, 540 | "un", "bel", "iev", "able" |
| "PE test" | 2 | 11401, 1332 | "PE", " test" |
| "体育考试" | 9 | 19526, 241, 164, 224, 110, 32003, 225, 46237, 243 | nine pieces, all � |
| 🍓 | 3 | 8582, 235, 241 | three pieces, all � |
The English sentence of section 1 came back as its 11 pieces, from "After" to "." with the spaces glued to the words; the Chinese one as 34 pieces, every one � except 一 and 。. The same numbers as sections 1 to 5: 11 tokens against 34, three ids for "strawberry", one for " strawberry", and 9 for 体育考试.
Then we gave the same text to two of today's Chinese-trained tokenizers, DeepSeek-V3's and Qwen3's, downloaded from the Hugging Face hub, the site where models are shared. We counted only the text itself, with no marker tokens (such as a start-of-text marker) added around it:
| Tokenizer | The English sentence | The Chinese sentence | 体育考试 |
|---|
| GPT-2's (distilgpt2) | 11 | 34 | 9 |
| DeepSeek-V3's | 11 | 9: 期末考试 · 一 · 结束 · , · 我们 · 班 · 决定 · 庆祝 · 。 | 2: 体育 · 考试 |
| Qwen3's | 11 | 10: 期末 · 考试 · 一 · 结束 · , · 我们 · 班 · 决定 · 庆祝 · 。 | 2: 体育 · 考试 |
All three cut the English into the same 11 pieces. Both Chinese-trained tokenizers keep whole words: 9 and 10 tokens for the Chinese sentence, and 体育考试 is 2.
The ids the model sees