A tokenizer has a 'vocabulary'. What is it, and why does its size matter for the model?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
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.
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.
What an interviewer would ask next. Try answering before peeking at the approach.
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.