Attention scores how much one word listens to another with a dot product: the first word’s query (what it looks for) times the other’s key (what it offers), as in “Who should “it” listen to?”. On their own they don’t say where the words are. Write tag(vector, position): change a 2D query or key so it includes its word’s position, such that the score between a query at i and a key at j depends only on how far apart they are, not on where in the sentence they sit.
A query word and a key word in a sentence. Untagged, their score is the same wherever they sit and however far apart they are. Tag each with its position so that the gap between them matters, and the place doesn’t.
tag(vector, position)| vector | a query or a key, [x, y] | e.g. [−1, 0.5] |
| position | where its word sits in the sentence, 0, 1, 2, ... | e.g. 0 |
| returns | the vector with the position worked in | |