A decoder generates an output sequence from information prepared by an encoder. In translation, the encoder processes a source sentence into context; the decoder uses that context to produce a sentence in the target language. section 2.3
The way context reaches the decoder differs between architectures:
- In an RNN, the encoder produces a context vector. The decoder generates words one at a time, updating its recurrent state to remember earlier output. section 1.1.1
- In a transformer, the decoder uses encoded features and attention-derived context. Stacked attention and fully connected layers replace the RNN’s recurrent architecture. section 1.1.2 section 2.2
English-to-French translation
For “I don’t speak French,” the decoder’s job is to generate “Je ne parle pas français” using information obtained from the English input. section 1.1.1 section 1.1.2
Figure 2.5 The encoder of the transformer architecture is depicted on the left side of the figure, and the decoder is depicted on the right side.
The architecture diagram places the transformer encoder and decoder side by side, showing where output generation fits in the overall model. section 2.2














