Topic 5
Token counts are not word counts
Because the vocabulary is learned from a training corpus, text that looks like that corpus compresses into few tokens and text that does not falls apart into many small ones. All counts on this page come from tiktoken 0.14.0.
Predict first
Language
English · The weather is nice today.
Spanish · Hoy hace buen tiempo.
Hindi · आज मौसम अच्छा है।
Japanese · 今日はいい天気です。
Same sentence, different token counts. Roughly the same sentence in four languages. Older vocabularies spend many more tokens on Hindi; the larger o200k_base vocabulary closes most of the gap.
Counts measured with tiktoken 0.14.0.
The newer o200k_base encoding, with a vocabulary twice as large, brings Hindi down to 5. Chip Huyen's AI Engineering reports the same pattern at scale: in a benchmark of GPT-4's tokenizer on a multilingual dataset, Hindi and Burmese needed several times more tokens than English to say the same thing, which makes them proportionally slower and more expensive.
(A word count is not even defined for Japanese here: the sentence has no spaces, so splitting on whitespace returns one "word".)
Numbers
Quick check
| Text | gpt2 pieces | o200k_base pieces |
|---|---|---|
2026 | 20 26 | 202 6 |
1234567 | 123 45 67 | 123 456 7 |
In cl100k_base and o200k_base, the pre-tokenization pattern (visible in tiktoken's source) caps digit runs at three, and every 1- to 3-digit string is a single token. GPT-2's pattern takes the whole digit run and lets BPE split it however its merges dictate.
Whitespace and code
| Text | gpt2 | cl100k_base | o200k_base |
|---|---|---|---|
a + four spaces + b | 5 | 3 | 3 |
| two tab characters | 2 | 1 | 1 |
| a two-line Python function (40 characters) | 18 | 16 | 16 |
gpt2 spends one token per extra space, which makes indented code expensive. The later encodings have tokens for runs of whitespace, a choice that matters for code where indentation is everywhere.
Capitalization and spacing
hello, hello, Hello and Hello are four different single tokens with four unrelated IDs (in o200k_base: 24912, 40617, 13225, 32949). HELLO is two tokens, HEL and LO. To the model, these are different symbols whose relationship it has to learn from data.
A rough rule, used carefully
For ordinary English prose, a token is a bit shorter than a word: AI Engineering gives roughly 100 tokens per 75 words for GPT-4, and the tiktoken README says a token averages about 4 bytes. Those averages break down for non-English text, code, numbers, tables and JSON. When the number matters, count with the real tokenizer.