liveBook · Manning

Decoder layer

A decoder layer is a Transformer block that transforms target-sequence representations using masked self-attention, feed-forward processing, and optionally cross-attention to encoder outputs.

How 2 Manning books explain it

Learn Generative AI with PyTorch

A Transformer building block composed of self-attention and feed-forward components, plus normalization and residual connections in this section.

How it is used
Forms the repeatable decoder unit for next-token prediction in translation, text generation, and music generation.
How deep it goes
Works through masked translation inputs and PyTorch forward passes, then shows how blocks are stacked into complete decoders.
Examples
Uses a five-token French target sequence, a 48-block GPT-2XL, and smaller text and music Transformers.
What you can do after
Build it from scratch in PyTorch as either an encoder–decoder layer or a decoder-only block, then stack it in a Transformer.

Read how Learn Generative AI with PyTorch explains decoder layer →

Inside Deep Learning: Math, Algorithms, Models

A transformer block that uses encoder outputs in a second attention stage for sequence generation.

How it is used
Supports sequence-to-sequence and autoregressive models that generate multiple outputs.
How deep it goes
Explains attention routing, residual structure, positional information, and future masking, but stops short of decoder implementation code.
Examples
Uses machine translation and sequence-to-sequence generation as application examples.
What you can do after
Understand how encoder outputs enter decoder attention and why autoregressive decoding requires a triangular mask.

Read how Inside Deep Learning: Math, Algorithms, Models explains decoder layer →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.