liveBook · Manning

Decode

As explained in LLMs in Production

A decoder is a neural-network component that generates an output sequence from an internal representation and, typically, previously generated tokens.

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.
figure

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

How LLMs in Production covers it

How deep it goes
Explains next-token generation, shifted-right outputs, attention blocks, strengths, and hallucination risks without detailing training procedures.
Examples
Uses GPT for decoder-only generation and translation or summarization for encoder-decoder generation.
What you can do after
Evaluate decoder-based generation by relating next-token prediction, streaming, conditional tasks, and hallucination risks to use cases.
How it connects
Connects decoders with encoders, transformers, multihead attention, masked language modeling, and natural language generation.

Also explained in

Compare how 15 books explain decode →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of LLMs in Production. The section links point to the parts of the book it draws on.