liveBook · Manning

Decoder layer

As explained in Inside Deep Learning: Math, Algorithms, Models

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

A decoder layer supports sequence generation by adding a second multi-head attention stage to the self-attention path. It usually works with an encoder: the encoder output supplies keys and values, while the previous attention result supplies queries. Residual connections organize both attention stages, and positional encodings provide sequence information instead of explicit recurrent time connections. section 12.5.2

For autoregressive use, account for these design points:

  • Use a triangular mask to prevent attention from seeing future inputs. section 12.5.2
  • Pair the decoder with an encoder for sequence-to-sequence tasks such as machine translation. section 12.5.2

How Inside Deep Learning: Math, Algorithms, Models covers it

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 it assumes
Assumes familiarity with multi-head attention and positional encodings, while distinguishing self-attention from attention over encoder outputs.
What you can do after
Understand how encoder outputs enter decoder attention and why autoregressive decoding requires a triangular mask.
How it connects
Connects encoder blocks, self-attention, multi-head attention, residual connections, positional encodings, and autoregressive models.

Also explained in

Compare how 2 books explain decoder layer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Inside Deep Learning: Math, Algorithms, Models. The section links point to the parts of the book it draws on.