← AI ChannelInside AIChapter 31 / 255日本語

Volume 1 / Part 3 Mechanics — What Happens Inside / Chapter 31

Predicting the Next Word — That's All It Takes, Over and Over

About 7 min read

When ChatGPT dashes off a long explanation, what's actually happening under the hood? The honest answer is almost absurdly simple: the model just keeps guessing the next word (technically, the next token). Let's look inside this next-token prediction and see how it stacks up into full paragraphs.

Even long answers are just 'next word' on repeat

Ask an AI like ChatGPT a question, and a few hundred words can come back almost instantly. It feels like the model planned the whole structure before writing a single word. But that's not what's going on at all. What the model actually does is far plainer and far simpler.

Last time, we looked at the Transformer as a single picture, the whole architecture at once. This time we're zooming way into the last part of that picture: the output. After reading the input, the model's final job comes down to exactly one thing. Predict the next token.

A short one-word reply and a thousand-word explanation are built from the exact same repeated operation. It sounds hard to believe, but once you trace through the mechanics step by step, you'll find it's almost anticlimactically simple.

Think about a conversation with a friend where you blurt out the end of their sentence before they finish it. "The weather today looks kind of..." "...like it's going to rain, right?" Humans do this kind of context-based prediction unconsciously all the time. What an AI does is close to the same thing, just far more mechanical, applied to a far larger set of candidates, and repeated hundreds or thousands of times.

Remember this

Whether the output is long or short, the model is running the exact same single operation underneath, again and again.

The model doesn't output an 'answer' — it outputs a probability distribution

The model never hands you a single next word directly. What it actually outputs is a probability distribution across every token in its vocabulary. If the vocabulary contains tens of thousands of tokens, the model produces one giant table, with a number attached to every single one of them, all at once.

OpenAI's own Cookbook has a concrete example of this. Given the sentence "My favorite TV show is" and asked to predict what comes next, the model assigned something like 49.25% probability to "My" and 0.8% to "was," among other candidates, with every token in the vocabulary getting its own number. It's a bit like a lottery box stuffed with countless tickets, each one printed with its own odds of winning.

Picking one actual token out of that probability distribution is called sampling. Here's the part worth remembering: the token with the highest probability doesn't always win. Higher-probability tickets get drawn more often, but lower-probability ones can still come up. We'll look at what happens right after that pick in the next section.

A familiar comparison: the predictive text on your phone's keyboard is a miniature version of the same idea. Type "goo" and you'll see "good," "goodbye," or "google" pop up as suggestions, ranked behind the scenes by something like a probability score for what's likely to come next. Now imagine that candidate list ballooning out to tens of thousands of entries — that's roughly the scale of the probability distribution an AI model is working with.

Pick, then append, pick again — the autoregressive generation loop

The model reads in the entire sequence of tokens so far — all the context up to this point — and builds a contextual embedding for each one. From that information, it calculates the probability distribution for the next token. This whole mechanism is called autoregression, because the model keeps feeding its own past output back in as its own input.

Once a token gets picked from that probability distribution, it's simply appended to the end of the input sequence. Then the entire process runs again from scratch on this newly extended sequence. Predict, pick, append, predict again. This loop is literally what generating text is.

Picture someone following a recipe one line at a time, hands moving as they go. They can't see the finished dish in their mind, but by looking only at where things stand right now, they decide the next step, and eventually a full plate comes together. The generation loop works the same way: it uses only the context built up so far to decide its very next move.

Or think of a row of dominoes falling. The first tile falling knocks over the second, and the second falling knocks over the third. The generation loop runs on the same chain reaction: the token just chosen — the domino that just fell — becomes the material for the next prediction, which knocks over the next domino in turn. Unless something stops it, that chain keeps running all the way to the end.

Remember this

Pick a token, append it to the input, predict again. As long as that loop keeps spinning, the text keeps growing.

Why doesn't it just write everything at once?

Here's a fact worth pinning down: generation happens one token at a time, sequentially. The model never outputs an entire passage in one shot. No matter how long the final answer is, internally the model is dutifully repeating the same operation — predict the next single token — exactly as many times as the text is long.

This structure doesn't change even as models scale up. According to the 2020 paper that introduced it, OpenAI's GPT-3 was an autoregressive language model with 175 billion parameters. No matter how many parameters a model has, the basic motion — predict one, append it — stays exactly the same. It's a genuinely interesting fact that massive scale and a dead-simple underlying mechanism can coexist like this.

There's a post on OpenAI's developer community forum that captures this nicely. A user was confused, asking whether there was any simple way to get the API to predict just a single next token. The Chat-style API most people use returns a whole conversational reply at once, which hides the token-by-token exchange happening underneath. That user ended up using a parameter called logprobs and a custom script to print out candidate tokens alongside their probabilities. The machinery behind the generation loop usually stays invisible — you have to go digging for it.

Even at an outlandish scale like 175 billion parameters, what happens in a single processing step is still just one thing: predict the next token. Growing the model didn't create some shortcut for outputting whole paragraphs at once. It's more accurate to say that bigger models simply got much better at performing this plain, repetitive task with high precision.

Try peeking at the 'next word' yourself

You've probably noticed how ChatGPT's answers appear on screen bit by bit rather than all at once. That's not a visual effect for show. It's literally the generation loop running one token at a time, displayed live on your screen. Next time you're using it, watch a little more closely before you type your next message.

We've been saying "next word" throughout this piece, but strictly speaking it's "next token." In English, a single token is often shorter than a full word — a subword — so longer words get split across multiple tokens. Japanese works similarly, splitting into characters or subword units. Treat "word" in this article as a simplification used to make the mechanism easier to follow.

Have you ever noticed that asking the exact same question twice gives you slightly different answers? That's down to the sampling step, where a token gets picked from the probability distribution — and there's a specific parameter that controls how much that picking wobbles around. Next time, we'll dig into exactly what that parameter is.

If you have access to an AI API, try sending the same short question three times in a row. The opening of the response will likely come out a little different each time. Once you realize the model isn't deciding the whole answer upfront but redrawing the lottery ticket token by token, that variation starts to make a lot more sense.

Remember this

Text appearing on screen one piece at a time is literally the generation loop at work, visible in real time.

FAQ

Does an AI plan out the entire response before writing it?

No, it doesn't. The model calculates a probability distribution for just the next token, appends whichever token gets picked to its input, and then predicts again. Even a long answer is built entirely from this repeated, sequential process.

What's the difference between next-token prediction and autoregression?

Next-token prediction refers to a single pass: calculating the probability of the next token. Autoregression describes the full looping mechanism — feeding that prediction back into the input and predicting again, over and over.

Does the model always pick the highest-probability token?

Not necessarily. Higher-probability tokens are more likely to be chosen, but depending on the sampling method, lower-probability tokens can get picked too. This behavior can be tuned with parameters like temperature.

Ask the same question twice and get two different answers — next time, we take a close look at 'temperature,' the parameter behind that wobble.

Primary sources

This article organizes general knowledge based on our experience and public sources. Product specs, prices, and regulations reflect the time of writing (October 7, 2026) and may change.