Read page 3 as text
What queries, keys and values do
5
QUERY
QUERY FROM THE POSITION “it”
q [2, 1]
Earlier cat / milk keys are visible
query from it
[2, 1]
Whose query is this?
Take “it” in our cat-and-milk sentence. Its current hidden state produces the query, which scores available keys.
Toy q = [2, 1]. Later words stay masked.
6
KEY
TWO CANDIDATE KEYS
cat key [2, 0]
milk key [0, 1]
Different keys, same comparison rule
cat key [2,0]
milk key [0,1]
A key helps determine how a position is matched. Its value vector is the information delivered by the weighted blend. They have different jobs.
Toy keys: cat [2,0]; milk [0,1]
7
SCORE AND NORMALIZE
cat: 2 × 2 + 1 × 0 = 4 milk: 2 × 0 + 1 × 1 = 1
softmax of [4, 1]
cat weight 95.3%
milk weight 4.7%
scores 4, 1
→
95.3%, 4.7%
In this unscaled toy, dot products give scores 4 and 1. Softmax turns them into about 95.3% and 4.7%.
Real attention also scales scores and applies masks
8
VALUE
0.953 × [1, 0] + 0.047 × [0, 1]
WEIGHTED BLEND
[0.953, 0.047]
V1 [1,0]
V2 [0,1]
The attention weights blend the value vectors. It is a weighted combination, not necessarily one exact lookup.
Values [1,0], [0,1] → [0.953,0.047]