Bahdanau Attention › Summary

Michael BrenndoerferUpdated May 22, 20251 min read
Language AI HandbookAll chapters
Part 12 of 67Sequence-to-Sequence
Chapter 87Bahdanau Attention › Summary
Reading section 9 of 11 · Summary · 1 minSection 9 of 11 · 1 min

Book contents

Section 9 of 11 · 1 min read

Bahdanau Attention › SummaryOne section · Sections in this chapter9 / 11 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

Bahdanau attention solves the bottleneck problem in encoder-decoder models by allowing the decoder to dynamically focus on relevant parts of the input at each generation step. The mechanism works through a learned alignment model that scores how well each encoder position matches the current decoder state.

The key components are:

  • Additive score function: eij=va⊤tanh⁡(Wasi−1+Uahj)e_{ij} = v_a^\top \tanh(W_a s_{i-1} + U_a h_j) computes alignment scores by projecting the decoder state si−1s_{i-1} and encoder states hjh_j into a shared alignment space, combining them additively, and reducing to a scalar
  • Softmax normalization: αij=exp⁡(eij)∑kexp⁡(eik)\alpha_{ij} = \frac{\exp(e_{ij})}{\sum_k \exp(e_{ik})} converts raw scores to attention weights that form a probability distribution over encoder positions
  • Context vector: ci=∑jαijhjc_i = \sum_j \alpha_{ij} h_j computes a weighted sum of encoder states, where the weights αij\alpha_{ij} determine how much each position contributes to the context for generating output ii

The attention weights are interpretable, showing which input positions the model considers relevant for each output position. This interpretability, combined with strong empirical performance, made Bahdanau attention a foundational technique in neural machine translation and sequence-to-sequence modeling more broadly.

In the next chapter, we'll explore Luong attention, which offers alternative score functions with different computational trade-offs.