Attention, from vectors to probabilities
Every transformer article assumes you already know scaled dot-product attention. This one does not. We build the equation from three plain vectors, watch each symbol earn its place, and end at the exact form used in the original paper.
Three vectors walk into a layer
For a single query, attention compares:
- a query vector - what this position is looking for;
- a key vector - what each position offers;
- a value vector - what each position contributes.
The raw match score is a dot product, which is just a similarity meter:
Dividing by keeps the variance of the score stable as vectors grow
- without it, long vectors push the softmax into regions with vanishing gradients.
From scores to a probability distribution
The softmax turns raw scores into weights that sum to one:
In matrix form for a whole sequence at once:
That is the entire operation. Multi-head attention runs it times in parallel subspaces and concatenates the results.
What to read next
The natural follow-up is why sequences need positional information once attention is permutation-invariant - that article lands later in this series.