Attention Is All You Need

Vaswani et al., 2017, Attention Is All You Need (Advances in Neural Information Processing Systems 30 (NIPS 2017))

Subscriber deck — free during early access

2 cards in “3.2.3 Applications of Attention in our Model” · whole deck

3.2.3 Applications of Attention in our Model

  1. In which three ways does the Transformer use multi-head attention?
    Encoder–decoder attention (queries from the previous decoder layer, keys and values from the encoder output, so every decoder position attends over the whole input); encoder self-attention (all from the previous encoder layer); and masked decoder self-attention (each position attends to positions up to and including itself).
  2. How is decoder self-attention masked?
    Inside scaled dot-product attention, inputs to the softmax for illegal connections (from a position to later ones) are set to \(-\infty\), so their weights become 0 and the model stays auto-regressive.
    y₁y₁−∞−∞−∞−∞y₂y₂−∞−∞−∞y₃y₃−∞−∞y₄y₄−∞y₅y₅
    Rows are queries, columns keys: each position attends only to itself and earlier ones

Source