Transformer Architecture
Inside the engine: how modern AI actually processes language
What is a Transformer?
Simulated internals
The 2017 blueprint versus modern LLMs
This diagram teaches the original encoder-decoder building blocks. Many generative LLMs instead use decoder-only blocks with causal masks, and model families may choose rotary position encodings, gated feed-forward layers, or grouped-query attention. Exact IO-aware kernels such as FlashAttention reduce memory traffic; they do not remove the quadratic pairwise arithmetic of dense attention.
Self-Attention: Tokens gather context
For each token, the model creates three vectors: Query (what am I looking for?), Key (what do I contain?), and Value (what information should I pass along?). Scores use Q(A) · K(B) / √dₖ, then masking and softmax turn the visible scores into normalized weights. Those weights mix the Value vectors. In a text generator, a causal mask prevents a position from using future tokens.
Key Insight
Check your understanding
1/5When can a Transformer process positions in parallel?
Sources, scope & review statusVerified Jul 29, 2026
Claims this lesson makes
- Stable conceptScaled dot-product attention mixes value vectors using softmax-normalized query-key scores; causal decoders mask future positions before softmax.
- Stable conceptDense attention forms a sequence-length-by-sequence-length score matrix; IO-aware exact kernels can reduce memory traffic without changing that attention function.
- Stable conceptThe original encoder-decoder Transformer is a blueprint, while deployed language models may use decoder-only stacks and different positional, normalization, attention, and feed-forward choices.
Scope: The selectable configurations and heatmaps are deterministic teaching simulations, not extracted activations or complete specifications of the named models.
Primary reading
Next content review: 2027-07-29. Source links establish the lesson's claims; interactive numbers remain labeled simulations unless explicitly identified as measured data.