The modern LLaMA-style architecture
Name the changes modern LLMs make to the original GPT design: RMSNorm, pre-norm, SwiGLU, RoPE, no bias terms, untied embeddings. Give the reason for each.
Builds on: The decoder-only transformer, end to end, Rotary position embeddings (RoPE)
What the animation says
Same skeleton, six changes
GPT from 2018 and LLaMA from 2023 share one skeleton: a decoder-only stack of attention and MLP blocks. What changed is a handful of details, and nearly every open model since copies them. Pre-norm, RMSNorm, no biases, SwiGLU, RoPE, and an untied output matrix. For each one, ask what it buys: stable training, less work, or better quality.
Pre-norm: keep the stream a plain sum
Each block reads the residual stream, computes something, and adds it back. The original post-norm design normalized the stream itself after every addition. Deep stacks of it often diverged unless training started very gently. Pre-norm normalizes only the input to each sublayer. The stream stays r plus f of norm of r. So gradients flow back to early layers through the additions, untouched. Your turn: tap where pre-norm puts the norm.
RMSNorm and no biases
LayerNorm subtracts the mean, divides by the spread, then applies a gain and a bias. RMSNorm keeps only the rescale. Take four numbers: four, zero, minus two, four. Square them and average: thirty-six over four is nine. The root is three. Divide by three, then multiply by a learned gain. No mean, no bias: fewer operations, same quality. LLaMA also removes the plus b from every linear layer. Quality barely moves, and training gets simpler and more stable.
RoPE and an untied output
RoPE rotates the queries and keys in every attention layer, by an angle set by each token's position. Scores then see position only as the offset between tokens. Nothing is added to the stream, and no position table limits length. At the output, LLaMA uses its own matrix instead of reusing the embedding: reading a token and predicting one are different jobs. In LLaMA seven B, that extra matrix is about a hundred thirty-one million weights. Roughly two percent. GPT-2 small is much narrower. What would untying cost there?
SwiGLU: a gate and three matrices
Thirty-one percent. That's why small models often keep the embedding tied. Now the MLP. A GELU MLP has two matrices: up to a wide layer, then back down. SwiGLU adds a third. One projection, passed through SiLU, gates a second one, element by element. The product goes back down through the third matrix, and at equal size it reliably gets lower loss. LLaMA seven B has width four thousand ninety-six. Its GELU MLP would be sixteen thousand wide. With three matrices, what hidden width keeps the same weight count?
The whole LLaMA block
Two matrices sixteen thousand wide hold as many weights as three at two-thirds of that: eight-thirds of the model width. LLaMA rounds to eleven thousand and eight. So here is one block: the stream plus RoPE attention on the RMS-normed stream, then plus SwiGLU on the RMS-normed result. No biases anywhere. After the last block, one more RMSNorm, then the separate output matrix. Pre-norm, RMSNorm and no biases buy stable, simple training. SwiGLU and RoPE buy quality and relative positions.
Changes for stability and simplicity
Changes for quality and flexibility
One LLaMA-style block, precisely
Numbers: SwiGLU width and untying cost
Remember
On Bytewise this lesson comes in small steps with a check at the end, and the app brings it back right before you would forget it.
Bytewise
All courses