Topic 6
What this breaks in practice
Limits and prices are in tokens
Context windows, output limits, API prices and many rate limits are denominated in tokens of a specific model's tokenizer. A 1,000-word document is not a fixed number of tokens: it depends on the language, the content and the tokenizer. Budget with the tokenizer, not a word count.
Different models, different tokenizers
The model and its tokenizer are trained together: each row of the model's embedding table belongs to one entry in that tokenizer's vocabulary. You cannot swap in a different tokenizer without retraining. Token counts are therefore not comparable across model families either, and a throughput number quoted in "tokens per second" means different amounts of text for different models.
Never mix tokenizers
Token IDs are only meaningful with the vocabulary that produced them. Encoding "Tokenizers turn text into integers." with o200k_base and decoding the resulting IDs with cl100k_base does not raise an error. It silently returns:
Decoding with the wrong tokenizer. IDs from one vocabulary, read with another, decode to fluent-looking garbage, and nothing raises an error.
Measured with tiktoken 0.14.0: encoded with o200k_base, decoded with cl100k_base.
That is the dangerous part: a mismatch produces plausible-looking garbage instead of a crash. The same applies to caches of token IDs, token-based chunk boundaries and token-count budgets stored in a database.
Quick check
Spelling and arithmetic quirks
The model never sees letters or digits unless the tokenizer happens to cut text that finely. In o200k_base, strawberry at the start of a string is three tokens (st, raw, berry) but strawberry after a space is a single token. Asking "how many r's are in strawberry?" asks the model about letters inside a symbol it was never shown letter by letter. Similarly, 12345 + 67890 = 80235 splits into 123 45 + 678 90 = 802 35, so digit columns do not line up between the numbers.
Tokenization is one commonly cited reason models stumble on character-level and arithmetic tasks. It is not the only factor, and models can still learn these tasks, but it explains why the failures look the way they do.
Special tokens
Besides text pieces, every vocabulary reserves special tokens with a control meaning rather than a textual one: end of text, beginning of a sequence, padding, chat-role markers, or fill-in-the-middle markers for code completion. In tiktoken, gpt2 has one (<|endoftext|>, ID 50256); cl100k_base adds <|fim_prefix|>, <|fim_middle|>, <|fim_suffix|> and <|endofprompt|>; o200k_base has <|endoftext|> (ID 199999) and <|endofprompt|>. Chat models use special tokens to mark where one speaker's turn ends and the next begins, which is why chat APIs build that framing for you.
The next page shows how special tokens become a security problem.