Why Self-Attention? A Targeted Evaluation of Neural Machine Translation Architectures

08/27/2018 ∙ by Gongbo Tang, et al. ∙ 0

Recently, non-recurrent architectures (convolutional, self-attentional) have outperformed RNNs in neural machine translation. CNNs and self-attentional networks can connect distant words via shorter network paths than RNNs, and it has been speculated that this improves their ability to model long-range dependencies. However, this theoretical argument has not been tested empirically, nor have alternative explanations for their strong performance been explored in-depth. We hypothesize that the strong performance of CNNs and self-attentional networks could also be due to their ability to extract semantic features from the source text, and we evaluate RNNs, CNNs and self-attention networks on two tasks: subject-verb agreement (where capturing long-range dependencies is required) and word sense disambiguation (where semantic feature extraction is required). Our experimental results show that: 1) self-attentional networks and CNNs do not outperform RNNs in modeling subject-verb agreement over long distances; 2) self-attentional networks perform distinctly better than RNNs and CNNs on word sense disambiguation.



There are no comments yet.


page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

Different architectures have been shown to be effective for neural machine translation (NMT), ranging from recurrent architectures Kalchbrenner and Blunsom (2013); Bahdanau et al. (2015); Sutskever et al. (2014); Luong et al. (2015) to convolutional Kalchbrenner and Blunsom (2013); Gehring et al. (2017) and, most recently, fully self-attentional (Transformer) models Vaswani et al. (2017). Since comparisons Gehring et al. (2017); Vaswani et al. (2017); Hieber et al. (2017) are mainly carried out via BLEU Papineni et al. (2002), it is inherently difficult to attribute gains in BLEU to architectural properties.

Recurrent neural networks (RNNs) Elman (1990) can easily deal with variable-length input sentences and thus are a natural choice for the encoder and decoder of NMT systems. Modern variants of RNNs, such as GRUs Cho et al. (2014) and LSTMs Hochreiter and Schmidhuber (1997), address the difficulty of training recurrent networks with long-range dependencies. gehring2017convolutional introduce a neural architecture where both the encoder and decoder are based on CNNs, and report better BLEU scores than RNN-based NMT models. Moreover, the computation over all tokens can be fully parallelized during training, which increases efficiency. vaswani2017Attention propose Transformer models, which are built entirely with attention layers, without convolution or recurrence. They report new state-of-art BLEU scores for ENDE and ENFR. Yet, the BLEU metric is quite coarse-grained, and offers no insight as to which aspects of translation are improved by different architectures.

To explain the observed improvements in BLEU, previous work has drawn on theoretical arguments. Both gehring2017convolutional and vaswani2017Attention argue that the length of the paths in neural networks between co-dependent elements affects the ability to learn these dependencies: the shorter the path, the easier the model learns such dependencies. The papers argue that Transformers and CNNs are better suited than RNNs to capture long-range dependencies.

However, this claim is based on a theoretical argument and has not been empirically tested. We argue other abilities of non-recurrent networks could be responsible for their strong performance. Specifically, we hypothesize that the improvements in BLEU are due to CNNs and Transformers being strong semantic feature extractors.

In this paper, we evaluate all three popular NMT architectures: models based on RNNs (referred to as RNNS2S in the remainder of the paper), based on CNNs (referred to as ConvS2S

) and self-attentional models (referred to as Transformers). Motivated by the aforementioned theoretical claims regarding path length and semantic feature extraction, we evaluate their performance on a subject-verb agreement task (that requires modeling long-range dependencies) and a word sense disambiguation (WSD) task (that requires extracting semantic features). Both tasks build on test sets of contrastive translation pairs,

Lingeval97 Sennrich (2017) and ContraWSD Rios et al. (2017).

The main contributions of this paper can be summarized as follows:

  • We test the theoretical claims that architectures with shorter paths through networks are better at capturing long-range dependencies. Our experimental results on modeling subject-verb agreement over long distances do not show any evidence that Transformers or CNNs are superior to RNNs in this regard.

  • We empirically show that the number of attention heads in Transformers impacts their ability to capture long-distance dependencies. Specifically, many-headed multi-head attention is essential for modeling long-distance phenomena with only self-attention.

  • We empirically show that Transformers excel at WSD, indicating that they are strong semantic feature extractors.

2 Related work

yin2017comparative are the first to compare CNNs, LSTMs and GRUs on several NLP tasks. They find that CNNs are better at tasks related to semantics, while RNNs are better at syntax-related tasks, especially for longer sentences.

Based on the work of Linzen2016assessing, bernardy2017using find that RNNs perform better than CNNs on a subject-verb agreement task, which is a good proxy for how well long-range dependencies are captured. Tran2018recurrent find that a Transformer language model performs worse than an RNN language model on a subject-verb agreement task. They, too, note that this is especially true as the distance between subject and verb grows, even if RNNs resulted in a higher perplexity on the validation set. This result of Tran2018recurrent is clearly in contrast to the general finding that Transformers are better than RNNs for NMT tasks.

bai2018empirical evaluate CNNs and LSTMs on several sequence modeling tasks. They conclude that CNNs are better than RNNs for sequence modeling. However, their CNN models perform much worse than the state-of-art LSTM models on some sequence modeling tasks, as they themselves state in the appendix.

Tang2018evaluation evaluate different RNN architectures and Transformer models on the task of historical spelling normalization which translates a historical spelling into its modern form. They find that Transformer models surpass RNN models only in high-resource conditions.

In contrast to previous studies, we focus on the machine translation task, where architecture comparisons so far are mostly based on BLEU.

(a) RNN



(b) CNN

(c) Self-attention
Figure 1: Architectures of different neural networks in NMT.

3 Background

3.1 NMT Architectures

We evaluate three different NMT architectures: RNN-based models, CNN-based models, and Transformer-based models. All of them have a bipartite structure in the sense that they consist of an encoder and a decoder. The encoder and the decoder interact via a soft-attention mechanism Bahdanau et al. (2015); Luong et al. (2015), with one or multiple attention layers.

In the following sections, is the hidden state at step of layer , represents the hidden state at the previous step of layer , means the hidden state at of layer, represents the embedding of , and denotes the positional embedding at position .

3.1.1 RNN-based NMT

RNNs are stateful networks that change as new inputs are fed to them, and each state has a direct connection only to the previous state. Thus, the path length of any two tokens with a distance of in RNNs is exactly . Figure 1 (a) shows an illustration of RNNs.


In deep architectures, two adjacent layers are commonly connected with residual connections. In the

th encoder layer, is generated by Equation 1, where is the RNN (GRU or LSTM) function. In the first layer, .

In addition to the connection between the encoder and decoder via attention, the initial state of the decoder is usually initialized with the average of the hidden states or the last hidden state of the encoder.

3.1.2 CNN-based NMT

CNNs are hierarchical networks, in that convolution layers capture local correlations. The local context size depends on the size of the kernel and the number of layers. In order to keep the output the same length as the input, CNN models add padding symbols to input sequences. Given an -layer CNN with a kernel size , the largest context size is . For any two tokens in a local context with a distance of , the path between them is only .

As Figure 1 (b) shows, a 2-layer CNN with kernel size 3 “sees” an effective local context of 5 tokens. The path between the first token and the fifth token is only 2 convolutions. Since CNNs do not have a means to infer the position of elements in a sequence, positional embeddings are introduced.


The hidden state shown in Equation 2 is related to the hidden states in the same convolution and the hidden state from the previous layer. denotes the kernel size of CNNs and is a non-linearity. ConvS2S chooses Gated Linear Units (GLU) which can be viewed as a gated variation of ReLUs. are called convolutional filters. In the input layer, .

3.1.3 Transformer-based NMT

Transformers rely heavily on self-attention networks. Each token is connected to any other token in the same sentence directly via self-attention. Moreover, Transformers feature attention networks with multiple attention heads. Multi-head attention is more fine-grained, compared to conventional -head attention mechanisms. Figure 1 (c) illustrates that any two tokens are connected directly: the path length between the first and the fifth tokens is . Similar to CNNs, positional information is also preserved in positional embeddings.

The hidden state in the Transformer encoder is calculated from all hidden states of the previous layer. The hidden state in a self-attention network is computed as in Equation 3.



represents a feed-forward network with ReLU as the activation function and layer normalization. In the input layer,

. The decoder additionally has a multi-head attention over the encoder hidden states.

3.2 Contrastive Evaluation of Machine Translation

Since we evaluate different NMT architectures explicitly on subject-verb agreement and WSD (both happen implicitly during machine translation), BLEU as a measure of overall translation quality is not helpful. In order to conduct these targeted evaluations, we use contrastive test sets.

Sets of contrastive translations can be used to analyze specific types of errors. Human reference translations are paired with one or more contrastive variants, where a specific type of error is introduced automatically.

The evaluation procedure then exploits the fact that NMT models are conditional language models. By virtue of this, given any source sentence and target sentence

, any NMT model can assign to them a probability

. If a model assigns a higher score to the correct target sentence than to a contrastive variant that contains an error, we consider it a correct decision. The accuracy of a model on such a test set is simply the percentage of cases where the correct target sentence is scored higher than all contrastive variants.

Contrastive evaluation tests the sensitivity of NMT models to specific translation errors. The contrastive examples are designed to capture specific translation errors rather than evaluating the global quality of NMT models. Although they do not replace metrics such as BLEU, they give further insights into the performance of models, on specific linguistic phenomena.

3.2.1 Lingeval97

Lingeval97 has over 97,000 EnglishGerman contrastive translation pairs featuring different linguistic phenomena, including subject-verb agreement, noun phrase agreement, separable verb-particle constructions, transliterations and polarity. In this paper, we are interested in evaluating the performance on long-range dependencies. Thus, we focus on the subject-verb agreement category which consists of 35,105 instances.

In German, verbs must agree with their subjects in both grammatical number and person. Therefore, in a contrastive translation, the grammatical number of a verb is swapped. Table 1 gives an example.

English: […] plan will be approved
German: […] Plan verabschiedet wird
Contrast: […] Plan verabschiedet werden

Table 1: An example of a contrastive pair in the subject-verb agreement category.

3.2.2 ContraWSD

In ContraWSD, given an ambiguous word in the source sentence, the correct translation is replaced by another meaning of the ambiguous word which is incorrect. For example, in a case where the English word line is the correct translation of the German source word Schlange, ContraWSD replaces line with the other translations of Schlange, such as snake, serpent, to generate contrastive translations.

For GermanEnglish, ContraWSD contains 84 different German word senses. It has 7,200 GermanEnglish lexical ambiguities, each lexical ambiguity instance has 3.5 contrastive translations on average. For GermanFrench, it consists of 71 different German word senses. There are 6,700 GermanFrench lexical ambiguities, with an average of 2.2 contrastive translations each lexical ambiguity instance. All the ambiguous words are nouns so that the disambiguation is not possible simply based on syntactic context.

4 Subject-verb Agreement

The subject-verb agreement task is the most popular choice for evaluating the ability to capture long-range dependencies and has been used in many studies Linzen et al. (2016); Bernardy and Lappin (2017); Sennrich (2017); Tran et al. (2018). Thus, we also use this task to evaluate different NMT architectures on long-range dependencies.

4.1 Experimental Settings

Different architectures are hard to compare fairly because many factors affect performance. We aim to create a level playing field for the comparison by training with the same toolkit, Sockeye Hieber et al. (2017) which is based on MXNet Chen et al. (2015)

. In addition, different hyperparameters and training techniques (such as label smoothing or layer normalization) have been found to affect the performance

Chen et al. (2018). We apply the same hyperparameters and techniques for all architectures except the parameters of each specific architecture. Since the best hyperparameters for different architectures may be diverse, we verify our hyperparameter choice by comparing our results to those published previously. Our models achieve similar performance to that reported by Hieber2017sockeye with the best available settings. In addition, we extend Sockeye with an interface that enables scoring of existing translations, which is required for contrastive evaluation.

All the models are trained with 2 GPUs. During training, each mini-batch contains 4096 tokens. A model checkpoint is saved every 4,000 updates. We use Adam Kingma and Ba (2015) as the optimizer. The initial learning rate is set to 0.0002. If the performance on the validation set has not improved for 8 checkpoints, the learning rate is multiplied by 0.7. We set the early stopping patience to 32 checkpoints. All the neural networks have 8 layers. For RNNS2S, the encoder has 1 bi-directional LSTM and 6 stacked uni-directional LSTMs, and the decoder is a stack of 8 uni-directional LSTMs. The size of embeddings and hidden states is 512. We apply layer normalization and label smoothing (0.1) in all models. We tie the source and target embeddings. The dropout rate of embeddings and Transformer blocks is set to 0.1. The dropout rate of RNNs and CNNs is 0.2. The kernel size of CNNs is 3. Transformers have an 8-head attention mechanism.

To test the robustness of our findings, we also test a different style of RNN architecture, from a different toolkit. We evaluate bi-deep transitional RNNs Miceli Barone et al. (2017) which are state-of-art RNNs in machine translation. We use the bi-deep RNN-based model (RNN-bideep) implemented in Marian Junczys-Dowmunt et al. (2018). Different from the previous settings, we use the Adam optimizer with , , . The initial learning rate is 0.0003. We tie target embeddings and output embeddings. Both the encoder and decoder have 4 layers of LSTM units, only the encoder layers are bi-directional. LSTM units consist of several cells (deep transition): 4 in the first layer of the decoder, 2 cells everywhere else.

We use training data from the WMT17 shared task.111http://www.statmt.org/wmt17/translation-task.html We use newstest2013 as the validation set, and use newstest2014 and newstest2017 as the test sets. All BLEU scores are computed with SacreBLEU Post (2018). There are about 5.9 million sentence pairs in the training set after preprocessing with Moses scripts. We learn a joint BPE model with 32,000 subword units Sennrich et al. (2016). We employ the model that has the best perplexity on the validation set for the evaluation.

4.2 Overall Results

Table 2 reports the BLEU scores on newstest2014 and newstest2017, the perplexity on the validation set, and the accuracy on long-range dependencies.222We report average accuracy on instances where the distance between subject and verb is longer than 10 words. Transformer achieves the highest accuracy on this task and the highest BLEU scores on both newstest2014 and newstest2017. Compared to RNNS2S, ConvS2S has slightly better results regarding BLEU scores, but a much lower accuracy on long-range dependencies. The RNN-bideep model achieves distinctly better BLEU scores and a higher accuracy on long-range dependencies. However, it still cannot outperform Transformers on any of the tasks.

Model 2014 2017 PPL Acc(%)
RNNS2S 23.3 25.1 6.1 95.1
ConvS2S 23.9 25.2 7.0 84.9
Transformer 26.7 27.5 4.5 97.1
RNN-bideep 24.7 26.1 5.7 96.3
Table 2: The results of different NMT models, including the BLEU scores on newstest2014 and newstest2017, the perplexity on the validation set, and the accuracy of long-range dependencies.

Figure 2 shows the performance of different architectures on the subject-verb agreement task. It is evident that Transformer, RNNS2S, and RNN-bideep perform much better than ConvS2S on long-range dependencies. However, Transformer, RNNS2S, and RNN-bideep are all robust over long distances. Transformer outperforms RNN-bideep for distances 11-12, but RNN-bideep performs equally or better for distance 13 or higher. Thus, we cannot conclude that Transformer models are particularly stronger than RNN models for long distances, despite achieving higher average accuracy on distances above 10.

Figure 2: Accuracy of different NMT models on the subject-verb agreement task.

4.2.1 CNNs

Theoretically, the performance of CNNs will drop when the distance between the subject and the verb exceeds the local context size. However, ConvS2S is also clearly worse than RNNS2S for subject-verb agreement within the local context size.

In order to explore how the ability of ConvS2S to capture long-range dependencies depends on the local context size, we train additional systems, varying the number of layers and kernel size. Table 3 shows the performance of different ConvS2S models. Figure 3 displays the performance of two 8-layer CNNs with kernel size 3 and 7, a 6-layer CNN with kernel size 3, and RNNS2S. The results indicate that the accuracy increases when the local context size becomes larger, but the BLEU score does not. Moreover, ConvS2S is still not as good as RNNS2S for subject-verb agreement.

Layer K Ctx 2014 2017 Acc(%)
4 3 08 22.9 24.2 81.1
6 3 12 23.6 25.0 82.5
8 3 16 23.9 25.2 84.9
8 5 32 23.5 24.7 89.7
8 7 48 23.3 24.6 91.3
Table 3: The performance of ConvS2S with different settings. K means the kernel size. The ctx column is the theoretical largest local context size in the masked decoder.
Figure 3: Results of ConvS2S models and the RNNS2S model at different distances.

Regarding the explanation for the poor performance of ConvS2S, we identify the limited context size as a major problem. One assumption to explain the remaining difference is that, scale invariance of CNNs is relatively poor Xu et al. (2014)

. Scale-invariance is important in NLP, where the distance between arguments is flexible, and current recurrent or attentional architectures are better suited to handle this variance.

Our empirical results do not confirm the theoretical arguments in gehring2017convolutional that CNNs can capture long-range dependencies better with a shorter path. The BLEU score does not correlate well with the targeted evaluation of long-range distance interactions. This is due to the locality of BLEU, which only measures on the level of n-grams, but it may also indicate that there are other trade-offs between the modeling of different phenomena depending on hyperparameters. If we aim to get better performance on long-range dependencies, we can take this into account when optimizing hyperparameters.

4.2.2 RNNs vs. Transformer

Even though Transformer achieves much better BLEU scores than RNNS2S and RNN-bideep, the accuracies of these architectures on long-range dependencies are close to each other in Figure 2.

Our experimental result contrasts with the result from Tran2018recurrent. They find that Transformers perform worse than LSTMs on the subject-verb agreement task, especially when the distance between the subject and the verb becomes longer. We perform several experiments to analyze this discrepancy with Tran2018recurrent.

A first hypothesis is that this is caused by the amount of training data, since we used much larger datasets than Tran2018recurrent. We retrain all the models with a small amount of training data similar to the amount used by Tran2018recurrent, about 135K sentence pairs. The other training settings are the same as in Section 4.1. We do not see the expected degradation of Transformer-s, compared to RNNS2S-s (see Figure 4). In Table 4, the performance of RNNS2S-s and Transformer-s is similar, including the BLEU scores on newstest2014, newstest2017, the perplexity on the validation set, and the accuracy on the long-range dependencies.

Figure 4: Results of a Transformer and RNNS2S model trained on a small dataset.

A second hypothesis is that the experimental settings lead to the different results. In order to investigate this, we do not only use a small training set, but also replicate the experimental settings of Tran2018recurrent. The main changes are neural network layers (84); embedding size (512128); multi-head size (82); dropout rate (0.10.2); checkpoint save frequency (4,0001,000), and initial learning rate (0.00020.001).

Model 2014 2017 PPL Acc(%)
RNNS2S-s 7.3 07.8 47.8 77.3
Trans-s 7.2 08.0 44.6 74.6
RNNS2S-re 9.2 10.5 39.2 77.7
Trans-re-h2 9.6 10.7 36.9 71.9
Trans-re-h4 9.5 11.9 35.8 73.8
Trans-re-h8 9.4 10.4 36.0 75.3
Table 4: The results of different models with small training data and replicate settings. Trans is short for Transformer. Models with the suffix “-s” are models trained with small data set. Models with the suffix “-re” are models trained with replicate settings. “h2, h4, h8” indicates the number of attention heads for Transformer models.
Figure 5: Results of the models with replicate settings, varying the number of attention heads for the Transformer models.

In the end, we get a result that is similar to Tran2018recurrent. In Figure 5, Transformer-re-h2 performs clearly worse than RNNS2S-re on long-range dependencies. By increasing the number of heads in multi-head attention, subject-verb accuracy over long distances can be improved substantially, even though it remains below that of RNNS2S-re. Also, the effect on BLEU is small.

Our results suggest that the importance of multi-head attention with a large number of heads is larger than BLEU would suggest, especially for the modeling of long-distance phenomena, since multi-head attention provides a way for the model to attend to both local and distant context, whereas distant context may be overshadowed by local context in an attention mechanism with a single or few heads.

Although our study is not a replication of Tran2018recurrent, who work on a different task and a different test set, our results do suggest an alternative interpretation of their findings, namely that the poor performance of the Transformer in their experiments is due to hyperparameter choice. Rather than concluding that RNNs are superior to Transformers for the modeling of long-range dependency phenomena, we find that the number of heads in multi-head attention affects the ability of Transformers to model long-range dependencies in subject-verb agreement.

PPL 2014 2017 Acc(%) PPL 2012 Acc(%)
RNNS2S 5.7 29.1 30.1 84.0 7.06 16.4 72.2
ConvS2S 6.3 29.1 30.4 82.3 7.93 16.8 72.7
Transformer 4.3 32.7 33.7 90.3 4.9 18.7 76.7
uedin-wmt17 35.1 87.9
TransRNN 5.2 30.5 31.9 86.1 6.3 17.6 74.2
Table 5: The results of different architectures on newstest sets and ContraWSD. PPL is the perplexity on the validation set. Acc means accuracy on the test set.

5 Wsd

Our experimental results on the subject-verb agreement task demonstrate that CNNs and Transformer are not better at capturing long-range dependencies compared to RNNs, even though the paths in CNNs and Transformers are shorter. This finding is not in accord with the theoretical argument in both gehring2017convolutional and vaswani2017Attention. However, these architectures perform well empirically according to BLEU. Thus, we further evaluate these architectures on WSD, to test our hypothesis that non-recurrent architectures are better at extracting semantic features.

5.1 Experimental settings

We evaluate all architectures on ContraWSD on both DEEN and DEFR. We reuse the parameter settings in Section 4.1, except that: the initial learning rate of ConvS2S is reduced from 0.0003 to 0.0002 in DEEN; the checkpoint saving frequency is changed from 4,000 to 1,000 in DEFR because of the training data size.

For DEEN, the training set, validation set, and test set are the same as the other direction ENDE. For DEFR, we use around 2.1 million sentence pairs from Europarl (v7) Tiedemann (2012)333http://opus.nlpl.eu/Europarl.php and News Commentary (v11) cleaned by rios2017improving444http://data.statmt.org/ContraWSD/ as our training set. We use newstest2013 as the evaluation set, and use newstest2012 as the test set. All the data is preprocessed with Moses scripts.

In addition, we also compare to the best result reported for DEEN, achieved by uedin-wmt17 Sennrich et al. (2017), which is an ensemble of 4 different models and reranked with right-to-left models.555https://github.com/a-rios/ContraWSD/tree/master/baselines uedin-wmt17 is based on the bi-deep RNNs Miceli Barone et al. (2017) that we mentioned before. To the original 5.9 million sentence pairs in the training set, they add 10 million synthetic pairs with back-translation.

5.2 Overall Results

Table 5 gives the performance of all the architectures, including the perplexity on validation sets, the BLEU scores on newstest, and the accuracy on ContraWSD. Transformers distinctly outperform RNNS2S and ConvS2S models on DEEN and DEFR. Moreover, the Transformer model on DEEN also achieves higher accuracy than uedin-wmt17, although the BLEU score on newstest2017 is 1.4 lower than uedin-wmt17. We attribute this discrepancy between BLEU and WSD performance to the use of synthetic news training data in uedin-wmt17, which causes a large boost in BLEU due to better domain adaptation to newstest, but which is less helpful for ContraWSD, whose test set is drawn from a variety of domains.

For DEEN, RNNS2S and ConvS2S have the same BLEU score on newstest2014, ConvS2S has a higher score on newstest2017. However, the WSD accuracy of ConvS2S is 1.7% lower than RNNS2S. For DEFR, ConvS2S achieves slightly better results on both BLEU scores and accuracy than RNNS2S.

The Transformer model strongly outperforms the other architectures on this WSD task, with a gap of 4–8 percentage points. This affirms our hypothesis that Transformers are strong semantic features extractors.

5.3 Hybrid Encoder-Decoder Model

In recent work, chen2018both find that hybrid architectures with a Transformer encoder and an RNN decoder can outperform a pure Transformer model. They speculate that the Transformer encoder is better at encoding or extracting features than the RNN encoder, whereas the RNN is better at conditional language modeling.

For WSD, it is unclear whether the most important component is the encoder, the decoder, or both. Following the hypothesis that Transformer encoders excel as semantic feature extractors, we train a hybrid encoder-decoder model (TransRNN) with a Transformer encoder and an RNN decoder.

The results (in Table 5) show that TransRNN performs better than RNNS2S, but worse than the pure Transformer, both in terms of BLEU and WSD accuracy. This indicates that WSD is not only done in the encoder, but that the decoder also affects WSD performance. We note that chen2018both,Domhan2018how introduce the techniques in Transformers into RNN-based models, with reportedly higher BLEU. Thus, it would be interesting to see if the same result holds true with their architectures.

6 Post-publication Experiments

PPL 2014 2017 Acc(%) PPL 2012 Acc(%)
RNNS2S 4.7 31.1 32.2 88.1 5.6 17.7 75.9
ConvS2S 5.0 30.9 32.2 87.2 5.9 17.9 74.7
Transformer 4.5 32.0 33.3 89.1 5.2 18.4 76.8
TransRNN 4.7 31.6 32.9 87.8 5.4 18.3 76.5
Table 6: Post-publication results of different architectures on newstest sets and ContraWSD. PPL is the perplexity on the validation set. Acc means accuracy on the test set.

We here present a number of further experiments with different configurations and implementations, performed after publication to test the robustness of our claims.

6.1 Pre-trained Fairseq CNN Model

The ConvS2S models underperform RNNS2S and Transformer on the subject-verb agreement task. To address the question whether these results can be attributed to a misconfiguration or implementation difference in Sockeye, we also obtained results with a pre-trained model released by Gehring et al. (2017) and trained with Fairseq666https://github.com/pytorch/fairseq. This pre-trained model also uses the WMT17 data set for training.

Table 7 shows the model differences and performance. The pre-trained Fairseq model has 15 layers, which is much deeper than the Sockeye models that we trained. It achieves higher BLEU score on newstest2014, and higher accuracy on modeling long-range dependencies, than the 8-layer Sockeye models that we trained. However, it still lags behind RNNS2S and Transformer on the subject-verb agreement task.

Model Layer K 2014 Accuracy(%)
Sockeye-1 8 3 23.9 84.9
Sockeye-2 8 7 23.3 91.3
Fairseq 15 3 25.2 92.7
Table 7: The performance of CNN models trained by different toolkits. K is the kernel size of CNN.

6.2 Reducing Model Differences

The difference between recurrent, convolutional, and self-attentional architectures is not the only difference between the RNNS2S, ConvS2S, and Transformer networks that we tested. For example, Transformer has multiple attention layers, multi-head attention, residual feed-forward layers, etc. These modules may affect NMT models on capturing long-range dependencies and extracting semantic features.

Domhan2018how applies these advanced techniques of Transformer models to both RNN and CNN models in Sockeye, minimizing the architectural difference between them.777https://github.com/awslabs/sockeye/tree/acl18 We reuse his configurations to train minimally different RNN, CNN and Transformer models. All models have 6-layer encoders and decoders.

6.2.1 Subject-verb agreement

Table 8 gives the results of retrained models. Compared to the original results in Table 2, we find that these configurations have a large positive effect on BLEU and perplexity of RNNS2S and ConvS2S, but the effect on subject-verb-agreement over long distances is relatively small. These result further confirm our experimental results in Section 4 that non-recurrent neural networks are not superior to RNNs in capturing long-range dependencies.

Model 2014 2017 PPL Acc(%)
RNNS2S 25.6 26.5 4.9 96.9
ConvS2S 25.4 26.6 5.4 85.0
Transformer 26.1 27.4 4.7 96.6
Table 8: Post-publication results, including BLEU on newstest2014 and newstest2017, perplexity on the validation set, and accuracy of long-range dependencies.

6.2.2 Wsd

The performance of retrained models on WSD task is shown in Table 6. Compared to the original results in Table 5, the performance gap between Transformer models and the other models is getting smaller across all metrics (BLEU, perplexity, and WSD accuracy), although Transformer still performs best. This implies that some of the strong performance of the Transformer architecture for WSD is attributable to architecture choices such as multi-head attention, layer normalization, and upscaling feed-forward layers in each block. Nevertheless, the retrained RNNS2S and ConvS2S models are still not as good as the retrained Transformer models, so these results also further confirm our results in Section 5.

7 Conclusion

In this paper, we evaluate three popular NMT architectures, RNNS2S, ConvS2S, and Transformers, on subject-verb agreement and WSD by scoring contrastive translation pairs.

We test the theoretical claims that shorter path lengths make models better capture long-range dependencies. Our experimental results show that:

  • There is no evidence that CNNs and Transformers, which have shorter paths through networks, are empirically superior to RNNs in modeling subject-verb agreement over long distances.

  • The number of heads in multi-head attention affects the ability of a Transformer to model long-range dependencies in the subject-verb agreement task.

  • Transformer models excel at another task, WSD, compared to the CNN and RNN architectures we tested.

Lastly, our findings suggest that assessing the performance of NMT architectures means finding their inherent trade-offs, rather than simply computing their overall BLEU score. A clear understanding of those strengths and weaknesses is important to guide further work. Specifically, given the idiosyncratic limitations of recurrent and self-attentional models, combining them is an exciting line of research. The apparent weakness of CNN architectures on long-distance phenomena is also a problem worth tackling, and we can find inspiration from related work in computer vision

Xu et al. (2014).


We thank all the anonymous reviews and Joakim Nivre who give a lot of valuable and insightful comments. We appreciate the grants provided by Erasmus+ Programme and Anna Maria Lundin’s scholarship committee. GT is funded by the Chinese Scholarship Council (grant number 201607110016). MM, AR and RS have received funding from the Swiss National Science Foundation (grant number 105212_169888).