Why is a decoder-only architecture like GPT preferred for autoregressive text generation?

Last updated 22 November 2026

A decoder-only model is trained with exactly the factorization used at generation time: p(x) = Π p(x_t | x_<t). Training and inference therefore match, and generation is just repeated next-token prediction over a single growing sequence.

  • The causal mask matches the task: Each position sees only earlier tokens, so the model never relies on future context it won't have when generating.

  • Parallel training via teacher forcing:

    • All n next-token predictions in a sequence are computed in one forward pass, unlike RNNs.

    • This makes pretraining on huge corpora efficient.

  • Efficient incremental decoding:

    • Past keys and values never change, because of the causal mask, so they can be cached in a KV cache.

    • Each new token costs O(n) attention instead of recomputing the whole sequence.

  • No artificial input/output boundary:

    • Prompt, context, and response live in one stream.

    • This suits continuation, chat, and in-context examples better than a fixed source/target split.

  • Simplicity at scale: A single homogeneous stack with one objective is easy to scale, parallelize, and serve.

  • Contrast with encoder-only models: Bidirectional models like BERT have no natural left-to-right factorization, so generating from them is awkward.

  • https://medium.com/@datascientist.lakshmi/the-illusion-of-understanding-how-decoder-only-transformers-like-gpt-generate-and-summarize-15110969bcbe
  • https://sebastianraschka.com/books/ml-q-and-ai-chapters/ch17/
  • https://haroldbenoit.com/notes/ml/llms/architecture/encoder-decoder-models
All Transformers interview questions