Appendix B — Architecture Comparison & Model Zoo

Technical course on encoder–decoder transformers — reference appendix.

Where this fits

This appendix is the side-by-side that Lessons 1 and 6 build toward. The three transformer families are not three different inventions — they are the same machinery under different attention masks (and different sources for keys/values). This sheet lays them on one table along the axes that actually distinguish them, then names the real models so the abstractions have faces. Read it after Lesson 6, or keep it open from the start as a map.


1. The three families on four axes

AxisEncoder-onlyDecoder-onlyEncoder–decoder
Attention maskbidirectional ($M=0$)causal ($M$ lower-tri)bidirectional encoder + causal decoder
Key/value sourceselfselfself (within each stack) + cross (decoder reads encoder)
New mechanism——cross-attention
Conditioning on inputn/a (no generation)implicit: input in the causal prefixexplicit: separate stack + cross-attention every decoder layer
Input readbidirectionallycausally (left-to-right)bidirectionally (by the encoder)
Generates output?no — produces representationsyes (continue the stream)yes (decoder, conditioned)
Pretraining objectiveMLM (mask & predict in place)next-token CEdenoising / span corruption
Parameters per layer$12d^2$$12d^2$$12d^2$ (enc) / $16d^2$ (dec)
Output lengths= input lengthone streaminput $n$, output $m$, decoupled
Natural tasksclassification, NER, retrieval, embeddingsopen-ended generation, chat, few-shottranslation, summarization, structured transduction

The progression left-to-right across “attention mask” is the whole story: encoder-only is all bidirectional, decoder-only is all causal, and the encoder–decoder mixes the two by giving each regime its own stack and bonding them with cross-attention. The prefix-LM (Lesson 6) is the fourth point — a single stack with a block mask that is bidirectional over the prefix and causal over the suffix, conditioning implicitly through shared weights instead of cross-attention.


The three families, laid on one table

Figure 1. The three families, laid on one table.

2. When to reach for each

Encoder-only when the task is understanding a fixed input and the output is a label, a span, or a vector — sentiment, classification, named-entity recognition, sentence embeddings, retrieval. No generation, so no decoder, so it is cheap and the bidirectional reading is pure upside.

Decoder-only when the task is open-ended generation, when you want one uniform stack that scales cleanly, in-context/few-shot learning, and a single model that does many things via prompting. This is the dominant general-purpose LLM design today. Seq2seq tasks are handled by concatenation (input → output), trading the encoder’s bidirectional reading for simplicity.

Encoder–decoder when the task is a genuine transduction with a clearly separate input and output — machine translation, summarization, grammatical error correction, data-to-text, speech-to-text — especially when reading the input well (bidirectionally) is decisive and the output length differs from the input. The compute-once memory and per-layer cross-attention conditioning are worth the extra stack here.

The field’s trajectory: 2017–2020 was encoder–decoder (MT) and encoder-only (BERT-era understanding); 2020 onward saw decoder-only scale to general-purpose dominance because one uniform causal stack is simpler to scale and prompt. Encoder–decoders persist where their inductive bias pays — translation and summarization systems, and many multimodal models whose decoder cross-attends to encoded image/audio features (the cross-attention of Lesson 4 reused across modalities).


When to reach for each

Figure 2. When to reach for each.

3. Model zoo

ModelFamilyNotable specifics
Original Transformer (Vaswani 2017)enc–decthe prototype; sinusoidal positions, post-norm, trained on WMT translation
BERT / RoBERTaencoder-onlyMLM pretraining, [CLS] pooling, no generation
GPT-2 / GPT-3 / Llama / Mistraldecoder-onlycausal, next-token CE, seq2seq by concatenation
T5 / mT5 / T5 v1.1 / Flan-T5enc–dectext-to-text framing, span corruption, relative position bias, RMSNorm/pre-norm
BART / mBARTenc–decdenoising autoencoder (5 noises), close to original Transformer; strong at summarization
Pegasusenc–decgap-sentence pretraining, purpose-built for summarization
UniLM / GLMprefix-LMsingle stack, prefix mask — the Lesson 6 middle ground
Whisperenc–decaudio encoder + text decoder; cross-attention bridges modalities
Flamingo / many VLMsdec + cross-attntext decoder cross-attends to a frozen vision encoder’s features

The last two rows make the broader point: once you see cross-attention as “queries from one sequence, keys/values from another,” the encoder–decoder pattern generalizes far beyond text-to-text — any time one modality or sequence must condition the generation of another, cross-attention is the bond.

The abstractions, with faces

Figure 3. The abstractions, with faces.


← Course index · Appendix A — Formulas · Appendix C — Acronyms


The figures in this lesson follow the shared figure key , which explains what every shape, line style and colour means.