Compute an attention output
Use your thumb for spaces and keep your eyes on the next word. · 133 words
Attention can combine values using weights derived from how well a query matches available keys. Suppose two values are four and eight. Give the first a weight of one quarter and the second three quarters. The weighted contributions are one and six. Their sum gives an attention output of seven.
Notice that the weights add to one. In this tiny example the result must lie between four and eight. An answer of twelve would reveal a mistake before you inspected the arithmetic. In a model, a value can be a list of numbers, and the same weighted combination is applied to each position in that list. A larger weight gives one source more influence on this calculation. It does not prove that the source is true, recent, or sufficient evidence for a claim.
Check your recall
What would equal weights produce?
Check your answer
Half of four plus half of eight equals six.
Sources and credits
Original KeyTouch lesson. Background reading · Zhang et al. · Dive into Deep Learning.