liveBook · Manning

Next-token prediction loss

As explained in Transformers in Action

Next-token prediction is the task of predicting the token that follows a given preceding token sequence.

Next-token prediction trains a model to predict the token following a sequence of preceding tokens. In decoder-only models, causal attention restricts each prediction to prior context. section 3.2

During generation, the model produces one token at a time and feeds its outputs back into the input. This recursive process supports sequences of arbitrary length within the model’s context window. section 3.2

Figure 3.1 Abstracted decoder-only architecture
figure

The decoder-only architecture diagram illustrates how causal attention and autoregressive generation relate to next-token prediction. section 3.2

How Transformers in Action covers it

How deep it goes
Defines the prediction objective and connects it to causal attention and autoregressive generation, without specifying a loss calculation.
Examples
Names GPT as a decoder-only system that uses next-token prediction.
What you can do after
Understand how decoder-only models condition predictions on prior tokens and generate sequences autoregressively.
How it connects
Connects next-token prediction with causal attention, autoregressive generation, and decoder-only transformers.

Also explained in

Compare how 9 books explain next-token prediction loss →

Related concepts

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