Attention compares words with words, so it sees a sentence as a bag: dog bites man and man bites dog look the same to it. Write position_tag(position, length): a list of numbers to add to the word at position (0 is the first word) in a sentence of length words, so the model can tell where each word is. A word is a list of 16 numbers between −1 and 1, so a tag can have at most 16.
Attention sees a sentence as a pile of words, so “dog bites man” and “man bites dog” give the same pile. Each place needs a tag added to its word, so the two piles come out different. What should the tags be?
position_tag(position, length)| position | where the word is (0 = the first word) | e.g. 0 |
| length | how many words the sentence has | e.g. 10 |
| returns | a list of numbers (at most 16) to add to that word | |