Neural Machine Translation by Jointly Learning to Align and Translate
The paper introduced neural attention as a soft alignment mechanism that lets a decoder look back at source-token states instead of relying on one fixed-length sentence vector.
Metadata
| Field | Value |
|---|---|
| Paper | Neural Machine Translation by Jointly Learning to Align and Translate |
| Authors | Dzmitry Bahdanau, Kyunghyun Cho, Yoshua Bengio |
| Year | 2014 preprint; 2015 conference |
| Venue | ICLR 2015 |
| arXiv | 1409.0473 |
| ICLR PDF | conference archive |
| Status | full note started |
One-Line Takeaway
Bahdanau attention replaces the fixed encoder context vector with a learned soft alignment over encoder states for each decoder step.
Question
Early neural machine translation used an encoder-decoder architecture:
The encoder compresses the full source sentence into one fixed-length vector:
The decoder generates:
The bottleneck:
The paper asks:
Can the decoder learn where to look in the source sentence while generating each target word?
Main Claim
The narrowed architecture claim:
Instead of one context vector for the entire source sentence:
the model uses a different context vector at every decoder step:
Here:
- indexes target position;
- indexes source position;
- is an encoder annotation/state;
- is the learned attention weight.
Architecture Contract
| Component | Role |
|---|---|
| bidirectional encoder | builds source annotations |
| decoder RNN | generates target tokens autoregressively |
| alignment model | scores decoder state against source states |
| softmax over source positions | normalizes scores into attention weights |
| context vector | weighted sum of source annotations for target step |
| output model | predicts next target token from decoder state and context |
This is the architecture pattern:
Encoder Annotations
The encoder produces a sequence of annotations:
The paper uses a bidirectional RNN. A simplified form:
The annotation concatenates both directions:
Why bidirectional encoding matters:
The decoder does not attend to raw tokens. It attends to contextual source annotations.
Decoder State
The decoder is an autoregressive RNN:
The token distribution:
This means generation still proceeds left to right:
Attention changes the context interface, not the autoregressive factorization.
Alignment Model
The alignment score compares decoder state and source annotation:
A common additive attention form:
Then:
The attention weights form a distribution over source positions:
Reading:
But this should be read as a model-internal soft alignment, not guaranteed causal explanation.
Context Vector
For target position , the context vector is:
This is the core architecture move. The context is no longer fixed:
Each output step can use a different weighted mixture of source states.
The model therefore changes from:
to:
Fixed-Vector Bottleneck
The earlier encoder-decoder route:
forces all source information through one vector.
This is especially harmful for long sentences:
Bahdanau attention changes the memory interface:
The decoder now has differentiable random access to source positions.
Soft Alignment
Traditional machine translation used alignment ideas explicitly. Bahdanau attention learns soft alignments inside the neural model.
Hard alignment would choose one source position:
Soft alignment uses a distribution:
Then the context vector is differentiable:
This is why the alignment can be trained end to end by backpropagation from the translation loss.
Training Objective
The model maximizes conditional log likelihood:
With autoregressive factorization:
The attention parameters are trained through the same objective:
There is no separate supervised alignment label required.
Why It Matters for Attention
The paper made attention a reusable architectural primitive:
In Bahdanau attention:
| Role | Object |
|---|---|
| query | decoder state |
| keys | source annotations through scoring network |
| values | source annotations |
| weights | |
| readout | context vector |
This is not yet Transformer self-attention, but it establishes the central idea:
Additive vs Dot-Product Attention
Bahdanau attention is often called additive attention because the score uses a learned MLP:
Dot-product attention uses:
Scaled dot-product attention uses:
Reading:
| Attention Type | Score |
|---|---|
| additive | learned MLP over query and key |
| dot-product | inner product similarity |
| scaled dot-product | normalized inner product for stability |
The Transformer later uses scaled dot-product attention, but the alignment-as-soft-read idea is already present here.
Relation to RNN Encoder-Decoder
Bahdanau attention:
The difference is not only performance. It changes the interface from fixed vector compression to memory access.
Relation to Transformer
Transformer attention:
Bahdanau attention:
The shared abstraction:
The differences:
| Axis | Bahdanau Attention | Transformer Attention |
|---|---|---|
| backbone | RNN encoder-decoder | attention-only blocks |
| score | additive MLP | scaled dot product |
| query | decoder state | projected token states |
| memory | encoder annotations | keys and values |
| parallelism | decoder remains recurrent | self-attention highly parallelizable |
| role | remove fixed-context bottleneck | replace recurrence as sequence mixer |
Relation to Cross-Attention
Bahdanau attention is an early cross-attention pattern:
Modern cross-attention:
The direction matters:
This idea later appears in encoder-decoder Transformers, retrieval-augmented models, multimodal generation, and protein-ligand context mixing.
Evidence Reading
The paper evaluates English-to-French translation and analyzes learned alignments.
| Evidence | Supports | Does Not Prove Alone |
|---|---|---|
| translation improvement | attention helps encoder-decoder NMT | attention is universally sufficient |
| stronger long-sentence behavior | fixed-vector bottleneck was real | all long-context problems are solved |
| alignment visualization | learned weights often match intuitive alignments | attention weights are causal explanations |
| end-to-end training | alignments can emerge without labels | learned alignments are always faithful |
The key evidence is architectural: dynamic context improves sequence transduction, especially when fixed-length encoding is a bottleneck.
Attention Weights and Explanation
Attention weights:
show how the context vector is computed:
But they do not automatically prove:
Why:
- source annotations already mix context;
- decoder state contains previous target history;
- downstream nonlinearities transform the context;
- alternative attention patterns can sometimes yield similar outputs.
The correct statement is:
Implementation Notes
Implementation checklist:
| Component | Check |
|---|---|
| encoder annotations | are source states returned for all positions? |
| decoder query | does score use previous decoder state or current state? |
| score shape | |
| softmax axis | normalize over source positions |
| context vector | weighted sum over source annotations |
| masking | ignore source padding positions |
| training | teacher forcing and target autoregressive likelihood |
Shape sketch:
Scores:
Weights:
Context:
Failure Modes
| Failure Mode | Why It Matters |
|---|---|
| no source padding mask | attention can read padded tokens |
| softmax over wrong axis | weights normalize over target instead of source |
| fixed context still used incorrectly | model may not actually use dynamic memory |
| overinterpreting alignments | attention weights are not causal proof |
| long-source quadratic-ish score cost | each target step scores all source states |
| decoder recurrence bottleneck | attention helps memory but does not remove sequential decoding |
| exposure bias | teacher-forced training differs from autoregressive inference |
Common Misreadings
”This is the Transformer attention paper.”
No. This is the neural attention/alignment paper for RNN encoder-decoder translation. Transformer later replaces recurrent sequence modeling with stacked self-attention and feed-forward blocks.
”Attention was invented only for interpretability.”
No. The primary architectural role is dynamic memory access. Interpretability is a secondary and limited reading.
”The context vector disappears.”
No. The fixed global context is replaced by a target-step-specific context vector .
”Attention weights are hard alignments.”
No. They are soft differentiable distributions over source positions.
Later-Paper Checklist
When reading later attention papers, ask:
- What is the query object?
- What provides keys and values?
- Is the attention additive, dot-product, scaled dot-product, or structured?
- Is attention self-attention or cross-attention?
- What axis is normalized?
- What masks are applied?
- Does attention replace recurrence or only augment it?
- Are weights interpreted as explanation, alignment, or only mixing coefficients?
- Does the model use one context vector or dynamic context per step?
- How does complexity scale with source and target lengths?
Why It Matters
This paper is the bridge:
It made a reusable pattern explicit:
For this wiki, it should sit between RNN Encoder-Decoder and Attention Is All You Need because it explains why attention became necessary before it became the whole architecture.
Limitations
The paper still uses recurrent encoder-decoder machinery. Attention removes the fixed-vector bottleneck, but not all limitations:
- target decoding remains sequential;
- source-target scoring grows with source and target lengths;
- learned alignments are soft and not guaranteed faithful;
- translation quality still depends on data, vocabulary, optimization, and decoding;
- attention is a memory access mechanism, not a full architecture by itself.
The defensible claim:
The overclaim to avoid: