1. Positional Encoding
Because attention is permutation-invariant, positional vectors (sinusoidal or learned rotary RoPE) are added to token embeddings so the model knows word order.
An interactive laboratory for the Attention mechanism ($Attention(Q,K,V) = \text{softmax}(\frac{QK^T}{\sqrt{d_k}})V$). Inspect live token embeddings, query-key dot products, attention heads, and probability distributions.
Head 1 focuses on adjacent syntactic relationships and direct word bindings (e.g. adjectives to nouns, prepositions to objects).
\text{head}_i = \text{Attention}(Q W_i^Q, K W_i^K, V W_i^V)
After Multi-Head Attention, residual addition, LayerNorm, and 2-layer FFN ($\text{GELU}(xW_1 + b_1)W_2 + b_2$), the unembedding matrix produces next-token probabilities:
Introduced in "Attention Is All You Need" (Vaswani et al., 2017), the Transformer eliminates recurrent neural network sequential dependencies by allowing every token to communicate directly with every other token in constant $O(1)$ path length.
Because attention is permutation-invariant, positional vectors (sinusoidal or learned rotary RoPE) are added to token embeddings so the model knows word order.
Query ($Q$): What a token is searching for.
Key ($K$): What a token contains.
Value ($V$): The information content transferred when matched.
Splitting dimensions into $h$ heads lets the model attend simultaneously to syntax, semantics, long-range pronouns, and factual associations.
Skip connections preserve gradients across hundreds of layers. The position-wise Feed-Forward Network then acts as a key-value associative memory bank.