You paste a two-page contract into ChatGPT and it tells you the message is too long. Your API bill is counted in something called tokens. And when you ask a chatbot how many r's there are in "strawberry", it confidently says two.
Three unrelated annoyances, one cause: before the model does anything, a separate program chops your text into pieces called tokens, and the model never sees a single letter.
A token is a chunk of text with an ID number
Think of a warehouse where every item has a shelf number and the staff can only say "shelf 4231", never "the small blue box". A language model works with numbers, so text is converted into numbers going in, and back into text coming out.
The program that converts is the tokenizer. Each chunk it produces is a token; the full list of chunks it knows is its vocabulary, anywhere from about 50,000 to a few hundred thousand entries; and each chunk's number is its token ID, which is all the model actually receives.
Here is a real example from OpenAI's documentation. The string ChatGPT is great! becomes six tokens:
1["Chat", "G", "PT", " is", " great", "!"]Notice three things, because they keep mattering. The space rides with the following word — the vocabulary holds " is", not "is" plus a space. Capitalization is part of the entry, so "Chat" and "chat" are different tokens. And unusual strings get sliced: ChatGPT isn't in the vocabulary as one piece, so it falls apart into pieces that were frequent enough in training to earn their own slots.
The tokenizer is trained first, before the language model, and then frozen. It isn't part of the neural network, and it doesn't improve as you chat.
Why not whole words? Why not single letters?
Both obvious designs fail, and seeing why makes the real one feel inevitable.
Whole words means a vocabulary of hundreds of thousands — plus names, typos, product codes, new slang — and it's still incomplete, so anything missed needs an awkward "unknown" fallback. Related words also become unrelated entries: book, books and bookstore each need their own slot despite sharing a core of meaning.
Single letters fixes coverage with about a hundred entries, but a thousand-word page becomes roughly six thousand separate steps, each carrying almost no meaning. The model would spend its capacity relearning that e usually follows th.
Real tokenizers take the middle path, called subword tokenization:
| Design | Vocabulary size | Sequence length | Where it breaks |
|---|---|---|---|
| Whole words | Enormous, still incomplete | Short | Unseen words, names, typos |
| Single letters | Tiny | Very long | Too little meaning per step; slow and costly |
| Subword chunks | Tens to hundreds of thousands | In between | Any text is representable; lengths vary by language |
Frequent words stay whole; rare words break into familiar pieces, so annoyingly might arrive as annoying + ly. The right picture is a parts bin, not a dictionary: a dictionary must contain every word, a parts bin only needs every piece you might assemble.
How the tokenizer chooses its chunks: merge whatever repeats
Nobody designed these chunks by hand. They're harvested from data by byte-pair encoding, or BPE — a 1994 file-compression trick later repurposed for language models. The principle is compression: whatever repeats often gets a short name.
The modern version starts from bytes. Any text is a byte sequence in UTF-8, and a byte takes only 256 possible values, so a 256-entry base vocabulary can represent anything at all — no unknown-character escape hatch. This is byte-level BPE, introduced with GPT-2. Then comes the loop:
- Count which adjacent pair of tokens occurs most often in a large sample of text.
- Mint a new token for that pair, give it the next ID, and replace every occurrence.
- Repeat tens of thousands of times.
A tiny illustration, starting from letters. Suppose the training text has low five times, lower twice, newest three times:
| Round | Most frequent pair | New token |
|---|---|---|
| 1 | l + o (7 times) | lo |
| 2 | lo + w (7 times) | low |
| 3 | e + s (3 times) | es |
After two rounds, low is one token that also covers the front of lower, which now reads low + e + r. Run the loop fifty thousand times and you get GPT-2's 50,257 slots: 256 bytes, 50,000 merges, one end-of-text marker. Newer tokenizers are larger, around 100,000 entries for OpenAI's cl100k_base and around 200,000 for o200k_base.
The consequence to hold onto: which chunks exist depends on what the training text looked like. Common text gets compact chunks; rare text stays splintered.
What tokenization explains about AI tools
Why your bill is counted in tokens
API pricing is per token, with input and output priced separately, output usually dearer. For English, one token is roughly four characters or three-quarters of a word, so 100 tokens is about 75 words and a 1,000-word document is somewhere near 1,300 tokens. These are estimates, and they're tokenizer-specific: the same sentence can be 40 tokens under one model and 55 under another, so a price per million tokens doesn't settle what a job will cost.
Why the same text costs more in some languages
English letters take one byte each in UTF-8; Chinese and Japanese characters typically take three. If those byte sequences never got merged into large chunks — because the tokenizer's training text was English-heavy — the content stays in small pieces and eats far more tokens. A 2023 study by Petrov and colleagues measured identical content across languages under the tokenizers used by ChatGPT and GPT-4: Italian needed about 1.6 times as many tokens as English, Bulgarian about 2.6, Arabic about 3, and Shan, a language of Myanmar, as much as 15 5. As the paper stresses, the disparity arises at the tokenizer, before the model is invoked at all. Users of those languages pay more for the same task, wait longer, and fit less content into the same context window.
Why the context window is counted in tokens
A model's context window is the fixed number of tokens it can hold at once — your prompt, any system instructions or attachments, and the reply. Because the unit is tokens, a "200,000-token window" isn't a fixed page count: it's a lot of English prose, less of a language using three-byte characters, and less again for code and URLs, which tokenize messily. When a chat says your message is too long, it's reporting a token count you can't see.
Why counting letters is a weak spot
The model receives strawberry as one ID or a couple — never as eleven letters. To answer, it must recover the spelling from what it absorbed during training, not read characters off the input. That's recall, not counting, and recall can be right almost always and still slip on one word. The same limit explains shaky performance on reversing words, rhyming, anagrams and counting words in a paragraph.
There's a practical trick that follows from the mechanism: ask the model to spell the word with spaces between the letters, s t r a w b e r r y, and each letter usually lands in its own token. Counting now has something to count. It isn't a guarantee — and some systems increasingly hand such questions to a small piece of code — but the reason it helps is exactly this: you changed the input so the letters became visible items.
Where the parts-bin picture stops working
A token is not a unit of meaning. It's a frequency artifact. un + believ + able doesn't mean the model has a concept called "un"; those boundaries fell where they fell because the sequences repeated. The same word with a leading space or in capitals can split differently.
It's a resolution limit, not a wall. The model does learn plenty about spelling, because chunks recur across millions of words. It isn't blind to letters; it reads them through chunks, which makes letter-level questions unreliable rather than impossible.
The one-sentence version
A token is a frequent chunk of text with an ID number, chosen by repeatedly merging whatever pairs appear most often in training data — and that one decision, chunks rather than words or letters, is why AI is billed per token, why some languages cost several times more than English for the same request, why context limits are counted this way, and why counting letters is asking a model to do something its input format doesn't put in front of it.
From here, those IDs enter the model and become a prediction for the next token — the sampling loop described in the previous article.