Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Part 12 / Topic 5 of 6

The transformer

The transformer is attention made into a repeatable block:

  1. Multi-head attention — several attentions in parallel, each with its own Q/K/V projections, so different heads track different relations (syntax here, coreference there).
  2. Position information — attention itself is order-blind; positional encodings (or rotary variants) tell the model where each token sits.
  3. Feed-forward layer — per-token MLP after the mixing.
  4. Residual connections + LayerNorm — around every sublayer, keeping gradients healthy through dozens of blocks (Part 11's normalization at work).

Stack the block N times and that is the architecture behind every modern LLM. Nothing in it is new to you now: matrix multiplies, softmax, LayerNorm, residuals.

🧪 Quick quiz

  1. What is the transformer's key building block, and how does it differ from recurrence?
Show the answer

Self-attention — every token looks at every other token in parallel, instead of a state crawling along the sequence one token at a time.

Done here? The practice set for Part 12 — 4 exercises with solutions — is on the part page.

Search the guide