Encoder-Decoder
An encoder-decoder is a neural network architecture composed of two distinct modules: an encoder that reads the input and compresses it into an intermediate representation, and a decoder that reads that representation and generates the output token by token. The encoder's job is to extract meaning from the source; the decoder's job is to reconstruct or transform that meaning into a target form. This split is particularly natural for tasks where the input and output are in different languages or formats, such as machine translation, text summarisation, and speech recognition.
Think of it like a skilled interpreter at a diplomatic conference: one part of their brain listens to the foreign speaker and builds an internal model of what was said, and a separate part converts that internal model into fluent English — the two processes are distinct even though they happen in quick succession.
The architecture powers models like T5 (Text-to-Text Transfer Transformer) and BART. T5, for example, casts every NLP task as a text-to-text problem: you feed the encoder a string like "summarize: The quick brown fox..." and the decoder autoregressively generates the summary. This unified framing lets a single model handle translation, summarisation, and question answering using the same encoder-decoder scaffold.
Encoder-decoder models are distinct from decoder-only models (like most LLMs) that generate text without a separate encoding stage, and from encoder-only models like BERT that produce representations without generating text. The architecture relies on Attention mechanisms — specifically cross-attention that lets the decoder query the encoder's output at every generation step — and is a foundational pattern in the broader Transformer family.
You will encounter encoder-decoder designs when working with translation APIs, abstractive summarisation systems, code generation tools that take structured input (like a database schema) and produce natural language descriptions, and speech-to-text pipelines.