Skip to content

LLMs in the WildLesson 1 of 5

Three transformer architectures

Causal, bidirectional, and encoder–decoder attention

The Transformer series follows a causal decoder. The same basic operations can be arranged in other ways. Start by asking which information is available at each position.

ArchitectureAvailable contextTypical use
Causal decoderCurrent and preceding input tokensPredict the next token
Bidirectional encoderTokens on both sides within the inputBuild representations for classification or retrieval
Encoder–decoderEncoder reads the input; decoder reads earlier output plus encoder representationsGenerate an output conditioned on a separate input

A decoder’s hidden states are contextual too. At the word “boring” in “the film was not boring,” a causal decoder can use the earlier “not.” An encoder additionally lets the representation at “not” use the later “boring.”

The diagrams isolate attention patterns and stack arrangement. Full models can also differ in their training objectives, normalization, position encodings, and output layers.

For translation, an encoder can first represent the complete source sentence. A decoder then generates the translation token by token while attending to those source representations. The original Transformer paper used this arrangement.

A decoder-only model can also translate when given a source sentence in its prompt. Architecture enables certain computations; it does not assign each task exclusively to one model family.

The remaining pages examine prompting, training data, evaluation, and failure. The masked-language-model section explores encoders in more detail.

Sources · 4
  1. Devlin, J., Chang, M.-W., Lee, K., & Toutanova, K. (2019). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding. In Proceedings of NAACL-HLT 2019 (pp. 4171–4186). arXiv:1810.04805.
  2. 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. Journal of Machine Learning Research, 21(140), 1–67. arXiv:1910.10683.
  3. Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L., & Polosukhin, I. (2017). Attention Is All You Need. Advances in Neural Information Processing Systems 30 (NeurIPS 2017). arXiv:1706.03762.
  4. Jurafsky, D., & Martin, J. H. (2026). Speech and Language Processing: An Introduction to Natural Language Processing, Computational Linguistics, and Speech Recognition with Language Models (3rd ed., draft of January 6, 2026). Stanford University. Ch. 7 (Large Language Models); Ch. 10 (Masked Language Models).

Full bibliography →

Definition

Read the full glossary entry →