passdrill
AI & LLM Engineering · How LLMs Work: Transformers & Training · Card 001/012 medium

In the Transformer architecture introduced by Vaswani et al. (2017) in "Attention Is All You Need," the dot products between queries and keys are divided by the square root of the key dimension before the softmax is applied. What is the primary reason for this scaling step?

  1. It converts the attention weights into a probability distribution that sums to one across the sequence
  2. It reduces the number of parameters needed in the query, key, and value projection matrices
  3. It counteracts dot products growing large in magnitude for larger key dimensions, which would push the softmax into regions with extremely small gradients
  4. It allows the same attention weights to be reused across all heads in multi-head attention
Next card → Shuffle