Zenaique
Compare

Encoder-only vs Decoder-only vs Encoder-Decoder

Three transformer families and what each is optimized for

The verdict

Encoder-only understands text (BERT); decoder-only generates it (GPT, Llama); encoder-decoder maps input to output (T5, translation). Most modern LLMs are decoder-only.

Encoder-only

Glossary

Bidirectional attention over the input, then a task head. Used for understanding: classification, embedding, extractive QA. BERT is the archetype.

Best for: Text understanding: embeddings, classification, NER.

Decoder-only

Glossary

Causal (left to right) self-attention. Trained to predict the next token; generates by unrolling. GPT, Llama, Mistral, Claude are all this family.

Best for: Open-ended generation and general LLMs.

Encoder-Decoder

Glossary

Encoder reads the input bidirectionally, decoder attends to it while generating output. Original 'Attention Is All You Need' architecture, used by T5 and translation models.

Best for: Structured input to output tasks like MT and summarization.

At a glance

Encoder-only vs Decoder-only vs Encoder-Decoder: dimension-by-dimension comparison
DimensionEncoder-onlyDecoder-onlyEncoder-Decoder
Attention patternCausalEncoder-decoder cross-attentionBidirectional
Training objectiveNext-token predictionDenoising (T5) or seq2seqMasked language modeling
GenerationNativeVia decoderNone
Understanding tasksVia promptingYesYes (strong)
PrototypesGPT, Llama, Mistral, ClaudeT5, BART, mT5BERT, RoBERTa
Modern defaultChat and general LLMsMT + summarizationEmbeddings + classification

Key differences

  • 1Encoder-only sees the full input at once (bidirectional); decoder-only sees only prior tokens (causal)
  • 2Decoder-only generates; encoder-only can only classify or embed
  • 3Encoder-decoder separates the input-understanding and output-generation stages
  • 4Modern LLMs are almost all decoder-only because scaling and generation matter most
  • 5For embeddings, encoder-only or decoder-only embedding heads (E5, BGE) are both used today

In the interview

What they're really testing
Whether you can map task shape to architecture: understanding vs generation vs both.
Say this
Encoder-only stacks (BERT) run bidirectional attention over the input and are optimized for understanding tasks like classification and embeddings. Decoder-only stacks (GPT, Llama) use causal attention and are trained to predict the next token, which is why they dominate generation. Encoder-decoder (T5) splits the stack: encoder reads, decoder writes. It's still the default for translation and summarization, but for general chat and reasoning the decoder-only family scales better.
Traps to sidestep
  • Saying encoder-only models can generate text
  • Not knowing modern chat models are decoder-only
  • Confusing 'encoder-decoder' with 'bidirectional' (they're not the same)

How to choose

If chat, reasoning, or open-ended generationDecoder-only
If classification, NER, or embeddingsEncoder-only
If translation or focused input to output tasksEncoder-Decoder
If matching a strong existing checkpoint's designEncoder-only

Generation → decoder-only. Understanding → encoder-only. Structured mapping → encoder-decoder.

Common misconceptions

Myth: Encoder-decoder is the default modern LLM architecture.

Reality: GPT-style decoder-only stacks dominate modern LLMs. Encoder-decoder still wins on translation-shaped tasks.

Myth: Decoder-only can't do classification.

Reality: It can, via prompting or via decoder-only embedding heads (E5-Mistral, BGE-decoder). It's just not the historical shape for that task.

Memory aid

Encoder-only: reads. Decoder-only: writes. Encoder-decoder: reads, then writes.

Can you combine them?

Retrieval stacks routinely mix them: encoder-only embeddings for retrieval, decoder-only LLM for generation. The rare 'unified' stacks (RAG plus rerank plus generation) touch all three.

Related topics

Related comparisons