The Prediction Game: How Tokens Learn to Mean Something
At the close of the last chapter we had reduced a page of writing to a row of integers — token IDs, the grain into which language had been ground so a machine could swallow it. And I was careful to insist on something that should still be nagging at you: those integers mean nothing. Token 5,317 is not "closer" to token 5,318 than to token 90,001. The numbers are arbitrary labels, handed out in the order the tokenizer happened to build its vocabulary. If the model is ever going to seem to understand anything, that understanding cannot come from the numbers themselves. It has to be built.
This chapter is about how it gets built, and the answer comes in two movements that feel, at first, unrelated. The first is a goal — a single, almost comically modest task that the entire apparatus is trained to perform. The second is a transformation — the first thing the machine does to a token, which quietly turns a meaningless ID into something with the beginnings of meaning. By the end you will see that these two are not separate at all: the goal is what creates the meaning, as a kind of side effect, and that fact is the strangest and most important idea in the whole subject.
Let us take the goal first, because it is so small that its power is easy to miss.
Part I — The whole game is "what comes next?"
Here is the entire objective a large language model is trained to accomplish. Ready?
Given a sequence of tokens, predict the next one.
That is it. That is the whole game. Not "understand the passage," not "answer the question," not "reason about the world" — just: here are some tokens, guess what token comes after them. A model that has read "the patient was prescribed a course of" is asked, simply, to fill in the blank. Antibiotics? Steroids? Physiotherapy? It must produce its best guess, and it is scored on nothing more than whether it matched the token that actually came next in some real piece of text.
The first time you hear this, it is genuinely deflating. All of it — the essays, the code, the eerie fluency, the appearance of thought — trained on a task you would set a parrot? It sounds like a category error, as though someone claimed that memorising a phone book could teach you to hold a conversation.
And then, if you sit with it, the deflation inverts into something closer to awe. Because think, really think, about what it would take to be good at this game. To reliably predict the next token in any text drawn from the whole internet, you cannot get by on surface tricks. Consider what predicting the blank actually demands across different sentences:
“2, 4, 6, 8, ___” → requires a pattern
“She lied to him, so he no longer ___” → requires a theory of people
“def add(a, b): return a ___” → requires the logic of code
“The murderer, it turned out, was the ___” → requires holding a whole story in mind
To fill in the last blank correctly for a detective novel, the model would have to have tracked the plot, the clues, the misdirections — everything. The task is a keyhole, and behind the keyhole is a door that opens onto the whole of what the text was about. This is the pivotal realization of the entire field, and I want to state it as plainly as I can.
A machine that could truly predict the next word of an arbitrary text would, somewhere inside itself, have to understand that text — and that back-door is the entire trick.
Everything downstream in this book — every capability, every failure — is a consequence of pushing a system relentlessly toward that one keyhole and seeing what it grows in order to fit through.
Part II — The model never gives an answer. It gives a weather forecast.
There is a subtlety here that trips up almost everyone, and getting it right now will save you endless confusion later. When we say the model "predicts the next token," it is easy to picture it confidently declaring a single winner. That is not what happens, and the difference matters enormously.
The model does not output a token. It outputs a probability for every token in the vocabulary at once — all hundred thousand of them from Chapter One. Given "the patient was prescribed a course of", its actual output is something like: antibiotics 41%, steroids 12%, treatment 9%, physiotherapy 4%, and a long, long tail of ever-smaller probabilities trailing off through every other token it knows, including the absurd ones. It is not an answer. It is a forecast — a full distribution of confidence spread across every possible next word.
This forecasting nature explains a fact everyone has noticed: ask the same model the same question twice and you may get two different answers. That is not a bug, and it is not the model "changing its mind." It is because generating text involves drawing from the distribution, and a draw has an element of chance. How much chance is governed by a single dial you have very likely met in an API or a settings panel: temperature. Turn the temperature down toward zero and the model almost always takes its single most probable token — reliable, repetitive, a little robotic. Turn it up and the draw gets more adventurous, reaching further into the tail — creative, surprising, and increasingly liable to wander into nonsense. Temperature is quite literally a knob on how much you let the dice matter.
So: the goal is prediction, and the output is a forecast we sample from. But we still have not answered the question this chapter opened with. The forecast has to be computed from the input tokens — and the input tokens, remember, are meaningless integers. How does a meaningless integer participate in producing a rich probability distribution? For that, we need the second movement: the transformation that gives a token its first foothold on meaning.
Part III — Giving every token a place in space
Here is the idea, and it is one of the most beautiful in all of machine learning. We are going to stop representing a token as a number, and start representing it as a location.
Picture a vast space — not the three dimensions we live in, but hundreds or thousands of them; hold the intuition even though you cannot picture the dimensions. Every token in the vocabulary is assigned a point in this space, specified by a list of numbers called a vector — its coordinates. The token dog is at one location; cat is at another; lisinopril at another still. This assignment — this big table mapping each of the hundred thousand tokens to its vector — is called the embedding, and the vectors are called embeddings too. It is, quite simply, the first thing that happens to a token once it enters the model: its ID is looked up in this table and swapped for its coordinates.
Now, why on earth would coordinates be better than a number? Because coordinates have neighbours, and neighbours can carry meaning. A single number line can only say "bigger" or "smaller." But a high-dimensional space can arrange its points so that things with similar meaning sit close together, and — this is the astonishing part — so that directions in the space correspond to relationships.
The famous demonstration of the direction idea, in ordinary-language embeddings, is almost a magic trick: take the vector for king, subtract the vector for man, add the vector for woman, and you land very near the vector for queen. The "royalty" and the "gender" of a word turn out to be directions you can travel along. In a medical embedding the same structure appears in our own vocabulary: aspirin is to NSAID roughly as lisinopril is to ACE-inhibitor — the "is-a-member-of-this-drug-class" relationship is a consistent bearing in the space. The model was never handed a drug classification. It reconstructed one, as geometry, purely from how these words are used.
If this idea of meaning-as-geometry feels important, that is because it is: it returns, scaled up from single tokens to whole documents, when we reach the chapter on retrieval — the mechanism behind grounding a model in your own files. The geometry you are meeting here, at the level of one token, is the same geometry that will later let a machine search a library by meaning rather than by keyword. Learn it once, here, and it pays dividends twice.
Part IV — Nobody puts the meaning there
Now for the part that genuinely borders on the uncanny, and that ties this chapter's two movements into a single knot.
Where does the arrangement of Figure 2 come from? Who decided that aspirin and lisinopril should be neighbours, that the drug-class direction should be consistent, that the space should be organised so beautifully? Surely a team of doctors sat down and placed the medical terms by hand?
No. Nobody placed anything. At the very start, before any training, the embedding table is filled with random numbers. Every token is flung to a random point in the space. aspirin and poetry and dialysis are scattered like buckshot, no cluster, no structure, no meaning whatsoever. The map begins as pure noise.
And then the prediction game begins. The model is shown ocean after ocean of real text and asked, over and over, to predict the next token — and every time it guesses, it is nudged to guess a little better. Crucially, those nudges do not only adjust some separate "prediction machinery." They reach all the way back and move the embedding vectors themselves. If treating aspirin and ibuprofen as neighbours helps the model predict text about pain relief, then the training gently slides their vectors together. If keeping bank-the-river and bank-the-money distinguishable helps, the training pulls on those too. Token by token, nudge by nudge, over billions of predictions, the random scatter organises itself into the landscape of meaning — not because meaning was the goal, but because a meaningful map is what makes the prediction game winnable.
Pause on this, because it is the philosophical heart of the whole enterprise and it is almost never stated plainly. We did not teach the model what words mean. We could not have — nobody has a complete theory of what words mean. Instead we set up a game in which having a good internal model of meaning is rewarded, pointed the machine at a large fraction of everything humans have written, and let meaning precipitate out of the relentless pressure to predict. The understanding these systems have — such as it is — was not authored. It was distilled.
Part V — The gap a lone vector cannot cross
We have come a long way. Tokens have become points in a meaningful space; the space organised itself through the prediction game; and the game, we argued, is a keyhole onto genuine understanding. It would be easy to feel we are nearly done — that a model is just a big embedding table plus some machinery to read off predictions. But there is a crack in what we have built so far, and finding it precisely is what sets up everything to come.
Here is the crack. The embedding of a token is fixed. bank gets one vector, always the same, no matter where it appears. But consider two sentences:
“He deposited the cheque at the bank on the corner.”
The word bank means something utterly different in each — a muddy riverside in one, a financial institution in the other. Yet the embedding table, knowing nothing of context, hands over the identical vector for bank both times. A fixed point in space simply cannot be a riverbank here and a savings bank there. The single most important word for the meaning of each sentence arrives at the model wearing the same blank mask.
So we need something more. We need a token, once it has been given its starting vector, to look around — to see that "river" and "current" are nearby in one sentence and "deposited" and "cheque" in the other, and to let that company reshape its own meaning before any prediction is made. We need each token to stop being a fixed point and become a point that adjusts itself in light of its neighbours.
This is not a small tweak. It is the central mechanism of the entire architecture — the thing that separates a modern language model from every earlier attempt, the idea that made all of this work at last. It has a name, and you have heard the name even if you have never been shown what is under it.
It is called attention. It is the reason these models are built the way they are. And building it, from nothing, so that you understand not just what it does but why it was the answer everyone was reaching for — that is Chapter Three.
For now, hold the shape of what we have. A token enters as a meaningless number. It is handed a place in a vast space of meaning — a place that was not designed but grown, distilled out of the single pressure to predict what comes next. And there it sits, rich but static, wearing the same face in every sentence, waiting for permission to turn its head and look at the words around it.
We are about to grant that permission. And when we do, the whole thing comes alive.
— Neal