Transformer Under the Hood $Attention(Q,K,V)$

Interactive Scaled Dot-Product & Multi-Head Self-Attention Pipeline

Space Step • Heads • R Reset
Query (Q)
Key (K)
Attention Weight

1. Attention Matrix & Scaled Logits d_k=64

Softmax( (Q · K^T) / √d_k )
Select a source token to view live query-key projections and dot-product calculations.

2. Output Value Aggregation & Next Token

Residual & LayerNorm: $z = \mathrm{LN}(x + \mathrm{MHA}(x)) \to \mathrm{LN}(z + \mathrm{FFN}(z))$