Decoder-Only Models Predict the Next Token

A decoder-only model aligns each visible prefix with the next token under a causal mask. Make the target shift explicit and distinguish parallel known-sequence training from sequential generation.

A decoder-only language model uses one causal token stream. At each position, it produces vocabulary logits for the next token while preventing information from later tokens from entering the current representation.

Make the Shift Visible

For the token sequence

A B C D

one training window can be written as:

input positionvisible prefixtarget
1AB
2A BC
3A B CD

The input tensor may contain A B C, with target tensor B C D. A causal mask ensures that output row 1 cannot read input B or C, even though all three input positions are processed in one parallel training pass.

Parallel Training Does Not Remove Causality

During training, the complete known sequence permits calculation of all positions at once. The mask preserves the conditional factorization:

p(B,C,DA)=p(BA)p(CA,B)p(DA,B,C).p(B,C,D\mid A)=p(B\mid A)p(C\mid A,B)p(D\mid A,B,C).

During generation, B is not available until it has been selected, so outputs are produced one token at a time. Training parallelism and generation order are different properties.

The Diagonal Depends on the Shift Convention

It is common for representation row tt to read input token tt and predict token t+1t+1. Under that convention the causal mask includes its diagonal. Other indexing or shifted-input descriptions can look different while encoding the same conditional problem. State tokens, rows, and targets rather than arguing from “strict” versus “inclusive” triangles alone.

Decoder-Only Does Not Mean Chat Model

The base architecture and next-token objective do not by themselves define an instruction-following assistant. Data selection, scale, post-training, decoding, retrieval or tools, and system policies alter observed behavior. This chapter uses GPT as an early representative of generative Transformer pretraining, not as a definition of every later LLM system.

Q1. Align a next-token target

For input row containing the visible prefix A B, what target appears in the table above?

Answer it first, then check.

Hint
Move one token to the right in the original sequence.
Solution
The target is C.
Not attempted
Review

Not marked done.

Reference

Pause and reflect

In your own words, note what you understood, what remains unclear, or what you want to revisit. The note stays with this lesson.

0 of 1 exercises marked done

Review

Not marked done.

LLM PrimerDecoder-Only Models Predict the Next Tokenhttps://llmprimer.com/transformers/transformer-architecture-families/decoder-only-models-predict-the-next-token© 2026 LLM Primer