In every attention layer, each token asks a question (its query), compares it with every token's key, and takes in their values in proportion to the match. Each of the model's four heads asks its own kind of question. Here are all of them, on your sentence.
The model's German: Anna hat einen kleinen Hund . Sie mag ihn .
Each English token (row) looks at every English token (column), before and after it.
Layer 1 of 2
Layer 2 of 2
Step by step: layer 2, head 3
Pick the token that asks. The clip plays scaled dot-product attention for it in the chosen head: its query against each key, the division by √d_k, the softmax, and the weighted sum of the values.
Playback speed
The numbers for “it”: each score is q · k, then divided by √16, then the softmax.
keys k
q · k
÷ √16
softmax weights
Anna
4.591
1.148
3.3 %
has
−7.701
−1.925
0.2 %
a
0.213
0.053
1.1 %
small
5.917
1.479
4.5 %
dog
17.789
4.447
88.0 %
.
−2.736
−0.684
0.5 %
She
−17.808
−4.452
0.0 %
likes
−9.900
−2.475
0.1 %
it
−10.428
−2.607
0.1 %
.
−3.483
−0.871
0.4 %
</s>
2.499
0.625
1.9 %
How to read the maps
Each map is one head. Its rows are the tokens that ask, its columns the tokens they can look at, and each row adds up to 100 %: the darker the cell, the more of that column's value goes into the row's new vector. A head that looks at the word before draws a diagonal just below the middle; a head that links a pronoun to its noun lights one cell far from the diagonal.
The paper's model uses attention three ways (section 3.2.3): the encoder's tokens look at the whole English sentence; the decoder's look only at the German written so far (the rest is masked); and in encoder–decoder attention, each German position looks at the English. The GPT-style model has only the masked kind, over the English so far.