Understanding Attention in Transformers

Attention lets a model construct a new representation of each token by mixing information from other tokens. The mixing weights depend on the current input, so the same word can use different context in different sentences. That description is useful but incomplete. Attention does not inherently know token order. A causal mask is not a positional encoding. A key-value (KV) cache is not long-term memory. Retrieval-augmented generation (RAG) and mixture-of-experts (MoE) are not attention variants. Attention maps can also be informative without being faithful explanations of a prediction. ...

August 15, 2024 · 8 min · Akshat Gupta