A decoder is a neural-network component that turns an internal representation into generated or reconstructed output. In language models, it produces text from encoder hidden states or, in decoder-only systems, from previously generated tokens. section 2.3
A decoder typically works through an iterative generation process:
- Receives encoder hidden states and a start token, or uses the tokens already generated as its context. section 2.8
- Predicts the next token, converts the prediction into text, and repeats the loop until the output sequence is complete. section 2.8
- In a variational autoencoder, samples a latent state and reconstructs an image, with randomness enabling varied outputs similar to the input. section 4.1.1
Two decoder roles
For text completion, a decoder predicts one token at a time until it forms a response. For image generation or restoration, a VAE decoder transforms sampled latent states into images, including reconstructed or inpainted content. section 2.8 section 4.1.1
Figure 2.3 Conceptual architecture of an LLM
Use the conceptual architecture to trace how tokenized input becomes embeddings, hidden states, decoder predictions, and final text. section 2.8














