How many trainable parameters are in a standard multi-head self-attention layer with hidden dimension d_model?

Last updated 22 November 2026

  • Total is 4·d_model² + 4·d_model: four d_model × d_model matrices (Q, K, V, output) plus biases. Bias-free LLMs have exactly 4·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_K and W_V to d_model × (g·d_k).

  • https://medium.com/data-science/how-to-estimate-the-number-of-parameters-in-transformer-models-ca0f57d8dff0
  • https://medium.com/@intuitivedl/how-to-count-the-transformers-number-of-parameters-d34a2558e26f
  • https://github.com/Devinterview-io/llms-interview-questions
All Transformers interview questions