Zenaique

Pick the 2026 task where an encoder-only transformer still beats a decoder-only LLM

MCQ·Easy·4.0 · 0·~1 min·Asked atDeepseekWandbWipro·Relevant atGoogleMicrosoft
Attempt it
TL;DR

Encoder-only transformers like BERT and ModernBERT still own dense retrieval and reranker bases in 2026.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

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.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

The interview signal here is not 'do you know BERT'. It is 'do you know which shape of transformer fits which task in 2026, given that decoder-only LLMs have eaten most of the field but encoder-only still owns retrieval and reranking?'

This card unpacks what encoder-only actually means architecturally, why dense retrieval is the natural fit, why the three generative options are immediate disqualifications, and where encoder-only models still beat 7B decoder LLMs on parameter and cost efficiency.

What 'encoder-only' commits you to architecturally

An encoder-only transformer stacks only the encoder half of the original 2017 design. Three commitments follow from that choice.

Bidirectional attention. Every layer is full self-attention with no causal mask. Token t can attend to every token in the sequence, including those after it. This is the central distinction from decoder-only LLMs, which use causal attention so token t can only see tokens 1 through t.

No generation head. The output is (batch, seq_len, d_model) hidden states. To turn that into text, you would have to attach a language-modeling head and swap the bidirectional attention for causal. At that point you have built a decoder LLM. Encoder-only is structurally not a generator.

MLM pretraining. The training objective is masked-language modeling: randomly mask ~15% of input tokens and ask the model to recover them from bidirectional context. The optional next-sentence-prediction objective from the original BERT paper is mostly dropped in modern variants. RoBERTa and ModernBERT use MLM only.

The shape produces strong per token representations and one strong pooled representation per input. Both of those are exactly what dense retrieval and reranking need.

Why dense retrieval is the right answer
Why the other three options are immediate disqualifications
Where encoder-only still wins in 2026
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
PropertyEncoder-only (BERT, ModernBERT)Decoder-only (GPT, Llama, Claude)
AttentionBidirectional, no causal maskCausal, left to right only
GenerationCannot generate tokensAutoregressive generation
Typical output shape(batch, seq_len, d_model) hidden states pooled to one vectorToken stream
Pretraining objectiveMasked-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 useRetrieval embeddings, rerankers, classifiersChat, reasoning, agents, code, creative

Real products, models, and research that use this idea.

  • ModernBERT (Answer.AI, 2024) is the 2026 reference encoder-only embedder: ~150M params, 8k context, beats many 7B decoder embedders on retrieval benchmarks.
  • bge-reranker-v3 (BAAI, 2024-2025) is an encoder-only cross-encoder reranker used widely in production RAG pipelines.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy does ModernBERT at 150M parameters beat a 7B decoder LLM as a retrieval embedder?
A

Two reasons. First, encoder-only's bidirectional attention lets every token aggregate context from both sides, which produces richer per token features for pooling into a single embedding than a causal model's left-only context. Second, MLM pretraining directly optimizes for producing representations that recover masked content, which transfers cleanly to retrieval; next-token prediction pretraining optimizes for generation, not for representation quality. A 7B decoder has many more parameters but most of them are tuned for a different objective.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

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.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Encoder-only attention is bidirectional, no causal mask

  • Encoder-only models cannot generate text, only consume it

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Explain scaled dot product attention.
Short answer·Medium