Pick the 2026 task where an encoder-only transformer still beats a decoder-only LLM
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
Encoder-only transformers like BERT and ModernBERT still own dense retrieval and reranker bases in 2026.
Imagine two specialists. One is a librarian who reads any document from start to finish and then writes a single short fingerprint that summarizes the whole thing. The other is a novelist who can keep typing forever, one word at a time, picking up cues from everything written so far. For the question 'turn this paragraph into a number you can store in a database and search later', you want the librarian. They read both directions at once, they are fast, and they specialize in producing one tidy fingerprint per input. For the question 'write me a thousand-word reply that responds to my last three messages', you want the novelist. The librarian was never trained to generate; ask them to write a reply and they have nothing to give you. Encoder-only models are the librarian. Decoder-only LLMs are the novelist. Pick by the question, not by which one is fancier in 2026.
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.
4 min: encoder-only shape and bidirectional attention, MLM pretraining, why ModernBERT dominates retrieval, why decoder LLMs lose on cost, what encoder-only fundamentally cannot do.
| Property | Encoder-only (BERT, ModernBERT) | Decoder-only (GPT, Llama, Claude) |
|---|---|---|
| Attention | Bidirectional, no causal mask | Causal, left to right only |
| Generation | Cannot generate tokens | Autoregressive generation |
| Typical output shape | (batch, seq_len, d_model) hidden states pooled to one vector | Token stream |
| Pretraining objective | Masked-language modeling (MLM) | Next-token prediction (NTP) |
| Param range in 2026 | ~30M to ~500M (ModernBERT, bge-reranker) | 1B to 1T+ (Llama 4, GPT-5.5) |
| Primary 2026 use | Retrieval embeddings, rerankers, classifiers | Chat, reasoning, agents, code, creative |
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating 'encoder-only' as just an older or weaker version of a decoder LLM. It is a different shape that produces bidirectional fixed-size representations and cannot generate at all.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.