Bahdanau Attention › The Alignment Problem

Michael BrenndoerferUpdated May 22, 20253 min read
Language AI HandbookAll chapters
Part 12 of 67Sequence-to-Sequence
Chapter 87Bahdanau Attention › The Alignment Problem
Reading section 2 of 11 · The Alignment Problem · 3 minSection 2 of 11 · 3 min

Book contents

Section 2 of 11 · 3 min read

Bahdanau Attention › The Alignment ProblemOne section · Sections in this chapter2 / 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

Before diving into the mathematics, let's understand the problem that Bahdanau attention solves. In a standard encoder-decoder architecture, the encoder processes the entire input sequence and compresses it into a single fixed-length vector. The decoder then generates the output sequence using only this compressed representation.

Out[4]:
Visualization
Diagram showing encoder states being funneled into a single context vector that feeds the decoder.
The bottleneck problem in standard encoder-decoder models. The entire input sequence must be compressed into a single fixed-length context vector, which becomes the sole source of information for the decoder. For long sequences, this compression loses critical details.

This bottleneck creates a fundamental problem: the context vector must somehow encode everything about the input that the decoder might need. For short sentences, this works reasonably well. But as input length increases, the fixed-size context vector becomes increasingly inadequate. Information gets lost, compressed, or muddled together.

The insight behind attention is that different parts of the output depend on different parts of the input. When translating "The cat sat on the mat" to French, generating "Le" depends mostly on "The," while generating "chat" depends mostly on "cat." Instead of forcing all this information through a single bottleneck, why not let the decoder directly access the relevant encoder states at each step?

Alignment

In the context of attention, alignment refers to the correspondence between positions in the input and output sequences. Good alignment means the model correctly identifies which input positions are relevant for generating each output position. Bahdanau attention learns this alignment jointly with translation, rather than relying on external alignment tools.