Attention mixes tokens. The MLP thinks about each one.
You already have attention: Query · Key · Value lets tokens look at each other and pull in context. But that is only half of every layer. The other half — the MLP — takes each contextualized token on its own and runs it through a little look-up engine. It is where the model does most of its computing, and where facts like "France → Paris" are stored.
Every layer does two different jobs
A transformer block is two sublayers stacked back to back. Attention moves information sideways — between token positions — so each token can gather what it needs from the others. The MLP (multi-layer perceptron, also called the feed-forward layer) then works straight down on each token separately: it never looks at the other tokens, it just processes the vector attention just handed it.
Both write their result back into the same running vector — the residual stream — by adding to it. So one block is really: x = x + attention(x), then x = x + mlp(x).
A clean way to hold it: attention looks things up in the context; the MLP looks things up in its memory.
in′, which is in + attn_out. It reads the result attention wrote — but only that one vector. It never sees Q/K/V or the other tokens.in′ + mlp_out = in″. That in″ is what leaves Layer 1 and enters Layer 2.x = x + attention(x), then x = x + mlp(x) from above. (paris and is ride the identical path in parallel.)An MLP is two matrices with a bend in between
Despite the fancy name, an MLP is the oldest, simplest neural network. It does exactly three things to a token's vector: expand it to a much wider list of numbers, bend each number through a nonlinearity, then shrink it back to the original width. In GPT-2 the vector is 768 numbers wide; the MLP blows it up to 3072 and back.
(c_fc)
squish
(c_proj)
The bend in the middle is the whole point
Why bother with the nonlinearity? Because without it, the two matrices would collapse into one. (x × Wup) × Wdown is just x × (one combined matrix) — no more powerful than a single linear step. The GELU bend in the middle breaks that collapse and lets each neuron act like a switch: it stays near zero until its input is positive enough, then it turns on.
Read it like a gate:
So each of the 3072 neurons is independently deciding "does my pattern appear in this token? if yes, speak up."
Each neuron is a tiny "if you see X, add Y" memory
Here is the bridge from attention. A single neuron does almost the same dance you already know — a dot product to get a score, then it scales a vector — except its Key and Value are learned weights baked into the model, not pulled from other tokens.
[0,1,0,1]) would score only 0.1 + 0.2 = 0.3, barely fire, and write almost nothing. Out of 3072 neurons, the handful whose key matches this token are the ones that speak.The whole MLP output is just the sum of every neuron's contribution: Σ GELU(token · keyi) × valuei. It behaves like a giant book of rules — "if the context looks like the capital of France, add a nudge toward Paris." That is literally where factual knowledge is stored: in the key/value weight pairs, learned during training.
Most of the model, by weight, is MLP
Because each MLP holds two big matrices (768×3072 and 3072×768), the feed-forward layers contain about two-thirds of GPT-2's parameters — more than attention. When people say large models "store knowledge," they mostly mean these matrices. Attention is the smaller, flashier part that routes information; the MLPs are the bulk memory.
Across all 12 layers that is roughly 57M parameters in MLPs versus 28M in attention — and the gap only widens in bigger models.
How a token gets answered
Back on the main explainer, "pass the contextualized tokens through the layer stack" is this two-step dance repeated 12 times:
So the one-line answer to "what is an MLP?": it is the per-token look-up engine that turns the context attention gathered into stored knowledge and computation — two matrices, a bend, and 3072 little if-then memories, run on every token at every layer.