How many trainable parameters are in a standard multi-head self-attention layer with hidden dimension d_model?
Last updated
Total is
4·d_model² + 4·d_model: fourd_model × d_modelmatrices (Q, K, V, output) plus biases. Bias-free LLMs have exactly4·d_model².The number of heads doesn't matter: more heads just split the same matrices more finely (e.g. BERT-base,
d_model = 768, gives 2,362,368).MQA/GQA (shared key/value heads) shrink
W_KandW_Vtod_model × (g·d_k).