Skip to content

Next-Token Prediction

The task on which all language models are trained: given a sequence of tokens, predict which token comes next.

Why This Is the Foundation

It sounds simple, but dialogues, translations and code all grow out of this task. To predict the next word well, a model has to absorb grammar, facts and logic — in effect, to understand the language.

How It Relates to Training

During pre-training the model goes through billions of texts and each time tries to guess the next token. The error is measured with cross-entropy and reduced by gradient descent. The lower the error, the more confident the model.

Onwards into Generation

A trained model works in the opposite direction: it predicted a token, added it, then predicted the next one. This is how autoregressive generation of text works.

See Also

← All Terms