liveBook · Manning

Next-token prediction

As explained in The AI Pocket Book

A language-model training objective that predicts the next token in a sequence from preceding context.

Next-token prediction trains a language model to continue a sequence by estimating what token should come next. The token might be a word, part of a word, or punctuation. section 1.21

A simple training example

Given “Better safe than,” the desired next token is “sorry.” Given “The Eiffel,” it is “Tower.” Existing sentences can be subdivided this way to create many training examples without manually labeling each one. section 1.27

The model does not produce one certain answer internally. After processing the preceding context, it assigns a probability to every token in its vocabulary. Those probabilities form an output vector whose values add to 1. A wrapper then selects the next token, either by choosing the highest-probability option or by using another selection method that allows more adventurous output. section 1.21

This objective is powerful because language sequences contain examples of many activities, including translation and summarization. It is not the same as following instructions helpfully and safely, however. A model optimized to continue internet text can still invent facts, produce biased or toxic text, or ignore instructions. section 1.28

Table 1.1 In the last step, the LLM assigns a probability value
for each possible token in the vocabulary. All the values add to 1.

0.01

0.0

0.05

…

0.8

…

“a”

“b”

“c”

“audible”

Use the probability table to see how every possible next token receives a value, rather than treating prediction as a single fixed guess. section 1.21

How The AI Pocket Book covers it

How deep it goes
Explains labeled continuation examples, vocabulary-wide probabilities, token selection, and the objective’s alignment limits.
Examples
Uses “Better safe than sorry,” “The Eiffel Tower,” and a vocabulary probability table as concrete illustrations.
What it assumes
Assumes basic familiarity with language models while teaching token labels, probability vectors, and self-supervised examples directly.
What you can do after
Evaluate how language models generate continuations and why fluent next-token behavior does not guarantee helpful or factual responses.
How it connects
Connects self-supervised learning, language modeling, generalization, instruction following, and model misalignment.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The AI Pocket Book. The section links point to the parts of the book it draws on.