TL;DR
Sutskever, Vinyals and Le (2014) translated English sentences into French with two LSTMs. The first reads the whole input and compresses it into one fixed-length vector. The second starts from that vector and writes the output one word at a time. No word alignment or phrase table is built by hand.
The trick that helped most was reversing the order of the source sentence before training. An ensemble of five such models reached a BLEU score of 34.81 on WMT'14 English to French, which beat a strong phrase-based statistical baseline (33.30) but not the best published system (37.0).
Where you'll see it: machine translation, summarization and any system that maps one variable-length sequence to another, such as speech recognition output or chat replies.
The problem
A neural network needs its inputs and outputs to have a fixed size. An image has a fixed number of pixels, but a sentence does not have a fixed number of words, and neither does its translation. Translation, speech recognition and question answering all map a sequence of unknown length to another sequence of unknown length, and the two lengths need not match.
Before this paper, the strong translation systems were statistical. They split the sentence into phrases, translated each phrase with a table, and reordered the results with separate models. Neural networks had been used only to rescore lists of candidates or to add features to that pipeline. The question was whether one neural network could do the whole job end to end, and whether a recurrent network could keep track of meaning across a long sentence.
Key idea
Use one LSTM as an encoder and a second LSTM as a decoder. The encoder reads the source words in order and its final hidden state is a summary of the sentence. The decoder is a language model that starts from that summary and predicts the target words, so each output word is conditioned on the input.
flowchart LR A[A] --> B[B] --> C[C] --> E[EOS] E --> V((vector v)) V --> W[W] --> X[X] --> Y[Y] --> Z[Z] --> F[EOS]
The second idea is smaller but decisive. The source sentence is fed in reversed. If the input is "a b c" and the target is "alpha beta gamma", the encoder reads "c b a". The first source word is then next to the first target word in the sequence the LSTM sees, which shortens the distance backpropagation has to cover.
The method
The model
A recurrent network computes a hidden state from the current input and the previous state, and produces outputs from it. The paper's goal is a conditional probability of the whole output sequence given the whole input sequence. Let be the input tokens and the output tokens. The encoder LSTM's last hidden state gives a fixed vector . The decoder LSTM starts from and factorizes the probability one word at a time:
Each factor is a Softmax over the whole output vocabulary. Every target sentence ends with a special end-of-sentence symbol, EOS. That symbol lets the model put probability on sequences of every possible length, because generation stops when EOS is produced.
The encoder and decoder are two separate LSTMs with separate parameters. This adds parameters at almost no compute cost, and it lets the same architecture be trained on several language pairs. The encoder-decoder pattern is the general shape, and the LSTM is the cell that keeps information alive over long spans.
Training objective
Training maximizes the average log probability of the correct translation given the source sentence over the training set :
This is the same quantity as the Cross-Entropy Loss for next-word prediction, negated and averaged over sentence pairs. Optimization uses Stochastic Gradient Descent with a fixed learning rate and no momentum.
Decoding
At test time the model needs the most likely translation, . Finding it exactly is too expensive, so the paper uses a left-to-right Beam Search. The decoder keeps the best partial translations at each step, extends each one with every vocabulary word, and keeps the best again. A hypothesis is moved to the finished set when it emits EOS. The authors found that even a beam of 1 works reasonably, and a beam of 2 gives most of the gain.
Reversing the source
The authors first trained on the source sentence in normal order and found that test perplexity was 5.8 with a BLEU of 25.9. After reversing the source sentences, perplexity dropped to 4.7 and BLEU rose to 30.6. These are the figures in the paper's text (Section 3.3). The results table gives slightly different numbers for the same comparison: 26.17 for the forward model and 30.59 for the reversed one, both with beam 12. The paper does not say why they differ. The table values are labelled with their setting (single LSTM, beam 12), so this lesson uses them, and the text values are unlabelled. Either way the gain is about 4.4 to 4.7 BLEU. The argument is about the minimal time lag. In normal order, each source word is far from its translation in the sequence. Reversal keeps the average distance the same, but it puts the first source words next to the first target words, so the earliest target words can be predicted from information that has just passed through the network. The authors say they lack a complete explanation, but the effect was large.
Architecture and training
The models use four LSTM layers with 1000 cells each and 1000-dimensional word embeddings. The source vocabulary has 160,000 words and the target vocabulary has 80,000, with everything else mapped to an unknown token. Each model has 384 million parameters, of which 64 million are recurrent connections (32 million in the encoder and 32 million in the decoder). The whole sentence is represented by 8000 real numbers: 4 layers of 1000 cells, each cell holding both a hidden value and a memory-cell value.
Training details:
- Weights start uniform between -0.08 and 0.08.
- SGD with no momentum, learning rate 0.7. After 5 epochs the rate is halved every half epoch. Training stops at 7.5 epochs.
- Minibatches of 128 sentence pairs.
- Gradient norm clipping: if the norm of the averaged gradient exceeds 5, it is rescaled to norm 5. This guards against exploding gradients, which LSTMs can still suffer from. See Gradient Norm Clipping.
- Sentences in a minibatch are grouped by similar length, which gave a 2x speedup because short sentences would otherwise waste most of the batch.
The training set is a 12-million-sentence subset of WMT'14 with about 348 million French words and 304 million English words. A single GPU ran at about 1,700 words per second, too slow, so each of the four layers ran on its own GPU and the remaining four GPUs computed the softmax in parallel. That reached about 6,300 words per second, and training took roughly ten days.
Results
Translation quality
The paper reports BLEU on the WMT'14 English to French test set, measured with the tokenized multi-bleu script. BLEU compares n-gram overlap with human references.
| Method | Test BLEU |
|---|---|
| Phrase-based SMT baseline | 33.30 |
| Single forward LSTM, beam 12 | 26.17 |
| Single reversed LSTM, beam 12 | 30.59 |
| Ensemble of 5 reversed LSTMs, beam 1 | 33.00 |
| Ensemble of 5 reversed LSTMs, beam 2 | 34.50 |
| Ensemble of 5 reversed LSTMs, beam 12 | 34.81 |
The best direct translation reaches 34.81 BLEU, which is 1.5 points above the baseline. The score is penalized whenever the reference contains a word outside the 80,000-word output vocabulary, so it understates what the model could do with a larger one. The authors note that the best published WMT'14 system at the time scored 37.0 under the same evaluation, so the neural system did not beat the best system, only the phrase-based baseline. The gap between the single reversed model and the single forward model is more than 4 BLEU points, which is the largest effect in the paper.
- 5-LSTM ensemble, reversed source
- SMT baseline
Rescoring
The LSTM also rescored the 1000-best lists from the baseline system. Averaging its score with the baseline score gives a BLEU of 36.5 for the ensemble, a gain of 3.2 points over the baseline. A single reversed LSTM reaches 35.85. The paper notes that an oracle that picks the best hypothesis from the same lists would reach about 45, so the lists contain much better translations than any reranker found.
Long sentences
The authors expected long sentences to fail, since earlier models had degraded on them. The paper's sentence-length figure shows no loss on sentences shorter than 35 words and only a small loss on the longest ones. Table 3 in the paper shows long outputs that are largely faithful to the reference, though they can contain unknown-word placeholders and small omissions.
Learned representations
Projecting the final encoder states with PCA shows that sentences with the same meaning cluster together, and that word order changes the representation. Sentences that differ only by active or passive voice stay close.
Why it mattered
The paper showed that a plain LSTM encoder-decoder, trained end to end, could compete with carefully engineered statistical systems on a large translation task, which made sequence-to-sequence learning a default approach. The encoder-decoder pattern carried over to speech, captioning and summarization. The paper also left a clear bottleneck. All the information in a sentence has to pass through one fixed vector, which limits how well very long inputs can be handled. The attention mechanism of Bahdanau et al. (2014) was designed to remove that bottleneck, and the Transformer later replaced recurrence entirely. The reversal trick is a reminder that data ordering and representation can matter as much as the architecture.
Reading guide
Read the paper with these lessons in hand, in reading order:
- Section 1 (introduction). Needs Encoder-Decoder Architecture and the idea of a Language Model, since the paper calls the decoder a conditional language model. Also see Long Short-Term Memory for the cell it relies on.
- Section 2 (the model). The conditional probability factorization uses Softmax at each step. The vanishing and exploding gradient problems in this section are explained in Vanishing Gradient Problem.
- Section 3.2 (decoding and rescoring). Needs Beam Search for the decoder and BLEU Score for the metric in Section 3.6.
- Section 3.3 (reversing source sentences). The minimal time lag argument is easier with the Vanishing Gradient Problem in mind.
- Section 3.4 (training details). Uses Stochastic Gradient Descent, Cross-Entropy Loss, and Gradient Norm Clipping.
- Section 4 (related work). Compare with the attention approach in Neural Machine Translation by Jointly Learning to Align and Translate, which the paper cites as the successful follow-up.