Autoregressive decoder-only Transformer: Difference between revisions
Cite BERT, T5, BART, and Mamba for the architecture comparison (via update-page on MediaWiki MCP Server) |
m Rongzhou moved page Autoregressive decoder-only Transformers to Autoregressive decoder-only Transformer without leaving a redirect |
(No difference)
| |
Revision as of 15:14, 11 November 2026
An autoregressive decoder-only Transformer is a Transformer that retains only the decoder stack, so that each position attends to itself and to earlier positions only. At the time of writing (2026-08) it is the most widely adopted architecture for LLMs.[1]
Causal restriction
The defining property is the causal mask of self-attention, which forbids position $j$ from attending to any position beyond itself. Because the representation of position $j$ is then a function of $x_{1:j}$ alone, 1 forward pass over a sequence of length $T$ yields all $T$ next-token predictions at once,
$$ P_\theta(x_t\mid x_{1:t-1}), \qquad t=1,\cdots,T, $$
so training is fully parallel even though generation is not. The objective that results is the language model loss.
Autoregressive factorisation
Chaining those per-position conditionals reconstructs the distribution of the whole sequence,
$$ P_\theta(x_1,\cdots,x_T)=\prod_{t=1}^{T}P_\theta(x_t\mid x_{1:t-1}), $$
which is what makes the model generatable one token at a time. The policies for doing so are treated at decoding, and the cost of each step at self-attention and KV caching.
Relation to other architectures
- Encoder-only models, such as BERT, are bidirectional and are not generatable: they condition on both left and right context in every layer, and fill in masked positions rather than extend a sequence.[2]
- Encoder-decoder models, such as T5 and BART, split the 2 roles: the encoder reads the input, and the decoder attends to its output through cross-attention at every generated token.[3][4]
- Attention-free sequence models, such as state-space models, drop self-attention altogether and keep a fixed-size state, which removes the quadratic context cost and the KV cache along with it.[5]
Only the 1st is a decoder-only autoregressive model; all 3 nevertheless fall under the LLM definition.
- ↑ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, Ł., & Polosukhin, I. (2017). Attention Is All You Need. 5998–6008. https://doi.org/10.48550/arXiv.1706.03762
- ↑ Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. https://doi.org/10.48550/arXiv.1810.04805
- ↑ Raffel, C., Shazeer, N., Roberts, A., Lee, K., Narang, S., Matena, M., Zhou, Y., Li, W., & Liu, P. J. (2020). Exploring the Limits of Transfer Learning with a Unified Text-to-Text Transformer. https://doi.org/10.48550/arXiv.1910.10683
- ↑ Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., & Zettlemoyer, L. (2020). BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension. https://doi.org/10.48550/arXiv.1910.13461
- ↑ Gu, A., & Dao, T. (2024). Mamba: Linear-Time Sequence Modeling with Selective State Spaces. https://doi.org/10.48550/arXiv.2312.00752