Which part of a transformer model's parameter count scales directly and linearly with vocabulary size?
Only the input embedding [vocab_size × d_model] and the output lm_head [d_model × vocab_size] scale with vocabulary size; attention and feed-forward weights depend on d_model alone.
Think of a transformer as a translation office. At the front door sits a filing cabinet with one drawer per word the office knows, and looking up a word means pulling its drawer. That front cabinet is how the office turns a word into notes it can work with. At the back door sits a second cabinet, also one slot per known word, used to decide which word to write next. Add more words to the office's knowledge and both cabinets grow, one drawer at a time. But the clerks in the middle, who shuffle and combine the files, do the same job no matter how many words exist. They never get bigger when the vocabulary does.
Detailed answer & concept explanation~6 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.
2 min: embedding [V×d] + head [d×V] + 2·V·d formula + backbone is vocab-agnostic + weight tying + output softmax cost at large vocab.
Real products, models, and research that use this idea.
- Llama 3 expanded its vocabulary from an earlier 32k to 128k, quadrupling the embedding plus head parameters at d_model=4096 in exchange for shorter sequences on code and multilingual text.
- GPT-5.5 ships the o200k_base tokenizer with roughly 200k tokens, paying several GB of dedicated interface weights to cut non-English token counts.
- GPT-2 used weight tying to share its embedding and output head, a standard trick that halves vocabulary-related memory in smaller models.
What an interviewer would ask next. Try answering before peeking at the approach.
QFor a 7B model with d_model=4096, what fraction of parameters is vocabulary-related at 32k vs 128k vocab, untied?
QWhy does the output softmax over a large vocabulary not benefit from FlashAttention, and what reduces its cost?
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.
Attributing vocabulary scaling to attention heads or feed-forward layers. Those depend only on d_model and the layer count; vocabulary size never appears in them.
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.