Skip to main content
Explainers · Transformers
A Visual Primer

How a transformer
actually thinks.

Eight stages. The whole loop, one screen at a time.

Scroll
01

Text becomes tokens.

“The barrister cross-examined unhappily.”
Thebarristercross-examinedunhappily.

The model only knows pieces it has seen during training. Unusual or long words break into common parts — so the same fixed vocabulary handles everything, from “barrister” to a word the model has never seen.

02

Each token is a point in space.

dim 1dim 2judgebarristersolicitoradvocatelegal rolescourttribunalchambersvenuesdogcathorseanimals~4,096 dimensions · similar meanings sit close together
03

Every token looks at every previous token.

Brighter cells = stronger attention. “her” looks back at “barrister”. “she” too. The model learns these links from data alone.
04

It does this many times in parallel.

Head 1
previous token
Head 2
subject of clause
Head 3
coreference
Head 4
punctuation
05

Then each token is processed independently.

in
expand 4×
out

Where most of the model’s knowledge is stored.

06

All of that, stacked 80 times.

Attention

Every word looks at the other words and decides which ones matter to it. Attention is how the model works out that it refers to cat:

“The cat sat because it was tired.”

itrefers tocat
Feed-forward

Once attention has gathered the right context, the layer does a bit of private thinking — refining what each word now means in the light of the others.

Stage 05 was a look inside this step. It’s where most of the model’s knowledge is stored.

Doing this many times lets understanding build up gradually. Early layers catch simple things — grammar, which word goes with which. Later layers handle abstract meaning — tone, intent, reasoning. Less like 80 separate machines, more like 80 rounds of revision on the same draft.

L1
attention
feed-forward
L2
attention
feed-forward
L3
attention
feed-forward
· · ·
L78
attention
feed-forward
L79
attention
feed-forward
L80
attention
feed-forward
Each layer reads the running notes, adds its own contribution, and passes them on — like a shared notepad running down the spine of the model. Nothing gets overwritten, so a useful insight from layer 3 is still available at layer 79. That’s the residual stream.

80 layers is roughly the depth of a model like Llama 70B. Different models go deeper or shallower — the idea is what scales, not the figure.

07

Output is a probability over every word.

“The barrister opened her brief and began to read the
papers
21%
first
14%
witness
11%
opening
9%
judgment
7%
transcript
5%
~100k more
33%
08

Pick one. Append. Repeat.

The barrister opened her brief and
0 tokens

That is the whole machine.

No memory between steps. No reasoning beyond the loop. Just attention, projection, and a probability over the next token — at remarkable scale. Next in the series: what the machine can actually see.

Next: The Context Window →