Interactive diagram makes Self-Attention vs Cross-Attention instantly clear

ProfTomYeh · x · 2026-09-20

Prof. Tom Yeh's "AI by Hand" series adds an interactive diagram contrasting self- and cross-attention. Self-attention: N tokens query each other, giving an N×N score matrix with Q, K, V all drawn from X. Cross-attention: the same N queries attend to a second sequence's M tokens, giving N×M — the only change is taking K and V from a second source E. In both cases Q and K must share the key dimension for the dot product, while V keeps its own dimension. Part 5 of the Attention series, following QKV projection and multi-head attention.

Original post →

More from Research

Research channel →