How Transformers Work: Self-Attention
Interactive MechanismTransformers replace sequential loops with Self-Attention: every token computes a Query ($Q$), Key ($K$), and Value ($V$) to weigh contextual relevance with every other token in parallel.
1. Select Query Token ($Q$) to Inspect Attention ($QK^T / \sqrt{d_k}$)
Click any token badgeNormalized Attention Weights (Softmax)
Attention Math Breakdown
For token it, the model computes compatibility scores against all Keys ($K$), scales by dimension $\sqrt{d}$, and applies Softmax: