Decoding turns context into generated text by predicting the next token, repeatedly extending the sequence with already-generated tokens. Decoder models specialize in natural language generation and can stream output as it appears, which suits chatbots and other interactive applications. section 2.3.2
A decoder is useful because it:
- Uses shifted-right output and masked attention to generate the next token from preceding tokens. section 2.3.2
- Supports natural language generation, including chatbots and storytelling. section 2.3.2
- Can form the generation half of a full transformer, where encoder representations support conditional tasks such as translation and summarization. section 2.3.3
- Can produce fluent syntax while still risking unintended meaning and hallucinations. section 2.3.2
Decoder-only and full-transformer generation
GPT models exemplify decoder-only architectures that generate text token by token. A full transformer combines an encoder with a decoder for tasks such as translation or summarization. section 2.3.2 section 2.3.3
Figure 2.6 A decoder visualized. Decoders are the second half of a full transformer, and they excel at NLG tasks like chatbots and storytelling. Decoders improve upon previous architectures in the same way as encoders, but they shift their output one space to the right for next-word generation to help utilize the advantages of multihead self-attention.
Use the decoder visualization to trace shifted-right outputs, multihead self-attention, and the decoder’s role as the generation half of a transformer. section 2.3.2














