Architecture Explorer

Transformer Lab: Scaled Dot-Product Self-Attention

Inspect exact matrix operations, Q/K/V vector projections, multi-head routing, and temperature scaling in real-time.

Multi-Head Specialization (8 Simulated Attention Heads)
Head 1: Coreference & Long-range Semantic Resolution
Attention Matrix Heatmap (Softmax(QKT / √dk))
Click Row to Inspect Token Query
Query Vector Focus: it
Attention Output Distribution
Query: [q0...q63] • Key: [k0...k63]
Formula: Aij = exp(Qi•Kj / √dk / τ) / ∑ exp(...)
Key Architectural Insight
Complexity: O(N²)

In modern LLMs (e.g., LLaMA, GPT-4), Multi-Head Attention projects the input representation into distinct sub-spaces ($Q, K, V$). Each head captures isolated syntactic or semantic relationships. Scaled dot-product prevents vanishing gradients in the softmax layer when vector dimensionality $d_k$ is large.