Picture an interpreter at a conference: she first listens to a full sentence, distills it into a single idea, then rephrases it in another language. This is precisely the principle of the encoder-decoder architecture, a foundational deep-learning blueprint for turning an input sequence into an output sequence of a different length.
Two modules, one bridge
The architecture splits into two complementary blocks:
- The encoder reads the input sequence (words, pixels, audio samples) and compresses it into a dense internal representation called the context vector or latent state.
- The decoder starts from that representation and generates the output sequence one element at a time, conditioned on what it has already produced.
The flow can be summarised as:
$$ \mathbf{c} = f_{\text{enc}}(x_1, \dots, x_n) \qquad y_t = f_{\text{dec}}(\mathbf{c},\, y_1, \dots, y_{t-1}) $$
The attention breakthrough
Early versions (RNN/LSTM) squeezed the entire input into a single vector, creating a bottleneck for long sequences. The attention mechanism removed it: at each generation step, the decoder looks back at all encoder states and weights the relevant ones. This very idea gave rise to the Transformer in 2017.
Three major families
| Type | Encoder | Decoder | Typical use |
|---|---|---|---|
| Encoder-only | Classification, understanding (BERT) | ||
| Decoder-only | Text generation (GPT) | ||
| Encoder-decoder | Translation, summarisation (T5) |
This architecture powers machine translation, text summarisation, speech recognition, and image captioning.
Understand, then produce: the encoder-decoder is the backbone of sequence transformation.