What is next-token prediction?
Next-token prediction is the task in which a language model computes the probability distribution of the next token from the preceding token sequence and being trained on that prediction; it is the pre-training objective and generation method of large language models.
Unlike masked language modelling, where hidden tokens inside a sentence are predicted from context on both sides, next-token prediction uses only the left context. Multi-token prediction extends it by predicting several future tokens at once.
- Topic
- Machine learning, models and training
- Also known as
- Causal language modelling
- Origin
- In neural language modelling, Bengio et al., 2003
How next-token prediction works
- Training text is split into tokens; at each position the model sees only earlier tokens.
- The model outputs a probability for every vocabulary token and is trained with cross-entropy loss to raise the true next token's probability.
- In training it receives the real previous tokens at each step, known as teacher forcing.
- In generation it appends its chosen token to the input and moves along the sequence.
Commonly confused terms
| Term | How it differs |
|---|---|
| Decoding strategies | Next-token prediction is the training objective and probability modelling step, whereas decoding strategies (greedy, temperature, top-k, top-p, beam search) are inference-time rules that pick the actual token from that distribution. |
Why next-token prediction matters for on-premises AI
Needing no labels, next-token prediction scales to huge text corpora and teaches a wide range of skills from grammar to facts; an early neural language modelling study combined this objective with distributed word representations. Its limits are debated: one study argues teacher-forced training can fail to learn an accurate predictor on some planning tasks. For organisations, the model produces a likely continuation rather than the truth, so grounding is needed.
Seeing its policy assistant sometimes produce fluent but wrong clause numbers, an insurer grounds answers in sections retrieved from policy texts and requires each answer to cite its source section.
Common questions
How does next-token prediction differ from masked language modelling?
Next-token prediction uses only earlier context and suits generation. Masked modelling predicts hidden tokens from both sides.
Why can next-token prediction lead to hallucination?
The model predicts the most likely continuation, not the truth. Without grounding it can produce fluent but wrong text.
Related terms
- Language model
- Autoregressive model
- Masked language modelling
- Multi-token prediction
- Loss function
- Text completion
Sources
- Bengio et al., A Neural Probabilistic Language Model, JMLR, 2003
- Bachmann and Nagarajan, The pitfalls of next-token prediction, 2024
In the glossary: Glossary, M to Q