AI & ML
Attention
Part of Deep Learning, level 4. About 9 hours of study across the topics below.
1Mechanism
- Query, Key, ValueThree roles, one retrieval: what the query asks, what keys offer, what values deliver. 1–2 h
- Similarity ScoresHow well does each key match? Query-key alignment, scored. 1–2 h
- Scaling and SoftmaxScores into weights: why divide by root-d, and the sum-to-one guarantee. 1–2 h
- Weighted AggregationThe mixture is the message: values averaged by weights into one output. 1–2 h
2Sequence Attention
- Self-AttentionA sequence attending to itself: every token contextualized by weighted others. 1–2 h
- Multi-Head AttentionParallel views, one output: heads attend differently, then concat and project. 1–2 h
- MaskingInformation control: causal and padding masks decide what may attend to what. 1–2 h
- Cross-AttentionQueries from one sequence attending to keys and values from another: how decoders read encoders and text reads images. 1–2 h
- Efficient AttentionAttention's quadratic cost and the fixes: IO-aware kernels, sparse and sliding windows, and linear approximations. 1–2 h
