Generative AI
Encoder, Decoder, and Encoder–Decoder Model Families
Compare major transformer model families and choose an architectural bias that matches the input-output contract.
By the end you can
- Distinguish bidirectional encoders, causal decoders, and encoder–decoder models
- Explain why BERT-like and GPT-like objectives create different default interfaces
- Match model families to classification, retrieval, extraction, and generation workflows
- Avoid treating one architecture family as universally superior
Comparison
Three transformer families expose different defaults
All can be adapted. But their pretraining masks and interfaces create useful biases — and the boxes leak at the edges.
The clearest evidence that they leak comes from the people who built one of them. BART is a denoising sequence-to-sequence model, published in 2020. Its abstract describes its own architecture entirely in terms of the other two columns: “It uses a standard Tranformer-based neural machine translation architecture which, despite its simplicity, can be seen as generalizing BERT (due to the bidirectional encoder), GPT (with the left-to-right decoder), and other recent pretraining schemes.” (The spelling “Tranformer” is as printed in the original.) BART matched RoBERTa on GLUE and SQuAD, and added gains of up to 3.5 ROUGE on abstractive summarization, dialogue and question answering.
So read the three columns below as positions on a continuum, described by the visibility their inputs get and the objective they were trained under. Not as a taxonomy of separate species.
Encoder-only
Build contextual representations from the full available input.
- Canonical example: BERT-like models
- Strong for classification, tagging, and retrieval encoding
- Masked objectives support bidirectional context
- No natural open-ended generation loop
Decoder-only
Predict continuations under a causal mask.
- Canonical example: GPT-like models
- Natural interface for open-ended generation
- Prompts express tasks inside the context
- Input understanding competes with generation behavior
Encoder–decoder
Encode a source, then generate a target while attending to that source.
- Canonical example: T5-like models
- Natural for translation and source-conditioned generation
- Separate source and target roles
- Serving may require both encoding and autoregressive decoding
Bidirectional encoders optimize representations, not dialogue
An encoder can let each input position attend to tokens on both sides, subject to the model’s masking scheme. That helps when the task needs a representation of the whole input — classification, or named-entity recognition.
The family’s defining bias is not folklore. Its authors wrote it into the first sentence of the abstract, in 2019: “BERT is designed to pre-train deep bidirectional representations from unlabeled text by jointly conditioning on both left and right context in all layers.” Not one direction, and not one layer. Both directions, in all layers.
What made this the default starting point for classification and extraction work is a set of numbers, not an impression. The paper reported new state-of-the-art results on eleven NLP tasks. It pushed the GLUE score to 80.5, MultiNLI accuracy to 86.7%, SQuAD v1.1 test F1 to 93.2 and SQuAD v2.0 test F1 to 83.1.
None of that makes the model “more understanding” because of what the family is called. It is biased toward producing contextual states that downstream heads can use. The eleven-task sweep is the measured consequence of that bias — a claim about benchmark scores, not about comprehension.
Causal decoders turn the task into continuation
A decoder-only language model predicts each next token from preceding context. Instructions, demonstrations, retrieved passages and tool descriptions are serialized into that context, which makes the interface unusually flexible. The same flexibility leaves a request open to more than one reading. The model may continue the style of an instruction without satisfying its hidden business constraints, so applications still need schemas, tools and validation.
The three families arrived within two years of each other, and each kept its own interface. BERT came in 2019, with a GLUE score of 80.5. T5 followed in 2020, recasting every text-based language problem into a text-to-text format and introducing the Colossal Clean Crawled Corpus. GPT-3 arrived the same year with 175 billion parameters and few-shot prompting — a count its paper describes as ten times more than any previous non-sparse language model.
None of the three retired the others. All three are still deployed.
Visual
Source-conditioned generation separates reading from writing
Encoder–decoder systems provide a distinct representation path for the source and a causal path for the target. The join between the two paths is a specific piece of architecture, and it has been specified in print since the family began.
The 2017 Transformer paper defined it in its section on encoder and decoder stacks: “In addition to the two sub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head attention over the output of the encoder stack.” That inserted third sub-layer is the entirety of what the step below calls attending across roles. It is not a mode the model enters. It is a layer that is there in every decoder block.
The design was justified by a translation result: 28.4 BLEU on WMT 2014 English-to-German, after training for 3.5 days on eight GPUs.
- 1
Encode the source
Bidirectional processing creates source representations.
- 2
Start the target
A decoder receives a start signal or partial output.
- 3
Attend across roles
Cross-attention lets target positions consult source states.
- 4
Generate autoregressively
Each target token conditions the next prediction.
- 5
Validate against the source
The application checks fidelity, coverage, and task constraints.
Key idea
Do not infer capability from family names alone
A decoder can perform classification through prompting. An encoder–decoder model can support dialogue. Fine-tuning and application design can move a model beyond its default interface.
One published experiment held scale and data constant across all three families and then asked which one wins. Wang and seven co-authors trained models of over 5 billion parameters on more than 168 billion tokens, and their 2022 abstract reports two results: “Our experiments show that causal decoder-only models trained on an autoregressive language modeling objective exhibit the strongest zero-shot generalization after purely self-supervised pretraining. However, models with non-causal visibility on their input trained with a masked language modeling objective followed by multitask finetuning perform the best among our experiments.”
Read the two sentences together. The same controlled comparison produced two different winners. What changed between them was not the architecture but the adaptation recipe. A ranking of the families is therefore never a property of the families alone. It is a property of the family plus the recipe plus the evaluation, and it reverses when any of those move.
The embedding world reports the same shape of answer from a much wider survey. The Massive Text Embedding Benchmark covers 8 embedding tasks, 58 datasets and 112 languages, and 33 models were benchmarked on it in 2023. The headline finding is a single sentence: “We find that no particular text embedding method dominates across all tasks.”
The correct comparison therefore includes quality, latency, throughput, context, training data, licensing, output constraints and evaluation results. “BERT versus GPT” is not a complete product decision.
Held at over 5 billion parameters and more than 168 billion tokens, the ranking of the three families still flipped when the adaptation recipe changed.
Analogy
Different workshops arrange the same tools differently
One workshop inspects an entire object before assigning a label. A second builds an object piece by piece. A third studies a blueprint before constructing a matching output.
Those workflows resemble encoder-only, decoder-only and encoder–decoder systems. Working habits are not limits. Real transformer families can be adapted, combined, and trained with objectives that blur these boundaries.
The BART abstract quoted earlier makes the same point in architecture rather than analogy. One published model is a bidirectional encoder and a left-to-right decoder at once, and its authors present that as generalizing the other two families rather than as a fourth kind of thing.
Use the family map to understand defaults, then evaluate the actual model and workflow.
Steps
Choose a family with a workload table
Document why the selected bias helps the intended task. Two rows of this table have published price tags attached to them, and both are large enough to decide a design on their own.
Step 3 asks about reuse of source representations. Reimers and Gurevych measured what that reuse is worth. Finding the most similar pair among 10,000 sentences takes about 50 million inference computations with a BERT cross-encoder. Their 2019 abstract states the consequence: “This reduces the effort for finding the most similar pair from 65 hours with BERT / RoBERTa to about 5 seconds with SBERT, while maintaining the accuracy from BERT.” Same family, comparable accuracy. The gap between hours and seconds is decided by one thing: whether the encoder output is computed once per document or once per pair.
Step 5 asks for an end-to-end benchmark, and quality moves as well as cost. Dense Passage Retrieval, in 2020, opened with the claim its experiments then supported: “In this work, we show that retrieval can be practically implemented using dense representations alone, where embeddings are learned from a small number of questions and passages by a simple dual-encoder framework.” That retriever outperformed a strong Lucene-BM25 system by 9%-19% absolute in top-20 passage retrieval accuracy across open-domain QA datasets.
And because MTEB found no method dominating across its 58 datasets and 33 benchmarked models, the last step cannot be delegated to somebody else’s leaderboard. The evaluation set has to be yours.
1. Describe the output
Is it a fixed label, vector, span, ranking, or open sequence?
2. Measure source length
Separate long input encoding from generated output length.
3. Estimate workload
Record volume, latency target, batching, and reuse of source representations.
4. Define constraints
Include schema fidelity, grounding, multilingual coverage, and deployment limits.
5. Benchmark end to end
Compare systems under the same data, evaluation set, and operational budget.
Key takeaways
- Encoder-only models default to contextual representations built from the available input. BERT was designed to pre-train “deep bidirectional representations” by conditioning on both left and right context in all layers, reaching a GLUE score of 80.5 and state-of-the-art results on eleven NLP tasks.
- Decoder-only models default to causal continuation and flexible prompt-based interfaces — the line GPT-3 extended to 175 billion parameters and few-shot prompting.
- Encoder–decoder models separate source representation from target generation through “a third sub-layer, which performs multi-head attention over the output of the encoder stack” in every decoder layer. That is the mechanism behind the original Transformer’s 28.4 BLEU on WMT 2014 English-to-German.
- BERT, GPT and T5 are useful reference families, not universal quality rankings. BART’s authors describe a standard encoder-decoder as generalizing BERT and GPT, and MTEB reports that “no particular text embedding method dominates across all tasks”.
- Architecture choice should include output form, workload, latency, constraints and measured behavior — the difference between 65 hours and about 5 seconds for one 10,000-sentence search is representation reuse, not family.
- Fine-tuning and application design can extend a model beyond its default family interface: at over 5 billion parameters and more than 168 billion tokens, the best family after self-supervised pretraining and the best family after multitask finetuning were not the same one.