Skip to content
AI & Machine Learning Medium #encoder-decoder#gpt#t5

Encoder-Decoder vs Decoder-Only

Original Transformer split. GPT keeps the decoder. T5 keeps both. Different fits, same primitives.

A free, animated encoder-decoder vs decoder-only you can read here or embed on any website, from Scrollchart.

Encoder-Decoder vs Decoder-Only

Encoder-Decoder vs Decoder-OnlyOriginal Transformer split input and output. GPT collapsed both into one causal stack.Encoder-Decoder (e.g. T5)Decoder-Only (e.g. GPT-4, Llama-3)Source tokensEncoder block x NEncoder outputbidirectional self-attnTarget tokens (shifted)Causal self-attentionCross-attention (enc out)Feed-forwardOutput logitsK, VPrompt + completionCausal self-attentionFeed-forwardx N layersOutput logitsno encoder, no cross-attn[prompt | completion]trained jointly, one causal maskAttributeEncoder-DecoderDecoder-OnlyPre-training taskSeq-to-seq (MLM encoder)Next-token predictionAttention typeBidirectional + crossCausal (left-to-right)Fits bestTranslation, summarisationOpen-ended generation, chatExamplesT5, BART, mT5GPT-3/4, Llama, MistralDecoder-only dominates open-ended tasks because prompt and completion share the same KV cache pass; encoder-decoder excels where input and output are structurally distinct (translation, summarisation).

Two architectures. Encoder-decoder: encoder builds representations, decoder cross-attends. Decoder-only: causal stack on the prompt + completion. Strengths in seq2seq vs open-ended generation annotated.

Good for

  • Architecture comparison articles contrasting T5, BART, and GPT-family models
  • Course material on the original Transformer paper and subsequent decoder-only simplification
  • Practical guides for choosing model architecture given a downstream task type

Source & accuracy

This encoder-decoder vs decoder-only is an editorial illustration built to represent the concept accurately. Where it shows figures, they are typical or representative values chosen to make the relationship clear, not a single underlying dataset. The diagram and its explainer are reviewed and maintained centrally, and updated over time as understanding improves.

Two ways to split (or not split) the transformer

The original Transformer (2017) had an encoder and decoder. The encoder processes the input bidirectionally (no causal mask); the decoder attends to both the input (via cross-attention) and generates autoregressively. T5 follows this pattern. GPT-style models use only a decoder, attending to the input as part of the same sequence it generates from.

The encoder-decoder split is natural for tasks like translation, where input and output languages are distinct. Decoder-only is simpler: everything is one left-to-right sequence.

Capacity allocation and cross-attention overhead

In encoder-decoder, roughly half the parameters are in the encoder (understanding input) and half in the decoder (generating output). This specialization can be efficient for tasks with clear input-output separation. Cross-attention (decoder attending to encoder outputs) adds compute but allows the decoder to focus on generation, not input processing.

Decoder-only allocates all parameters to a single sequence understanding task. Modern large models (GPT-4, Llama) are decoder-only, suggesting that unified processing of input and output in a single stack is more efficient at scale.

Task fit and practical differences

Encoder-decoder is better for abstractive summarization, machine translation, and question-answering where the input is read once and the output is generated. Decoder-only is better for in-context learning and long conversations because the same sequence understanding mechanism handles both past outputs and future generation.

Most new models are decoder-only because in-context learning (the ability to adapt to new tasks from examples in the prompt) has proven more valuable than architectural specialization.

Embed this diagram

Add this animated encoder-decoder vs decoder-only to your own site. Copy one line of HTML, or use the embed builder for theme and sizing options.

Reference

What this is
A free, embeddable, animated encoder-decoder vs decoder-only for any website.
Who uses it
AI/ML blogs.
How to embed
Copy one line of HTML. No signup. No watermark. Works in WordPress, Webflow, Ghost, Substack, plain HTML.
File size
iframe embed, ~80 KB gzipped (loads on demand, does not block your page paint).
License
Free forever. Editorial explainer text included; updated centrally over time.

Embed format options

Copy the universal HTML snippet, the WordPress shortcode, or an iframe fallback - see the WordPress plugin page for details. Any format keeps the same Core Web Vitals profile and the same explainer text.

Embed snippet
<div data-scrollchart="encoder-decoder-vs-decoder-only" data-scrollchart-v="1"></div>
<script src="https://scrollchart.com/embed.js" async></script>

Frequently asked questions

Where can I get a free animated "Encoder-Decoder vs Decoder-Only" for my website?
Scrollchart provides "Encoder-Decoder vs Decoder-Only" as a free, embeddable animated diagram you can add to any website with one line of HTML. No signup is required and there is no watermark. The diagram and its explainer text are served from scrollchart.com, so the embed stays current without any maintenance on your end.
How do I embed a encoder-decoder vs decoder-only in a developer or tech blog?
Copy the one-line snippet from the Scrollchart diagram page and paste it into your post HTML. It works in any static site generator, CMS, or hand-coded HTML page. The embed is a thin loader, not an iframe, so the content is fully in your DOM.