How do you estimate the number of parameters in a single Transformer layer given hidden size d and an FFN dimension of 4d?
Last updated
Attention has four d×d projections (
4d², independent of head count) and the FFN has two d×4d matrices (8d²), giving about12d²per layer. Biases and norms add only O(d).Example: d = 4096 gives about 201M per layer, so 32 layers is about 6.4B plus V·d embeddings.
Variants: SwiGLU uses hidden size about 8d/3 to keep the FFN near 8d², and GQA shrinks
W_K/W_Vbelow 4d² total for attention.