Skip to content
Sign in

What is Encoder-Decoder?

An Encoder-Decoder is a neural network architecture that uses one model (the encoder) to compress input data into a compact representation and a second model (the decoder) to generate output from that representation.

The encoder processes the input sequence step by step, typically with recurrent layers, building hidden states that capture the meaning of the data. At the end it produces a fixed-size context vector that summarizes the entire input.

The decoder takes this context vector and generates the output sequence one element at a time, using its own recurrent layers and often feeding its previous predictions back as input.

Modern variants replace the single context vector with attention mechanisms so the decoder can focus on different parts of the input at each step.

Example

In machine translation an English sentence is fed to the encoder; the decoder then produces the equivalent French sentence word by word using the encoded representation.

Why it matters

Encoder-Decoder models form the backbone of sequence-to-sequence tasks in NLP and are the direct precursor to the Transformer architecture used in today’s large language models.

Frequently asked questions

The encoder reads and compresses the input; the decoder generates the output from that compressed representation.