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

FieldValue
PaperNeural Machine Translation by Jointly Learning to Align and Translate
AuthorsDzmitry Bahdanau, Kyunghyun Cho, Yoshua Bengio
Year2014 preprint; 2015 conference
VenueICLR 2015
arXiv1409.0473
ICLR PDFconference archive
Statusfull 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

ComponentRole
bidirectional encoderbuilds source annotations
decoder RNNgenerates target tokens autoregressively
alignment modelscores decoder state against source states
softmax over source positionsnormalizes scores into attention weights
context vector weighted sum of source annotations for target step
output modelpredicts 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:

RoleObject
querydecoder state
keyssource annotations through scoring network
valuessource annotations
weights
readoutcontext 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 TypeScore
additivelearned MLP over query and key
dot-productinner product similarity
scaled dot-productnormalized 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

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:

AxisBahdanau AttentionTransformer Attention
backboneRNN encoder-decoderattention-only blocks
scoreadditive MLPscaled dot product
querydecoder stateprojected token states
memoryencoder annotationskeys and values
parallelismdecoder remains recurrentself-attention highly parallelizable
roleremove fixed-context bottleneckreplace 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.

EvidenceSupportsDoes Not Prove Alone
translation improvementattention helps encoder-decoder NMTattention is universally sufficient
stronger long-sentence behaviorfixed-vector bottleneck was realall long-context problems are solved
alignment visualizationlearned weights often match intuitive alignmentsattention weights are causal explanations
end-to-end trainingalignments can emerge without labelslearned 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:

ComponentCheck
encoder annotationsare source states returned for all positions?
decoder querydoes score use previous decoder state or current state?
score shape
softmax axisnormalize over source positions
context vectorweighted sum over source annotations
maskingignore source padding positions
trainingteacher forcing and target autoregressive likelihood

Shape sketch:

Scores:

Weights:

Context:

Failure Modes

Failure ModeWhy It Matters
no source padding maskattention can read padded tokens
softmax over wrong axisweights normalize over target instead of source
fixed context still used incorrectlymodel may not actually use dynamic memory
overinterpreting alignmentsattention weights are not causal proof
long-source quadratic-ish score costeach target step scores all source states
decoder recurrence bottleneckattention helps memory but does not remove sequential decoding
exposure biasteacher-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:

Connections