01 / ScoringHow is relevance measured?
The rule that scores a query against a key. Scaled dot product maps cleanly onto matrix multiplication; additive attention uses a small learned network; cosine attention compares direction only.
- Scaled dot product
- Additive
- Cosine
Source: Attention Is All You Need ↗02 / ConnectivityWho may look where?
The mask decides which pairs exist. Full attention fills the square, causal attention is a triangle that hides the future, local attention is a band near the diagonal. Cross-attention takes keys and values from another sequence.
- Full
- Causal
- Local
- Sliding window
- Cross
Source: Swin Transformer ↗03 / Heads and cacheWhat do the query heads share?
MHA gives every query head its own key and value head. MQA shares one across all of them, GQA shares one per group. MLA compresses keys and values into a smaller latent instead. Each trades KV-cache memory against variety.
Source: GQA ↗04 / GrowthWhat grows with input length?
Full attention compares n × n pairs, so doubling the input can quadruple the work. Local and sparse patterns compare fewer pairs; linear attention keeps a running state instead of the full matrix, with different recall behaviour.
- Full matrix
- Sparse
- Linear state
- Hybrid
Source: Kimi Linear ↗05 / ExecutionHow is it run and stored?
FlashAttention computes exact attention but tiles the work so it stays in fast on-chip memory. PagedAttention manages the serving KV cache in blocks. Neither changes which token attends to which.
- FlashAttention
- PagedAttention
- Basic kernel
Source: FlashAttention ↗06 / PositionHow does order enter?
Plain attention sees a set. Sinusoidal and learned embeddings add a vector per position; RoPE rotates query and key features so their dot product carries relative position.
Source: RoFormer ↗07 / DomainWhat structure does the input have?
Text is a sequence, images are patch grids, video adds time, graphs define neighbours by edges. The mask and position scheme should respect that structure.