Which components make up a standard transformer block?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
A transformer block stacks multi-head attention and a feed-forward network, each wrapped in a residual connection and a layer norm. Four ingredients, same across every variant.
Imagine an assembly line where each station takes a sentence, processes it, and hands it on. The first station, attention, lets every word in the sentence look at every other word and gather context. The second station, the feed-forward network, gives each word a chance to think privately about what it just learned. Around each station, a forklift quietly carries the original input through the back so nothing gets lost (that is the residual connection), and a quality inspector rescales the output so it stays in a healthy range (that is the layer norm). Stack 32 of these stations and you have GPT. The four ingredients never change; only their order and the size of each station varies.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: four ingredients + pre-norm vs post-norm + FFN dominates parameter count + RMSNorm and SwiGLU as 2026 swaps + how GQA/MLA modify attention without changing the block recipe.
| Component | Original (2017) | Modern (2026) |
|---|---|---|
| Attention | Multi-head attention (MHA) | GQA, MQA, or MLA for KV efficiency |
| FFN activation | ReLU | SwiGLU or GeGLU |
| Normalization | LayerNorm (post-norm) | RMSNorm (pre-norm) |
| Residuals | Two per block | Two per block (unchanged) |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating attention as the entire transformer block. The feed-forward network carries about two-thirds of the parameters and most of the per-token compute.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.