An auto-regressive (AR) model is a type of generative model that predicts the next part of a sequence based on the previous parts. It generates outputs step by step, with each new output depending on the ones before it. In simple terms, It generates data one piece at a time, using past outputs to inform the next one.
1. Training Phase
The model learns to predict the next value/token in a sequence given all previous ones.
For example, in text:
Input: "The cat sat on the"
Target: "mat"
The model is trained to predict "mat" based on "The cat sat on the"
2. Generation Phase
Start with a seed (e.g., "The cat").
Predict the next token: "sat"
Add it to the sequence: "The cat sat"
Predict again: "on", and so on.
This sequential prediction continues until a stop condition is met (e.g., a special token or max length).
Text: Language models like GPT (Generative Pre-trained Transformer), BERT (in masked form), XLNet, etc.
Audio: WaveNet generates raw audio waveforms autoregressively.
Images: PixelCNN/PixelRNN generate images pixel by pixel.
For a sequence x=(x1,x2,...,xn)x = (x_1, x_2, ..., x_n)x=(x1,x2,...,xn), the joint probability is:
P(x)=P(x1)⋅P(x2∣x1)⋅P(x3∣x1,x2)⋅⋯⋅P(xn∣x1,...,xn−1)P(x) = P(x_1) \cdot P(x_2 | x_1) \cdot P(x_3 | x_1, x_2) \cdot \dots \cdot P(x_n | x_1, ..., x_{n-1})P(x)=P(x1)⋅P(x2∣x1)⋅P(x3∣x1,x2)⋅⋯⋅P(xn∣x1,...,xn−1)
So each element is conditioned on all previous elements.
Accurate modeling of sequences
Naturally suited for text, speech, music
Slow generation (since it’s step-by-step)
No parallelization during generation
Error accumulation: mistakes early on can ruin the rest of the sequence
Result:
Google colab Notebook page :