Tokenization leaks into everything
By now you know text becomes tokens before the model does anything. The practical punchline is that the token count, not the character count, drives almost everything you care about: how much you pay, how fast a reply streams, and whether your prompt fits. Pricing is quoted as cost per token, speed is measured in tokens per second, and the context length limit is counted in tokens. Learning to think in tokens is the single most useful practical skill in this whole track.
The handy rule of thumb — and exactly why it is unreliable: code, numbers, and non-English text break this ratio, so run the real tokenizer instead of guessing.
The classic pitfalls, explained
Most famous LLM weirdnesses are really tokenization pitfalls in disguise. Once you see the tokens, the quirk stops being mysterious:
- Bad arithmetic & spelling: the model never sees letters or digits individually. "1234" might be one token or split oddly as "12"+"34", so counting characters or doing long multiplication is genuinely hard for it.
- The space-matters bug: " hello" (with leading space) and "hello" (without) are often DIFFERENT tokens. A trailing space at the end of your prompt can quietly change the model's behaviour.
- Exact-string fragility: asking a model to repeat a rare token, or reverse the letters of a word, can fail because the word is one opaque token to it, not a string of characters.
- Language fairness: an English word may be 1 token while the same idea in Thai, Hindi, or even Chinese takes several. That means non-English prompts can cost more and eat the context window faster.
Byte-level tokenizers make the language gap smaller and guarantee nothing is unrepresentable, but they cannot erase it: scripts that the tokenizer's training data saw less of still get chopped into more, smaller pieces.
Count tokens before you trust an estimate
Because the ratio is unreliable, the professional move is to run the actual tokenizer your model uses and look at the real count. Every major provider ships a tokenizer you can call locally — feed it your prompt and it returns the token list and length. This is how you budget cost, check you fit under the context limit, and debug a spacing surprise.
prompt = "the cat sat" ids = tokenizer.encode(prompt) print(ids) # -> [1820, 5169, 7493] print(len(ids)) # -> 3 tokens, this is what you are billed for
Remember the vocabulary size trade-off from guide 2: a model with a bigger vocabulary often encodes the same text in fewer tokens, which can make it cheaper and able to fit more into its window — even before comparing the headline price per token. Token efficiency is a real, comparable property of a model.
Beyond text: images become tokens too
The same idea generalizes beautifully. A multimodal model handles pictures through multimodal tokenization: an image is sliced into patches and each patch is turned into a vector, so the picture arrives as a sequence of image tokens sitting right alongside your text tokens in the very same vector space. That is why providers bill an image as a chunk of tokens, and why a high-resolution image can quietly consume a big slice of your context window — it is genuinely more tokens.
The whole track in one mental model
Step back and the pipeline is short and beautiful. Text is chopped into vocabulary pieces (tokenization), each piece becomes an integer ID, each ID looks up a learned vector (the embedding matrix), and at the output the model scores every token to choose the next one — often reusing the input table via tied embeddings. Everything downstream — attention, the transformer stack, the final answer — operates on those vectors. Master this front door and the rest of the LLM stops being magic and starts being machinery.
Diagram: word vectors as points in space, with king minus man plus woman approximately equals queen.