Autoregressive factorization: from joint to conditionals
When you train a GPT-style language model, you’re really teaching it the probability of a whole token sequence by breaking it into easier conditional pieces.
We start with a sequence of tokens
.
Autoregressive factorization writes the joint probability as:
(With the convention that , since there’s no past.)
Why this is tractable
- The full joint over a large vocabulary is astronomically big if you try to model it directly.
- The chain rule of probability always lets you write a joint as a product of conditionals like above.
- An autoregressive LM (e.g. GPT) only needs to output one distribution at a time:
given a prefix , output over the vocabulary. - During training:
- You feed in the prefix tokens.
- The model predicts the next-token distribution.
- You do this for each position in the sequence.
- At inference:
- You sample from .
- Then sample from .
- And so on.
The model never has to store or enumerate the full joint distribution; it only implements a function mapping a prefix to a probability distribution over the next token. That’s what makes training and sampling tractable.
Concrete example
Say your vocabulary is tiny: ["I", "love", "cats", "."].
For the sequence: "I love cats .":
The autoregressive factorization is:
A GPT-style model, given the input tokens:
["I"]→ predicts["I", "love"]→ predicts["I", "love", "cats"]→ predicts
You can multiply the appropriate probabilities to get the sequence probability.