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.
| animal | place |
|---|---|
| 0 | 1 |
| animal | place | |
|---|---|---|
| cat | 2 | 0 |
| sat | 0 | 0 |
| mat | 0 | 2 |