Describe what 'autoregressive' means for LLM generation.
Autoregressive generation samples one token at a time conditioned on every token before it. Each step emits a vocab distribution, samples a token, appends it to the context, and repeats until a stop condition fires.
Imagine writing a story one word at a time, where every word you pick depends on everything you have already written. After each word, you look back at the whole draft and ask, given all of this, what feels like the next word. You sample one option, write it down, and ask the question again with the longer draft. That loop is autoregressive generation. The model is the author, the draft is the context, the sampling step is the actual choice of word, and the loop only stops when the model itself decides to end the story (the end-of-text token), or when it runs into a stop word the user set, or when it hits a maximum length cap.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Autoregressive generation is the defining cost shape of LLM inference. The model factors the probability of a sequence as a product of conditionals, and serving realizes that factorization one token at a time. Token T+1 depends on token T, so the decode loop cannot parallelize across the output dimension. Every inference optimization in 2026, batching, KV cache, speculative decoding, multi-token prediction, exists because of this constraint.
This question is the foundation everything else builds on. A candidate who fumbles the per-step loop will fumble every downstream question about decode performance, throughput optimization, or speculative decoding. A candidate who explains it crisply has the mental model that makes the rest of inference engineering coherent.
The deep dive walks the mathematical framing, the per-step loop, the role of the KV cache, the termination conditions, and the optimization landscape that follows. By the end you should be able to explain why decode is the bottleneck of LLM serving and which optimizations attack which part of the autoregressive loop.
The factorization and what it encodes
An autoregressive language model factors the joint probability of a sequence into a product of conditionals, each one predicting the next token given all earlier tokens:
This factorization is exact for any sequence model; the modeling assumption is in the architecture (transformer with causal mask) and the training objective (maximize likelihood under this factorization). The causal mask in self-attention is what enforces the conditional dependency: when computing the representation for position i, attention scores at positions j > i are masked to negative infinity so they contribute nothing.
During training, the model learns all conditionals in parallel via teacher forcing: feed in the ground-truth sequence, predict every position at once, sum the cross-entropy loss across positions. During inference, the same conditionals are realized sequentially: sample t_1 from P(t_1 | prompt), then t_2 from P(t_2 | prompt, t_1), and so on. The training-inference asymmetry is the whole reason serving is hard.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
Real products, models, and research that use this idea.
- GPT-5.5, Claude Opus 4.7, Gemini 3.1 Pro, Llama 4 Maverick, and DeepSeek V4 are all autoregressive transformers; the entire frontier model lineup in 2026 still uses the same left-to-right factorization.
- vLLM, SGLang, and TensorRT-LLM all implement the same autoregressive decode loop under the hood, differing only in how they manage the KV cache and schedule the batches.
What an interviewer would ask next. Try answering before peeking at the approach.
QWhy is prefill parallel while decode is sequential, even though both use the same model?
Prefill processes the whole prompt at once; every position's Q, K, V can be computed in parallel because the causal mask hides future positions from each query. Decode generates token by token because token T+1 does not exist yet when computing token T; the conditional dependency is a sequential one. Same architecture, different access pattern.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Believing the model generates the full output in one shot. Each token is its own forward pass, conditioned on every earlier token, which is what makes decode slow and bandwidth-bound.
60 second bullets to scan on the way to the call.
The mathematical factorization that autoregression encodes
The four stages of the per-step decode loop
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.