Paper commentary
Effective Approaches to Attention-based Neural Machine Translation
Local attention lets translation models read only part of the source
- Problem Global attention reads every source word for each output word, which is costly on long inputs.
- Method Local attention reads a window of source states around one aligned position instead of all of them. Local-p learns that position with a sigmoid and reweights nearby states with a Gaussian, so it stays differentiable.
- Results An ensemble of 8 models scored 25.9 NIST BLEU on newstest2015, compared to 24.9 for the top WMT'15 entry.
Why one source summary is not enough
Neural machine translation reads a source sentence to its end and then writes the target one word at a time. Earlier systems used the source representation once, to start the decoder state, so the decoder worked from a single summary. Attention lets the decoder look back at a set of source hidden states at every step instead. That fix has a cost: every target word is scored against every source position, which gets expensive for long inputs such as paragraphs.
Hard attention picks a single position and is cheaper, but it is non-differentiable and needs techniques such as reinforcement learning to train. Soft attention spreads weight over every position and is easy to train, but it keeps the full cost. The open question is whether a model can keep soft attention's trainability while reading only part of the source at each step.
A global and a local attention
The key idea is to keep attention differentiable while limiting how many source positions it reads at each step. The authors build two variants: a global one that reads all source states, and a local one that reads a window around one aligned position. Both start from the top layer of a stacked LSTM and share the same steps after the context vector is formed.
The global model compares the current target hidden state with each source hidden state and turns the scores into alignment weights. With \(h_t\) the target state and \(\bar h_s\) a source state, the dot score is \(h_t^\top \bar h_s\) and the general score is \(h_t^\top W_a \bar h_s\). A softmax over all source positions gives the weights \(a_t(s)=\exp(\mathrm{score}(h_t,\bar h_s))/\sum_{s'}\exp(\mathrm{score}(h_t,\bar h_{s'}))\), and the context vector is their weighted average.
The authors also test a location-based score, \(a_t=\mathrm{softmax}(W_a h_t)\), which ignores the source states. The context vector then gives \(\tilde h_t=\tanh(W_c[c_t; h_t])\), and a softmax of \(W_s \tilde h_t\) yields the word distribution.
The local model first chooses an aligned position \(p_t\) and reads only the window \([p_t-D, p_t+D]\). Its alignment vector has a fixed size of \(2D+1\), so it doesn't grow with the sentence. Local-m simply sets \(p_t = t\), which assumes that source and target are roughly monotonic.
How local-p places its window
Local-p learns the position instead of assuming monotonic alignment. It computes \(p_t = S \cdot \mathrm{sigmoid}(v_p^\top \tanh(W_p h_t))\), where \(S\) is the source sentence length. The sigmoid keeps \(p_t\) in \([0, S]\), as a real number. Because \(p_t\) is real, a Gaussian centred at \(p_t\) reshapes the alignment scores so that positions near \(p_t\) count more.
Each weight becomes \(a_t(s)=\mathrm{align}(h_t,\bar h_s)\exp(-(s-p_t)^2/(2\sigma^2))\). The authors use the same align function as the global model and set \(\sigma\) empirically from \(D\). Gradients reach \(W_p\) and \(v_p\) through \(p_t\), so the model stays differentiable almost everywhere. For the local models the window size is set empirically to \(D = 10\).
Feeding attentional vectors forward
The input-feeding approach concatenates each attentional vector \(\tilde h_t\) with the inputs of the next time steps. Without it, each alignment decision is made on its own, even though a coverage record of past translation would help. Feeding past decisions forward lets the model see its earlier alignments, and it also makes the network deeper in both directions.
The reported models pair feeding with both global and local attention. The authors note that feeding is general and can be applied to stacked recurrent models without attention too.
Training setup
All models train on WMT'14 English-German data of 4.5M sentence pairs. Each language keeps its top 50K words as vocabulary, and other words map to a unk token. The stacked LSTM has 4 layers with 1000 cells each and 1000-dimensional embeddings. Sentence pairs longer than 50 words are filtered out during training.
Hyperparameters are selected on newstest2013 with 3000 sentences. Reported results use newstest2014 with 2737 sentences and newstest2015 with 2169 sentences. The LSTMs use dropout with probability 0.2, and dropout models train for 12 epochs. A single Tesla K40 GPU processes 1K target words per second, so one model takes 7-10 days to train.
English-German gains step by step
Table 1 builds the system up one change at a time, so each gain can be traced. Reversing the source sentence added 1.3 BLEU, and dropout added 1.4 more. Global attention then reached 16.8, which is 2.8 above the dropout model at 14.0. Adding input-feeding raised the global model from 16.8 to 18.1.
Local-p with feeding reached 19.0, which is 0.9 above the global model with feeding. Measured against the non-attentional dropout model at 14.0, this is a gain of 5.0 BLEU, the headline number. Unk replace then added 1.9 BLEU, moving local-p from 19.0 to 20.9. The authors read this as evidence that the learned alignments help with rare words.
An ensemble of 8 models with different attention types and dropout settings reached 23.0 BLEU. That is 1.4 above the ensemble from Jean et al. at 21.6. On newstest2015 the ensemble with unk replace reached 25.9 NIST BLEU, compared to 24.9 for the top WMT'15 entry. The authors note that their models were trained on WMT'14 data, slightly less than the winning entry used.
Which alignment function works
Table 4 compares score functions by perplexity before unk replacement and BLEU after it.
The authors read this as the location-based score not learning good alignments. Concat scoring didn't perform well in their implementation, and the authors leave the reason for further analysis. Among these models, local-p is best in both perplexity and BLEU.
Long sentences and alignment quality
Sentences were grouped by length and BLEU was computed per group. The authors report that quality of the attentional models doesn't degrade as sentences get longer, unlike the non-attentional model. The best model outperformed all other systems in every length bucket.
For alignment, the authors compared learned alignments with gold alignments from 508 English-German Europarl sentences using AER. They forced the models to produce the reference translations and kept, for each target word, the source word with the highest weight. Local-m with general scoring reached an AER of 0.34, lower than the 0.39 of the global location model.
The Berkeley aligner scored 0.32, and local-p reached 0.36. Because AER and translation quality correlate poorly, a lower AER doesn't guarantee better translation.
Limits of the reported gains
German-English translation didn't reach the state of the art, which is 29.2 for the phrase-based Edinburgh system. Global attention added 2.2 BLEU over the base model at 16.9, and input-feeding added 1.0 more. Dot scoring with dropout added 2.7, and unk replacement added 2.1 more.
The analysis uses only English-German results on newstest2014. Because of limited resources, not every combination of attention type and alignment function was run. Lower AER doesn't imply better translation, so the alignment result remains a separate check.
Paper info
- Authors
- Minh-Thang Luong, Hieu Pham, Christopher D. Manning
- Venue
- arXiv · Preprint
- First published
- 2015-8-17
- Added
- 2026-11-11
- Updated
- 2015-9-20
- Version
- v5
- arXiv
- 1508.04025
- Category
- cs.CL
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Minh-Thang Luong, Hieu Pham, Christopher D. Manning (2015). Effective Approaches to Attention-based Neural Machine Translation. arXiv:1508.04025v5. https://arxiv.org/abs/1508.04025v5
BibTeX
@misc{luong2015effective,
title = {{Effective Approaches to Attention-based Neural Machine Translation}},
author = {Minh-Thang Luong and Hieu Pham and Christopher D. Manning},
year = {2015},
eprint = {1508.04025},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1508.04025v5}
}