Match each transformer family to the kind of attention it uses
Four families flip three switches: causal masking, bidirectional self-attention, and cross-attention. Each family is defined by which combination of these its blocks use.
Imagine four types of newsrooms. The first lets every reporter read every other reporter's notes freely, all at once, that's encoder-only (BERT). The second lets each reporter only read notes written before their own, that's decoder-only (GPT). The third has a research team that reads everything freely and a writing team that reads its own past plus the research team's report, that's encoder-decoder (T5). The fourth treats the first half of the day like the first newsroom and the second half like the second, that's prefix-LM. The flipping of two switches (can I look both ways, can I see the other team) gives you four newsrooms.
Detailed answer & concept explanation~7 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
Name the three switches, walk each family's switch settings, give one example model per family, and close with why decoder-only dominates general-purpose LLMs in 2026 while encoder-only and encoder-decoder retain specific niches.
| Family | Self-attn mask | Cross-attn? | Primary task |
|---|---|---|---|
| Encoder-only | Bidirectional | No | Classification, retrieval |
| Decoder-only | Causal | No | Autoregressive generation |
| Encoder-decoder | Bidirectional (enc) + Causal (dec) | Yes | Translation, ASR, summarization |
| Prefix-LM | Bidirectional in prefix, causal after | No | Mixed generation + context |
Real products, models, and research that use this idea.
- BERT (encoder-only, 2018): bidirectional masked language modeling; still the basis for re-rankers and dense retrievers in 2026 production.
- GPT-5.5, Claude Opus 4.7, Llama 4 Maverick, Gemini 3.1 Pro, DeepSeek V4, Qwen 3.5 (decoder-only, 2026): the dominant LLM family.
- T5 (encoder-decoder, 2019): the canonical text to text design with cross-attention bridging encoder and decoder.
- Whisper (encoder-decoder ASR, 2022): audio encoder + text decoder with cross-attention, still the production ASR baseline.
- UL2 (prefix-LM, 2022): mixed bidirectional then causal training; demonstrated the prefix-LM design at scale.
What an interviewer would ask next. Try answering before peeking at the approach.
QIf decoder-only models have won the chat market, why is encoder-only still used for retrieval and re-ranking?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating encoder-only and the encoder of an encoder-decoder as different things. They use the same bidirectional self-attention; the difference is whether a decoder consumes their output.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.