The Tower: How a Transformer Turns Attention into Thought
At the end of the last chapter we had built something genuinely powerful and left it deliberately incomplete. We had attention: the mechanism by which a token issues a query, matches it against the keys of every earlier token, and updates itself with a weighted blend of their values. A word could finally read the room. The frozen vectors of Chapter Two had come alive to their context.
But I was careful to name two things attention cannot do on its own, because they are the exact shape of what we build now. First, a single attention operation tracks only one kind of relationship at a time — one notion of "relevant" — while real language is threaded with many relationships at once. Second, and more subtly, attention moves information around but does very little thinking with it; it is a superb librarian fetching the right passages onto the desk, but fetching is not the same as reasoning over what was fetched.
This chapter fixes both, and then does something more ambitious than either fix: it discovers that once you have a unit which gathers context and then thinks about it, the natural thing to do is stack that unit, deep — and that depth is where a transformer's apparent intelligence actually lives. We are going to build the block, and then build the tower.
There is also a small debt to settle before we begin — a gap I let you walk past in the last two chapters, and which you may already have felt nagging. Let us pay it first, because it is quick and it matters.
Part I — A debt: the machine does not know word order
Look back at the attention mechanism of Chapter Three and ask a sharp question: does it know which word came first?
Astonishingly, no. Attention compares every query to every key by content alone. Nothing in "query dotted against key" encodes where in the sentence each token sits. If you shuffled the words of a sentence, the set of queries, keys, and values would be exactly the same set — only reordered — and the attention machinery, which is blind to order, would compute essentially the same blend. But "the dog bit the man" and "the man bit the dog" contain identical words and mean opposite things. A mechanism that cannot tell them apart cannot possibly model language.
The fix is disarmingly direct. Since the token vectors carry no sense of position, we simply add position information into them before they ever enter the first attention layer. Alongside the embedding table from Chapter Two — which answers "what does this token mean?" — the model keeps a second source that answers "where does this token sit?", and the two are added together so that each token's starting vector encodes both its identity and its place in line. Position stops being invisible; it becomes part of what every query and key is built from, so a token can now attend not only by meaning but by where things are relative to it.
Part II — Many glances at once
Return to the first limitation: one attention operation can only follow one thread of relevance. In the sentence "the surgeon told the registrar that she had made an error," several questions hang in the air simultaneously. Who does "she" refer to — the surgeon or the registrar? Which verb governs "error"? What is the emotional and hierarchical relationship between the two people? A single query-key scheme has to commit to one notion of relevance, and cannot chase all of these at once.
So we do the obvious, generous thing: we run many attention operations in parallel, side by side, each with its own independent query, key, and value projections. Each one is called a head. Because their projections are learned separately, the heads are free to specialise — and, remarkably, when you inspect trained models they demonstrably do. Interpretability researchers, dissecting real networks, reliably find heads that have quietly taken up distinct jobs: one tracks which noun a pronoun refers to, another matches opening brackets to closing ones in code, another attends to the previous occurrence of the current word, another follows subject-verb agreement across long distances. Nobody assigned these roles. The heads discovered a division of labour, the way an experienced team settles, without discussion, into who watches what.
That is the first limitation dissolved. A token no longer follows a single thread; it follows a whole braid of them, in parallel, and leaves with all of them woven into its updated representation.
Part III — The thinking step
Now the subtler limitation, and the part of the transformer that most explanations skate over even though it holds the majority of the model's substance.
Attention, even multi-headed, is fundamentally an act of gathering. It reaches out, collects the relevant values from around the sentence, and blends them in. But blending is not reasoning. Having assembled "this token is a pronoun, its antecedent is the surgeon, the mood is one of admitted fault," something must now do something with that assembled picture — transform it, draw an inference from it, turn the gathered ingredients into a new conclusion. Gathering sets the table; someone still has to cook.
That cooking is done by the second half of the block: a small, ordinary neural network applied to each token independently, once its context has been gathered. It is often called the feed-forward layer or the MLP, and mechanically it is the simplest thing in the whole architecture — take the token's vector, pass it through one expanding transformation and a nonlinearity and one contracting transformation, and out comes a new vector. No looking at other tokens; no attention. Each token, alone, thinks about what it has just gathered.
So the block has a rhythm, and it is worth naming because it is the whole design in four words: communicate, then compute. First the tokens talk to each other and gather what they need (multi-head attention); then each retreats and thinks about what it gathered (the feed-forward network). Reach out; reflect. Gather; digest. It is a rhythm any clinician will recognise from the ward round itself — first you collect the relevant information from everyone around the bed, then you step back and reason about the case on your own.
Part IV — The stream that holds it all together
We now have the two working halves. But how are they wired together — and stacked, dozens of times, without the signal degrading into noise? The answer is one more idea, quiet but load-bearing, and it changes how you should picture the whole machine.
Do not picture the block as a pipe that transforms a token and passes on a replacement. Picture instead a residual stream: a running vector for each token that flows straight up through the entire model like a central highway, and onto which each sub-layer adds its contribution rather than overwriting what was there. Attention does not replace the token; it reads the current state of the stream and adds what it gathered back onto it. The feed-forward layer does not replace the token; it reads the stream and adds its computed refinement. The stream is never wiped and rewritten — it is a chart that each stage annotates and passes upward, thicker with meaning at every step.
Why addition, and why does it matter so much? Two reasons, one practical and one conceptual. Practically, adding rather than overwriting gives the training signal a clean, unobstructed path all the way down through even a hundred stacked blocks — the reason very deep networks became trainable at all, and a point we will feel the force of in the next chapter on training. Conceptually, the residual stream lets each block make a modest edit to a shared, evolving representation rather than reinventing it from scratch. A block does not have to solve the whole sentence; it just has to add one useful annotation and pass the chart along. Small edits, stacked deep, compound into something that looks remarkably like understanding.
Part V — Depth: the tower
And now the step that turns a clever unit into a mind-like thing. We take the block — attention, then feed-forward, both adding to the residual stream — and we stack it. The output stream of one block is the input stream of the next, unchanged in shape, so the blocks pile up cleanly: a dozen high in a small model, dozens in a large one, well past a hundred at the frontier. This is the tower, and depth is where the magic quietly happens.
Watch what accumulates as a token's vector rises through the stack. In the earliest blocks, the annotations are close to the surface — resolving a word's part of speech, binding a pronoun, noting simple local structure. A little higher, the edits grow more abstract — assembling phrases into clauses, tracking who did what to whom, registering tone. Higher still, the representation carries things no single word contains — the gist of an argument, the state of a story, the constraint that the next word must satisfy. Meaning is not computed in one heroic step. It is refined, layer upon layer, each block adding a slightly more abstract reading of the same underlying text, until near the top the stream holds a representation rich enough that the single most useful thing left to do is predict what comes next.
Part VI — Reading the answer, and closing the loop
We have built the tower. One final, almost anticlimactic step converts it back into the thing Chapter Two promised: a forecast.
At the very top of the stack, we take the residual-stream vector — but only at the last position, the token after which we want to predict — and we project it, through one more learned transformation, out to a list of scores with one entry for every token in the vocabulary from Chapter One. Softmax turns that list of scores into a probability distribution, and there it is: antibiotics 41%, steroids 12%, the whole forecast we drew in Chapter Two, now actually computed, from the bottom of the tower to the top. The machine has read the tokens, refined their meaning through dozens of layers of communicate-then-compute, and read off, at the summit, its best guess at what comes next.
Take a moment with what we have assembled, because it is the whole thing. Text becomes tokens (Chapter One). Tokens become vectors in a space of meaning, carrying their positions (Chapter Two, and Part I here). Those vectors flow up a deep tower, and at every level they gather context from one another through many-headed attention (Chapter Three) and then think privately in the feed-forward layers (this chapter), adding refinement after refinement to a residual stream that is never overwritten, only enriched. At the summit, the enriched vector is read off as a forecast of the next token. That is a large language model. There is no other secret ingredient. Everything else — the scale, the training, the polish — is in service of this architecture, not in addition to it.
Part VII — The machine is built, but it is empty
And yet — for all that we have assembled — we have not actually explained the most important thing.
Go back and count the pieces that were simply given to us, fully formed, throughout these four chapters. The embedding table that places aspirin near ibuprofen. The query, key, and value projections that let attention know what is relevant. The feed-forward layers that hold the model's knowledge. The combining projections, the output projection, every last one of the millions or billions of numbers that make this tower do anything at all. Where did they come from? Who set them?
We already glimpsed the unsettling answer back in Chapter Two: nobody set them. They all begin as random noise. The magnificent engine we have just built, if you constructed it today and ran a sentence through it, would produce pure gibberish — a confident forecast of an entirely random next token — because every projection in every head, every weight in every feed-forward layer, is meaningless static. We have built the body in exquisite detail. It has no mind in it yet.
What fills it — what turns billions of random numbers into an embedding space that knows medicine and attention heads that track pronouns and feed-forward layers that store facts — is training: the relentless process by which the single pressure to predict the next token, applied across a large fraction of everything humans have written, reaches back through this entire tower and nudges every one of those numbers, billions of times, until gibberish becomes fluency. We have deferred the mechanism of that "reaching back" three times now. We can defer it no longer.
How a guess at a single next token can reach all the way down through a hundred layers and correct every parameter that contributed to it — how noise becomes knowledge — is the subject, at last, of Chapter Five.
— Neal