Notes

Encoder-Decoder Transformer

The original transformer had two halves, and it was built for translation: one stack to read the source sentence, another to write the target one. Encoder-decoder models keep that split, which makes them a different animal from the decoder-only models that dominate chat.

How the halves divide the work

The encoder reads the whole input at once with bidirectional attention, so every token is interpreted with full knowledge of what follows it. The decoder then generates output left to right, attending to its own previous tokens and, through cross-attention, to the encoder's finished representation. Understanding the input and producing the output are separate computations with separate parameters — the architecture's defining property.

Where that pays off
  • Translation and summarisation, where a definite source text is being transformed rather than a conversation continued.
  • Long input, short output: the encoder pass runs in parallel over the whole source, and the decoder never re-reads it token by token.
  • T5 and FLAN-T5 are the models a reader will actually meet, with mT5 covering multilingual work — cheap, dependable workhorses for fixed text-to-text jobs.
Why chat went the other way

Scaling rewarded simplicity. A decoder-only stack trains on raw text with one objective and treats the prompt as a prefix of what it is about to write, so instruction following, few-shot prompting and dialogue all fall out of the same mechanism. An encoder-decoder needs a boundary between input and output, which is natural for a sentence to translate and awkward for an open-ended conversation.

An encoder-decoder transformer splits the model in two: an encoder reads the entire input with bidirectional attention, and a decoder generates the output left to right while consulting that representation through cross-attention. The design suits tasks with a distinct source text — translation, summarisation — and underlies T5 and mT5. Decoder-only models displaced it for chat, where prompt and response form one continuing sequence rather than separate input and output.

Think of an interpreter who listens to a whole sentence before saying a word. Hearing the end helps her understand the beginning, and only then does she start speaking, checking back against what she heard as she goes. An encoder-decoder model works like that: one half reads all of the input and makes sense of it, the other half writes the answer while consulting that understanding. It suits jobs with a clear before and after — translating a paragraph, shortening a report. Chat assistants use a simpler single-piece design instead, because a conversation has no tidy point where the input stops and the answer starts.