LLaMA Components › Parameter Distribution
Michael BrenndoerferUpdated August 2, 20253 min read
Language AI HandbookAll chapters Part 29 of 67Modern Decoder Models
LLaMA Components › Parameter DistributionOne section · Sections in this chapter8 / 12 ↓
Sections in this chapter12
Reading tools Definitions & inline links
Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.
Article links
Make inline references clickable
Understanding where parameters reside helps explain why certain design choices matter. Let's analyze the parameter distribution in a LLaMA block:
In[23]:
Codedef count_block_params(d_model, n_heads, d_ff):
"""Count parameters in each component of a LLaMA block."""
d_head = d_model // n_heads
params = {
"RMSNorm (×2)": 2 * d_model, # Two norm layers, one scale per dim
"Q projection": d_model * d_model,
"K projection": d_model * d_model,
"V projection": d_model * d_model,
"O projection": d_model * d_model,
"FFN W_gate": d_model * d_ff,
"FFN W_up": d_model * d_ff,
"FFN W_down": d_ff * d_model,
}
return params
# LLaMA 7B proportions
d_model = 4096
n_heads = 32
d_ff = 11008 # Actual LLaMA 7B FFN dimension
params = count_block_params(d_model, n_heads, d_ff)
total = sum(params.values())Out[24]:
Visualization

Out[25]:
ConsoleParameter Count per Block (LLaMA 7B scale): -------------------------------------------------- RMSNorm (×2) : 8,192 ( 0.0%) Q projection : 16,777,216 ( 8.3%) K projection : 16,777,216 ( 8.3%) V projection : 16,777,216 ( 8.3%) O projection : 16,777,216 ( 8.3%) FFN W_gate : 45,088,768 ( 22.3%) FFN W_up : 45,088,768 ( 22.3%) FFN W_down : 45,088,768 ( 22.3%) -------------------------------------------------- Total : 202,383,360 (100.0%) For 32 layers: 6.48B parameters in transformer blocks
The FFN dominates parameter count despite SwiGLU's efficiency improvements. This is because:
- The hidden dimension is large (about 2.7x )
- SwiGLU uses three matrices instead of two
However, this investment pays off. The FFN provides the model's primary capacity for storing learned patterns and facts. The attention mechanism, while containing fewer parameters, handles the important task of routing information between positions.