We now have every part. A
It is a strikingly small recipe for something so capable: gather context, think, repeat.
Let the input be a whole sequence,
Step 1 — the attention sublayer, wrapped. Run multi-head self-attention on a normalised copy of the stream, and add the result back:
After this line, every token has mixed in information from every other token. The shape is unchanged:
Step 2 — the feed-forward sublayer, wrapped. Feed
After this line, every token has been transformed in place. Again the shape is unchanged:
Step 3 — name the block. The two wrapped sublayers, in this order, are one transformer block:
Attention first (gather context), feed-forward second (process it) — each wrapped in Add & Norm.
Step 4 — track the shape. The input was
Input shape equals output shape. That is the whole reason blocks compose.
Step 5 — stack
The sequence keeps its
Step 6 — read the rhythm. Every block gives each token one more chance to look
around (attention) and then reconsider (FFN), reading from and writing to the same residual stream.
Depth is how many rounds of gather-then-think the model gets; width
The cleanest way to see a deep transformer is as one long
residual stream — a single
This view makes the two scaling knobs concrete. Depth (
On the left, one block laid out in full: attention wrapped in Add & Norm, then the feed-forward
block wrapped in Add & Norm, with the residual stream running straight up the side. On the right,
the same block copied
That is a transformer. Embed the tokens, add positional information, run them up a stack of these blocks, and read off the top — encoder, decoder, and the large language models all share this exact backbone. Everything beyond here is variation on the theme: how the attention is masked, how the blocks are arranged, and how high the tower goes.
Stacking
So a "24-layer" transformer has roughly 24 times the attention-and-feed-forward parameters of a single block, not the same handful of weights reused 24 times. (Tying weights across layers is a real technique some models use — it's notable precisely because most models don't: each rung of the tower is its own fresh set of learned numbers.)