Encoder-decoder model
An encoder-decoder model is a neural network in two parts: an encoder that reads the whole input into internal representations, and a decoder that generates the output from them step by step.
Encoder-decoder models were built for jobs that turn one sequence into another: translating a sentence, summarising an article, turning speech into text. The encoder reads the entire source first. The decoder then writes the target one token at a time, consulting the encoder's representation of the source as it goes and feeding each new token back in to choose the next.
The design took hold in machine translation in 2014. In June that year Kyunghyun Cho and colleagues described an RNN Encoder-Decoder, two recurrent networks in which one encodes a sequence of words into a fixed-length vector and the other decodes it into another sequence; they used it to score phrase translations in a statistical translation system. In September, Ilya Sutskever, Oriol Vinyals and Quoc Le published Sequence to Sequence Learning with Neural Networks, using deep LSTM networks for both halves. On a standard English to French test it scored 34.8 BLEU against 33.3 for a phrase-based statistical system, and the authors found that simply reversing the word order of source sentences improved performance markedly.
Squeezing a whole sentence into one fixed vector was a bottleneck, and attention, which lets the decoder look back at every part of the input, eased it. The 2017 transformer paper Attention Is All You Need kept the encoder-decoder layout but built both halves from attention alone, with six layers each. In every decoder layer an extra attention step takes its queries from the decoder and its keys and values from the encoder's output, so each word being written can draw on the whole source. It reached 28.4 BLEU on English to German and 41.8 on English to French, the second after 3.5 days of training on eight GPUs.
Later encoder-decoder transformers widened the idea beyond translation. In October 2019 Colin Raffel and colleagues introduced T5, which recast every text task, from classification to summarisation, as feeding text in and getting text out, and released the model with a large cleaned web dataset.
The best known chatbots today use decoder-only models, which drop the encoder and treat the prompt and the reply as one continuous sequence. Encoder-decoder models remain a natural fit where there is a clear input and a separate output to produce, and the terms still matter when reading model papers: they tell you how a system reads its input and where the work happens.
Tasks that convert one sequence into another, such as machine translation, summarisation and speech recognition. The encoder takes in the full input, and the decoder produces the output step by step while referring back to the encoded input. No. GPT models are decoder-only: they have no separate encoder and no cross-attention, and they generate text by predicting the next token from everything before it. The original 2017 transformer and models such as T5 are encoder-decoder designs. Seq2seq, short for sequence to sequence, is the name popularised by the 2014 paper by Sutskever, Vinyals and Le for models that map an input sequence to an output sequence. In practice it is used almost interchangeably with encoder-decoder model. An encoder-only model, such as BERT, stops after the encoder and outputs representations of the input, which suits classification and search. An encoder-decoder model adds a decoder that generates new text from those representations, which suits translation and summarisation.Common questions
What is an encoder-decoder model used for?
Is GPT an encoder-decoder model?
What is seq2seq?
How does an encoder-decoder model differ from an encoder-only model?
Search for "encoder-decoder transformer", "sequence to sequence learning" or "cross-attention" to see how the two halves connect. The original papers on arXiv are short and readable in their introductions, and encyclopedia articles and university course notes explain the architecture with diagrams. When reading model announcements, check the technical report for whether a model is encoder-decoder, encoder-only or decoder-only, since marketing pages rarely say.Finding more
Working out what this means for your business?
Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.