Like in “Who should “it” listen to?”, a word scores how well every word’s key matches its query and turns the scores into shares of its attention. But now the text is being written one word at a time, left to right: when the word at position reads, the words after it don’t exist yet. Write listen(query, keys, position): one share per word in the whole sentence, future words included.
The text is written one word at a time. When “sat” (position 1) reads, it looks for a place, [0, 1], and “mat” hasn’t been written yet. How should it share out its attention, one share per word in the whole sentence?
listen(query, keys, position)| query | what the word at `position` is looking for | e.g. [0, 1] |
| keys | one row per word of the sentence, what each word is | e.g. [[2, 0], [0, 0], [0, 2]] |
| position | which word is reading (0 = the first word) | e.g. 1 |
| returns | one share per word, future words included | |