A tokenizer has a 'vocabulary'. What is it, and why does its size matter for the model?
A tokenizer vocabulary is the fixed numbered list of token ids the tokenizer can emit. Its size is set at training time and directly determines the row count of the embedding matrix and the column count of the lm_head.
Imagine the language model only knows a finite list of stamps it can use, like a kid with a sticker book. The sticker book is the vocabulary. Every sticker has a number printed on it, and the model can only ever stick stickers it owns. When the tokenizer reads your prompt, it figures out which stickers to lay out to represent your text. When the model replies, it picks stickers one at a time from the same book. The number of pages in the book is the vocabulary size. A bigger book lets the model represent more things with single stickers (so common words become one sticker instead of three), but every page in the book costs memory inside the model. Picking a vocabulary size is picking how big the sticker book should be before you start training.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: define vocabulary as the numbered list of ids, identify the embedding and lm_head matrices that depend on its size, walk the tradeoff between fertility and parameter count, cite typical 2026 sizes, and distinguish vocabulary from context window and hidden dimension.
Real products, models, and research that use this idea.
- OpenAI's tiktoken cl100k_base has 100,256 tokens (used by GPT-4 and GPT-3.5-turbo); o200k_base has approximately 200,019 tokens (used by GPT-4o, o1, o3, GPT-5, GPT-5.5).
- Meta's Llama 3 and Llama 4 use a 128K-token byte-level BPE vocabulary, expanded from Llama 2's 32K SentencePiece vocabulary primarily to improve multilingual and code performance.
- Mistral Large 3 retains a 32K-token SentencePiece-based BPE vocabulary, which contributes to higher fertility on non-English text relative to the larger-vocabulary frontier models.
- Hugging Face tokenizer.json files explicitly list the full vocabulary; you can inspect any open-weight model's tokens by loading the tokenizer and iterating over its vocab.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf you wanted to add a new special token to a pretrained model, what would actually have to happen?
QWhy did OpenAI move from cl100k_base to o200k_base for GPT-4o and later models?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Confusing vocabulary size with context-window size. Vocabulary is how many distinct tokens exist; context window is how many tokens fit in one prompt. They are unrelated parameters.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.