Predict the typical layer count for a Llama 7B and a Llama 70B
Without looking up the spec, predict how many transformer blocks (layers) a Llama-style 7B and 70B model have, respectively. Report as 'NN / NN'.
Llama-style 7B models stack 32 transformer blocks; 70B models stack 80. Width and depth both scale, but width (`d_model`) scales faster.
Imagine building two skyscrapers, a small one and a big one. The small one (Llama 7B) is 32 floors tall and each floor is 4096 square meters wide. The big one (Llama 70B) is 80 floors tall and each floor is 8192 square meters wide: the floors got twice as wide AND there are more than twice as many of them. Engineers worked out a rule of thumb over years of experiments: when you make a language model bigger, you want to grow both the height (more layers) and the width of each layer, but width usually grows a bit faster. Llama 3 and Llama 3.1 follow this rule almost exactly. Memorizing 32 and 80 lets you sanity check almost any LLM cost estimate.
Detailed answer & concept explanation~5 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: state the two anchor numbers, work the aspect ratio math, connect to the wider not deeper scaling-law finding, and show how the numbers feed KV cache and parameter estimates.
Real products, models, and research that use this idea.
- Llama 3.1 8B: 32 layers, d_model 4096, 32 query heads with 8 KV heads (GQA 4:1), FFN hidden 14336.
- Llama 3.1 70B: 80 layers, d_model 8192, 64 query heads with 8 KV heads (GQA 8:1), FFN hidden 28672.
- Llama 3.1 405B: 126 layers, d_model 16384; depth grew further but width grew faster, preserving the wider than deep trend.
- Mistral 7B (the original 2023 release) also picks 32 layers / 4096 width, mirroring the Llama 7B shape almost exactly.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy did Llama 3.1 promote the 7B class to 8B without changing layer count or width?
QWhat happens to KV cache size between 7B and 70B at fixed context length?
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.
Guessing 24 and 96 by analogy with GPT-3's small/large scaling, or assuming depth doubles cleanly with parameter count. Real LLMs scale width faster than depth.
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.