Self-attention · “The cat sat”
The six steps of self-attention in one diagram. The query is “sat”: it is compared with the key of every token up to and including itself, and its score for “cat” is marked. Numbers flow up from the embeddings to the output vector.