What fraction of a 7B transformer lives in its embedding table at vocab 128k?
128k vocab times d_model 4096 is ~524M parameters in the input embedding alone, about 7.5% of a 7B model. Untying the output head doubles the cost to ~15%.
Imagine a giant phone book where every word the model knows has its own page, and each page is filled with a long list of numbers that describe what the word means. The phone book is huge: 128,000 pages times 4,096 numbers per page comes out to about 524 million numbers. On a 7 billion number model, that phone book alone is 7.5% of the whole thing. Not a rounding error, but not a black hole either: most of the model is still the stack of thinking layers above it. If you also keep a second phone book at the back of the model for turning answers into word scores, the pair takes about 15% of the total. Sharing one phone book for both ends (called tying) saves that 7.5% at a tiny cost in quality.
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.
5 min: do the multiplication, contrast tied vs untied embeddings, explain why Llama 3 moved to 128k vocab, and discuss how the fraction scales with model size.
| Model | Vocab | d_model | Embedding params | % of total |
|---|---|---|---|---|
| Mistral 7B (tied) | 32k | 4096 | 131M | 1.9% |
| Llama 2 7B (tied) | 32k | 4096 | 131M | 1.9% |
| Llama 3.1 8B (untied) | 128k | 4096 | 1.05B | 13% |
| Llama 3.1 70B (untied) | 128k | 8192 | 2.1B | 3% |
| Gemma 4 (untied) | 256k | 2048 | 1.05B | varies |
Real products, models, and research that use this idea.
- Llama 3.1 8B: vocab 128256, d_model 4096, embedding pair ~1.05B (13% of 8B).
- Llama 3.1 70B: vocab 128256, d_model 8192, embedding pair ~2.1B (3% of 70B): fraction shrinks at scale.
- Mistral 7B: vocab 32000, d_model 4096, embedding pair ~131M (tied, so 1.9% of 7B).
- Gemma 4: vocab 256000, d_model 2048, embedding pair ~1.05B; vocab grew while d_model shrank.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy doesn't the embedding fraction scale linearly with model size?
QHow would you choose vocab size for a new LLM?
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.
Treating embeddings as negligible because they are a lookup. They're not: at 128k vocab they're 7-8% of a 7B model, and at 256k plus vocab the cost climbs further.
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.