Skip to main content
AI / MLModel ArchitectureDiagramBeginner

Encoder vs Decoder

KO: 인코더 vs 디코더·EN: Encoder vs Decoder·JA: エンコーダ vs デコーダ

An architectural comparison between bidirectional Encoder models (BERT family, excelling at embeddings and classification) and causal autoregressive Decoder models (GPT family, excelling at generation)

Table of Contents

Structure Diagram

Encoder-Only (Bidirectional) vs Decoder-Only (Causal)
EncoderEncoder-Only (BERT)

Bidirectional attention · Understanding

  • AttentionFull left & right context simultaneously
  • Pre-trainingMasked Language Modeling (MLM)
  • Best ForEmbeddings, Rerankers, Classification/NER
DecoderDecoder-Only (GPT)

Causal masked attention · Generation

  • AttentionPast tokens only (causal mask)
  • Pre-trainingAutoregressive Next-Token Prediction
  • Best ForChat, coding, reasoning & agentic tasks
Quick Answer

What is Encoder vs Decoder?

An architectural comparison between bidirectional Encoder models (BERT family, excelling at embeddings and classification) and causal autoregressive Decoder models (GPT family, excelling at generation). It is a core concept in Model Architecture within AI / ML.

Core Principles

While the original Transformer paired an Encoder and Decoder for translation, modern AI largely specialized into two camps. Encoder-only models use bidirectional attention across the entire input—ideal for embeddings, reranking, and classification. Decoder-only models use causal masking for autoregressive next-token prediction, scaling into general-purpose reasoning and generation engines.

Practical Takeaways

  • Do not use a giant Decoder for every NLP task: For embeddings, reranking, NER, or guardrails classification, a 100M–500M Encoder is 50–100× cheaper and far faster than a frontier LLM.
  • Production RAG combines both: Encoders handle dense retrieval and Cross-Encoder reranking, while a Decoder synthesizes the grounded final answer.
  • Encoder-Decoder still shines in specialized Seq2Seq: Audio transcription (Whisper) and compact translation models remain top performers.

Notable Examples

  • Encoder-only: ModernBERT, DeBERTa, BGE-M3 embeddings, and Cross-Encoder rerankers.
  • Decoder-only: GPT, Claude, Gemini, Llama, and Qwen foundation models.
  • Encoder-Decoder: Whisper (speech-to-text) and T5/BART sequence-to-sequence models.