Attention Imagined from the ground up
Audience:
Analytics
Comments
I really liked the way you tied back many of the ideas that motivate the math to those of a traditional conversation. It’d be nice if some of the images could have been included as svg’s to make them more scalable and to remove the white background on them.
The examples to motivate Attention were nice But at places (e.g. when introducing grammar) they felt rushed / just to draw the parallel, but not quite helpful for understanding the concept
Overall explanation and motivation of the attention mechanism is good, but I would add some things:
- It’s not clear why we start with weighted averages of the last n word vectors to predict the next word.
- We don’t always want weights along each row of the attention matrix to sum to 1, which is what softmax forces. This leads to a problem called “attention sinks” which recent research has addressed.
- Positional encodings and residual connections were not explained.
- Only self-attention was shown, but cross-attention is also used very often.
In general, you do a good job describing how a human being could have thought of the idea for attention, but you should mention at the end that after developing attention, we can (and often should) remove our human conceptions of what each component means, for example:
- the dot product operation does not need to be thought of as “similarity”, it can be treated as just an arbitrary nonlinear function on a pair of vectors
- similarities don’t need to be converted to probabilities (this relates to the issue of weights summing to 1), in principle they can even be converted to negative numbers How actual AI models work is usually very different from how a human would imagine they work. I personally think the real reason attention works so well is because it explicitly forces every word vector to interact with every other word vector (all-pairs dot products), while representing each individual word as a full vector (instead of compressing all words into a fixed-size representation, like what recurrent neural networks do).
I’d say the motivation of the post was pretty clear from the beginning, with a gradual build-up to the importance of attention.
Great efforts were made to be clear in the post and empathetic to readers who are just considering these ideas for the first time. But I still felt that there were some confusing portions related to the examples, and some unclear wordings when defining the function f(w_{1 : n}, i). It started getting hard to follow once we started following steps without much justification, such as in computing the Value vector. I had a hard time following the first diagram. But I did like how you labeled your “putting it all together” formulas.
Pre-existing knowledge of linear algebra concepts like dot product, cosine similarity, or matrix multiplication were assumed, so I think the “undergraduate” and “graduate” labels are appropriate.
I think the post is unique in its attempt to focus on the importance of attention and how it works for NLP.