Why are attention scores scaled by the square root of the key dimension in scaled dot-product attention?
Last updated
With unit-variance components,
q·khas varianced_k. Dividing by√d_k(the standard deviation) brings the logit variance back to about 1.Large logits saturate softmax into a near one-hot output. Its gradients then vanish and training becomes slow or unstable.
Dividing by
d_kinstead would over-shrink the logits and make attention nearly uniform.