Sequence to Sequence Learning with Neural Networks
Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014))
Subscriber deck — free during early access
20 cards
1 Introduction
- What limitation of deep neural networks did sequence-to-sequence learning address?DNNs need inputs and targets encoded as vectors of fixed dimensionality, but many problems (speech recognition, machine translation, question answering) map sequences to sequences whose lengths aren’t known in advance.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §1
- What is the core idea of Sutskever, Vinyals and Le’s sequence-to-sequence model?One LSTM reads the input sequence, one step at a time, into a large fixed-dimensional vector; another LSTM, essentially a language model conditioned on that vector, generates the output sequence from it.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §1
- What were the headline results of Sutskever et al. (2014)?On WMT’14 English–French, an ensemble of 5 deep LSTMs translated directly with 34.81 BLEU, beating a phrase-based SMT baseline (33.30) despite an 80k-word output vocabulary that penalized out-of-vocabulary words. Rescoring the baseline’s 1000-best lists gave 36.5, close to the previous state of the art (37.0).
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §1
- How does the seq2seq model relate to earlier neural sequence-to-sequence work?Kalchbrenner and Blunsom first mapped whole sentences to vectors (with convolutional networks, which lose word order); Cho et al. used a similar RNN encoder–decoder mainly inside an SMT system; Bahdanau et al. added attention for long sentences. CTC also maps sequences to sequences but assumes monotonic alignment.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §1
2 The model
- How does the seq2seq LSTM define \(p(y_1, \ldots, y_{T'} \mid x_1, \ldots, x_T)\)?The encoder’s last hidden state gives a fixed-dimensional representation \(v\) of the input; the decoder, an LSTM language model whose initial state is \(v\), factorizes \(p(y_1, \ldots, y_{T'} \mid x_1, \ldots, x_T) = \prod_{t=1}^{T'} p(y_t \mid v, y_1, \ldots, y_{t-1})\), each a softmax over the vocabulary.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §2
- Why does every sentence end with an end-of-sentence symbol in seq2seq?It lets the model define a distribution over sequences of all possible lengths: generation stops once it outputs ⟨EOS⟩.
Source A B C is read reversed; the decoder feeds each output word back in as its next input - Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §2
- In what three ways did the actual seq2seq model differ from the basic description?Two separate LSTMs for input and output (more parameters at negligible cost, and natural for multiple language pairs); deep LSTMs with four layers, which significantly beat shallow ones; and reversing the word order of the source sentence.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §2
- Why does reversing the source sentence help seq2seq?Mapping \(c, b, a\) to \(\alpha, \beta, \gamma\) puts \(a\) right next to its translation \(\alpha\), \(b\) fairly close to \(\beta\), and so on. The average distance between corresponding words is unchanged, but the minimal time lag is greatly reduced, making it easier for SGD to “establish communication” between input and output.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §2
3.1 Dataset details
- What data and vocabularies were used for the seq2seq experiments?A clean 12M-sentence subset of WMT’14 English–French (348M French and 304M English words); the 160,000 most frequent source words and 80,000 most frequent target words, with all other words replaced by UNK.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.1
3.2 Decoding and Rescoring
- How is seq2seq trained and decoded?Training maximizes \(\frac{1}{|\mathcal{S}|} \sum_{(T, S) \in \mathcal{S}} \log p(T \mid S)\) over the training set. Decoding searches for \(\arg\max_T p(T \mid S)\) with a left-to-right beam search keeping the \(B\) best prefixes; a hypothesis ending in ⟨EOS⟩ is complete.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.2
- How much did beam size matter for seq2seq translation?Little: a beam of 1 (greedy) already worked well, and a beam of 2 gave most of the benefit. An ensemble of 5 LSTMs got 33.00 BLEU with beam 1, 34.50 with beam 2 and 34.81 with beam 12.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.2
3.3 Reversing the Source Sentences
- How much did reversing source sentences improve seq2seq?Test perplexity dropped from 5.8 to 4.7 and BLEU of decoded translations rose from 25.9 to 30.6. Unexpectedly, it also made long sentences translate much better, suggesting better memory utilization, not just more confident early predictions.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.3
3.4 Training details
- Describe the seq2seq LSTM architecture and its size.4 layers of 1000 cells each in both encoder and decoder, 1000-dimensional word embeddings, input vocabulary 160,000, output vocabulary 80,000 with a naive softmax: 380M parameters, 64M of them recurrent. Each added layer reduced perplexity by nearly 10%.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.4
- What training recipe did Sutskever et al. use?Uniform initialization in \([-0.08, 0.08]\); plain SGD with learning rate 0.7, halved every half epoch after 5 epochs, 7.5 epochs in total; batches of 128; gradient norm clipping (rescale if \(\|g\|_2 > 5\)); and batches of similar-length sentences for a 2× speed-up.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.4
- Why did seq2seq training need gradient clipping?LSTMs largely avoid vanishing gradients but can still have exploding ones, so the gradient was rescaled to norm 5 whenever its norm exceeded 5.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.4
3.5 Parallelization
- How was seq2seq training parallelized?On 8 GPUs: each of the 4 LSTM layers ran on its own GPU, passing activations onward as soon as they were computed, and the other 4 GPUs split the 80,000-word softmax. This raised speed from about 1,700 to 6,300 words per second; training took about ten days.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.5
3.6 Experimental Results
- Why was the seq2seq result a landmark even though it didn’t beat the state of the art?It was the first time a pure neural translation system beat a phrase-based SMT baseline on a large MT task by a sizeable margin, despite being relatively unoptimized and unable to handle out-of-vocabulary words.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.6
3.7 Performance on long sentences
- How did seq2seq handle long sentences?Surprisingly well: there was no degradation for sentences under 35 words and only a minor drop for the longest, unlike earlier reports with similar models. Performance did drop on sentences with many rare words.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.7
3.8 Model Analysis
- What did PCA projections of seq2seq sentence vectors show?Phrases cluster by meaning, which is sensitive to word order (“John admires Mary” vs “Mary admires John” land apart) but fairly invariant to active vs passive voice (“I gave her a card in the garden” near “In the garden, I gave her a card” and “She was given a card by me”), something a bag-of-words model couldn’t capture.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §3.8
5 Conclusion
- What general lesson did Sutskever et al. draw from source reversal?Find a problem encoding with the greatest number of short-term dependencies, since they make learning much simpler. They suspected even a standard RNN could be trained on reversed translation data, though they didn’t verify it.
- Sutskever et al., 2014, Sequence to Sequence Learning with Neural Networks (Advances in Neural Information Processing Systems 27 (NIPS 2014)), §5
Source
- Ilya Sutskever, Oriol Vinyals and Quoc V. Le. 2014. Sequence to Sequence Learning with Neural Networks. In Advances in Neural Information Processing Systems 27 (NIPS 2014). https://papers.nips.cc/paper/2014/hash/5a18e133cbf9f257297f410bb7eca942-Abstract.html