An Attention Output as a Weighted Sum

An attention operation can combine value vectors using weights computed from query and key relationships.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace two scalar values
  2. Keep the score and weight stages separate

Trace two scalar values

With weights \(1/4\) and \(3/4\) on values two and six, the result is five. A different query can produce a different weighted combination without changing either value. See weighted means.

Keep the score and weight stages separate

Raw dot-product scores are not the weights in softmax attention. A normalization and any relevant mask intervene. Scaled dot-product attention gives the full calculation.[1]

References

  1. Ian Goodfellow, Yoshua Bengio and Aaron Courville, Deep Learning ↩