Neural Machine Translation by Jointly Learning to Align and Translate
Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015))
Subscriber deck — free during early access
18 cards
1 Introduction
- What bottleneck in encoder–decoder NMT did Bahdanau, Cho and Bengio identify?The encoder must compress all the information of a source sentence into one fixed-length vector, which makes long sentences hard; Cho et al. had shown that basic encoder–decoder performance deteriorates rapidly as input length grows.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §1
- What is the key idea of “jointly learning to align and translate”?Encode the source into a sequence of vectors instead of one, and each time a target word is generated, (soft-)search for the source positions where the most relevant information is, building a context vector from them. The decoder no longer depends on a single fixed-length vector.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §1
2.1 RNN Encoder–Decoder
- How does the basic RNN encoder–decoder define the translation probability?The encoder RNN reads \(x_1, \ldots, x_{T_x}\) into hidden states \(h_t = f(x_t, h_{t-1})\) and a vector \(c = q(\{h_1, \ldots, h_{T_x}\})\) (e.g. \(c = h_{T_x}\)); the decoder factorizes \(p(\mathbf{y}) = \prod_t p(y_t \mid \{y_1, \ldots, y_{t-1}\}, c)\), with \(p(y_t \mid \ldots) = g(y_{t-1}, s_t, c)\).
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §2.1
3.1 Decoder: General Description
- How does the attention-based decoder differ from the basic encoder–decoder?Each target word gets its own context vector: \(p(y_i \mid y_1, \ldots, y_{i-1}, \mathbf{x}) = g(y_{i-1}, s_i, c_i)\) with decoder state \(s_i = f(s_{i-1}, y_{i-1}, c_i)\), instead of a single \(c\) shared by all steps.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §3.1
- How is the context vector \(c_i\) computed in Bahdanau attention?As a weighted sum of the encoder annotations: \(c_i = \sum_{j=1}^{T_x} \alpha_{ij} h_j\), with \(\alpha_{ij} = \frac{\exp(e_{ij})}{\sum_{k=1}^{T_x} \exp(e_{ik})}\) and \(e_{ij} = a(s_{i-1}, h_j)\), an alignment model scoring how well input around position \(j\) matches output position \(i\).
The decoder’s previous state scores every annotation; the weights αij mix them into ci - Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §3.1
- What alignment model \(a(s_{i-1}, h_j)\) did Bahdanau et al. use, and why that form?A one-hidden-layer perceptron: \(a(s_{i-1}, h_j) = v_a^\top \tanh(W_a s_{i-1} + U_a h_j)\) (additive attention). It must be evaluated \(T_x \times T_y\) times per sentence pair, and \(U_a h_j\) doesn’t depend on \(i\), so it can be precomputed.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §3.1
- How does soft alignment differ from alignment in traditional statistical MT?Alignment isn’t a latent variable to be summed or searched over: the model computes a soft alignment directly, so gradients flow through it and the alignment model is trained jointly with the whole translation model. \(c_i\) is the expected annotation under alignment probabilities \(\alpha_{ij}\).
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §3.1
- Why is this mechanism called attention?The decoder decides which parts of the source sentence to pay attention to when generating each word. This relieves the encoder of encoding everything into a fixed-length vector: information can be spread across the annotations and selectively retrieved.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §3.1
3.2 Encoder: Bidirectional RNN for Annotating Sequences
- How are the source annotations \(h_j\) computed in Bahdanau et al.?With a bidirectional RNN: a forward RNN reads \(x_1 \to x_{T_x}\) and a backward RNN reads \(x_{T_x} \to x_1\); \(h_j = [\overrightarrow{h}_j^\top; \overleftarrow{h}_j^\top]^\top\) summarizes both preceding and following words, focused on the words around \(x_j\), since RNNs better represent recent inputs.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §3.2
4 Experiment Settings
- What data and setup did Bahdanau et al. use?WMT’14 English–French parallel corpora reduced to 348M words by data selection, no monolingual data; news-test-2014 (3003 sentences) as the test set; a 30,000-word shortlist per language with other words mapped to [UNK]; no lowercasing or stemming.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §4
- Which models did Bahdanau et al. compare?RNNencdec (Cho et al.’s encoder–decoder, 1000 gated hidden units each side) and RNNsearch (bidirectional encoder with 1000 units per direction, 1000-unit decoder, attention), each trained on sentences of up to 30 and up to 50 words; minibatch SGD with Adadelta, about 5 days each, decoding with beam search.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §4
5.1 Quantitative Results
- How did RNNsearch compare with RNNencdec and Moses in BLEU?RNNsearch beat RNNencdec in all settings: on all test sentences 26.75 vs 17.82 (trained on ≤50 words), and RNNsearch-30 even beat RNNencdec-50. On sentences without unknown words, RNNsearch-50 trained longer scored 36.15, above Moses (35.63), which also used a 418M-word monolingual corpus.
model all no UNK RNNencdec-30 13.93 24.19 RNNsearch-30 21.50 31.44 RNNencdec-50 17.82 26.71 RNNsearch-50 26.75 34.16 RNNsearch-50, trained longer 28.45 36.15 Moses 33.30 35.63 - Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §5.1
- How did translation quality depend on sentence length?RNNencdec’s BLEU dropped dramatically as sentences got longer, while RNNsearch was much more robust; RNNsearch-50 showed no deterioration even for sentences of 50 or more words.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §5.1
5.2.1 Alignment
- What did visualizing attention weights \(\alpha_{ij}\) reveal?English–French alignments are largely monotonic (strong diagonal), with sensible non-monotonic exceptions: for “European Economic Area” → “zone économique européenne”, the model aligned zone with Area, jumping over two words, then looked back one word at a time.
Schematic weights (stronger colour = larger α): adjective–noun order is reversed in French - Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §5.2.1
- Why is a soft alignment better than a hard one for “the man” → “l’ homme”?A hard alignment maps the → l’, but choosing between le, la, les and l’ depends on the following word. Soft alignment lets the model look at both the and man. It also handles phrases of different lengths without mapping words to or from NULL.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §5.2.1
5.2.2 Long Sentences
- Why does RNNsearch translate long sentences better than RNNencdec?It needn’t encode a whole long sentence perfectly into a fixed vector, only the parts around each word accurately. In examples, RNNencdec-50 drifted from the meaning after about 30 words (e.g. “based on his status as a health care worker” became “based on his state of health”), while RNNsearch-50 kept all details.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §5.2.2
6.1 Learning to Align
- How does Bahdanau attention differ from Graves’s (2013) alignment for handwriting synthesis, and what is its cost?Graves’s Gaussian-mixture weights move monotonically in one direction, too restrictive for translation, which needs (long-distance) reordering. Bahdanau attention computes a weight for every source word for every target word: \(O(T_x T_y)\), fine for 15–40-word sentences but possibly limiting for other tasks.
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §6.1
7 Conclusion
- What challenge did Bahdanau et al. leave for future work?Better handling of unknown and rare words, needed to match state-of-the-art systems in all contexts; their models used a 30,000-word shortlist with everything else mapped to [UNK].
- Bahdanau et al., 2015, Neural Machine Translation by Jointly Learning to Align and Translate (3rd International Conference on Learning Representations (ICLR 2015)), §7
Source
- Dzmitry Bahdanau, Kyunghyun Cho and Yoshua Bengio. 2015. Neural Machine Translation by Jointly Learning to Align and Translate. In 3rd International Conference on Learning Representations (ICLR 2015). https://arxiv.org/abs/1409.0473