D EEP E NCODER , S HALLOW D ECODER : R EEVALUATING N ON - AUTOREGRESSIVE M ACHINE T RANSLATION Anonymous authors
Paper under double-blind review
A BSTRACT
During the recent years, much effort has been invested in non-autoregressive neural machine translation, which appears to be an efﬁcient alternative to state-of-theart autoregressive machine translation on modern GPUs.
In contrast to the latter where generation is sequential, the former allows generation to be parallelized across target token positions.
Non-autoregressive machine translation provides a tradeoff between translation quality and inference speed, but some of the latest models have achieved impressive tradeoffs compared to autoregressive baselines.
In this work, we reexamine this tradeoff and argue that autoregressive baselines can be substantially sped up without loss in accuracy.
Speciﬁcally, we study autoregressive models with encoders and decoders of varied depths.
Our extensive experiments show that given a sufﬁciently deep encoder, a single-layer autoregressive decoder can substantially outperform strong non-autoregressive models with comparable inference speed.
We show that the speed disadvantage for autoregressive baselines compared to non-autoregressive methods has been overestimated in three aspects: suboptimal layer allocation, insufﬁcient speed measurement, and lack of knowledge distillation.
Our results establish a new protocol for future research toward fast, accurate machine translation.
I NTRODUCTION
Fast, accurate machine translation is a fundamental goal with a wide range of applications both in research and production.
State-of-the-art neural machine translation systems generate translations autoregressively where words are predicted one-by-one conditioned on all previous words (Kalchbrenner & Blunsom, 2013;
Sutskever et al., 2014; Bahdanau et al., 2015; Wu et al., 2016; Vaswani et al., 2017).
This sequential property limits parallelization since multiple tokens in each sentence cannot be generated in parallel.
A ﬂurry of recent work developed ways to (partially) parallelize the decoder with non-autoregressive machine translation (NAR; Gu et al., 2018), thereby speeding up decoding during inference.
NAR tends to suffer in translation quality because parallel decoding assumes conditional independence between the output tokens and prevents the model from properly capturing the highly multimodal distribution of target translations (Gu et al., 2018).
Recent work proposed methods to mitigate this multimodality issue, including iterative reﬁnement (e.g., Lee et al., 2018; Ghazvininejad et al., 2019;
Gu et al., 2019b; Kasai et al., 2020) and modeling with latent variables (e.g., Ma et al., 2019; Shu et al., 2020).
These approaches modify the decoder transformer to ﬁnd a balance between decoding parallelism and translation quality.
In this work, however, we adopt a different speed-quality tradeoff.
Recent work by Kim et al.
in autoregressive machine translation (AR) suggests that better speed-quality tradeoffs can be achieved by having different depths in the encoder and the decoder.
Here, we make a formal argument in favor of deep encoder, shallow decoder conﬁgurations and empirically demonstrate better speed-quality tradeoffs for the AR baselines.
We provide extensive speed-quality comparisons between iterative NAR models and AR models with varying numbers of encoder and decoder layers.
In particular, we use two types of speed measures for translation and discuss their relation to computational complexity.
The two measures reﬂect two different application scenarios: feeding one sentence at a time, and feeding as many words as possible into the GPU memory.
The ﬁrst scenario is designed to simulate, for example, instantaneous machine translation that translates text (or even speech) input from users.
This is where current NAR models shine—we can make full use of parallelism across decoding positions in a GPU.
For this reason, much prior work in NAR only measures speed using this metric (e.g., Gu et al., 2018; 2019b; Kasai et al., 2020; Li et al., 2020).
The second scenario aims at a situation where we want to translate a large amount of text as quickly as possible.
In this case, we see that AR models run faster than NAR models by a large margin.
Computation at each time step is large enough to exploit parallelism in a GPU, which cancels out the beneﬁt from parallel NAR decoding.
Further, AR models can speed up by caching all previous hidden states (Ott et al., 2019) and computing each step in linear time complexity with respect to the sequence length.
In contrast, NAR models necessitate a fresh run of quadratic self and cross attention in every decoding iteration.
Interestingly, using a deep encoder and a shallow decoder in NAR models fails to retain the original translation accuracy by using 6 layers each (§4.1).
This suggests that departure from AR decoding necessitates more computational capacity in the decoder side, and the strategy is effective speciﬁcally for AR models.
In particular, our analysis demonstrates that an NAR decoder requires more layers to learn target word ordering (§5).
In summary, our contributions are the following:
• We challenge three conventional assumptions in NAR evaluation: suboptimal layer allocation, lack of distillation for AR baselines, and insufﬁciently general speed measures.
• We provide a formal complexity analysis and identify an optimal layer allocation strategy that leads to better speed-quality tradeoffs, namely a deep-shallow conﬁguration.
• We perform extensive analyses and head-to-head comparisons of AR and strong NAR models on seven standard translation directions.
We demonstrate that the accuracy gap between the two model families is much wider than previously thought and that NAR models are unable to capture target word order well without sufﬁciently deep decoders.
R EEVALUATING N ON -A UTOREGRESSIVE M ACHINE T RANSLATION
We critically examine in this section the evaluation practices and assumptions that are widely held in the non-autoregressive neural machine translation (NAR) literature (e.g., Gu et al., 2018;
Ghazvininejad et al., 2019; Kasai et al., 2020).
In particular, we focus on three crucial aspects: speed measurement (§2.1), layer allocation (§2.2), and knowledge distillation (§2.3).
2. S PEED M EASURES
One major beneﬁt of NAR models over AR ones is their ability to generate text in parallel.
Current practice on measuring speed has focused solely on the setting of translating one sentence at a time where full parallelization is trivial with a single GPU.
However, we argue that this speed measure is not realistic in some scenarios because the GPU memory is ﬁnite and the GPU unit in such a setting is underused.
To address this issue, we use two translation speed metrics to measure inference speed:
• S 1 measures speed when translating one sentence at a time.
This metric is used in standard practice and aligns with applications like instantaneous machine translation that translate text input from users immediately.
• S max measures speed when translating in mini-batches as large as the hardware allows.
This corresponds to scenarios where one wants to translate a large amount of text given in advance.
For instance, such large-batch machine translation is implemented in the Googleand Amazon 2 cloud services.
For all models, both metrics measure wall-clock time from when the weights are loaded until the last sentence is translated.
We report speedups relative to an AR baseline with a 6-layer encoder and a 6-layer decoder following prior work (Gu et al., 2018; Li et al., 2020; Kasai et al., 2020).
2. L AYER A LLOCATION
Current evaluation practice in the NAR literature uses an equal number of layers for the encoder and decoder both in AR baselines and NAR models.
However, previous studies in AR machine about [Table] translation suggest that this allocation strategy leads to a suboptimal speed-quality tradeoff (Barone et al., 2017; Kim et al., 2019).
These ﬁndings have several implications for evaluating NAR methods.
We ﬁrst discuss the strategy of deep encoder, shallow decoder (§2.2.1), and provide a theoretical analysis of the speed-quality tradeoff in the context of NAR evaluation (§2.2.2).
Our analyses are veriﬁed empirically in the next section (§3).
2.2. D EEP E NCODER , S HALLOW D ECODER
In line with prior work on deep encoders or shallow decoders (Barone et al., 2017; Wang et al., 2019a; Kim et al., 2019), we depart from the convention to allocate an equal number of layers on both sides and explore pairing a deep encoder with a shallow decoder for both AR and NAR methods.
Here, we study the impact of such architectures and systematically compare AR and NAR methods.
As we will show in §3, an AR model with a deep-shallow conﬁguration retains translation accuracy, but can substantially reduce decoding time.
This is because at inference time, the encoder accounts for a smaller part of the overhead since its computation can be easily parallelized over source positions; on the other hand, the speedup gains from a lightweight decoder are substantial.
[Table]
2.2. C OMPLEXITY A NALYSIS
This section analyzes the complexities of transformer-based encoders, autoregressive and nonautoregressive decoders.
We focus on two key properties: (1) the total amount of operations and (2) time complexity when full parallelization is assumed (Harris, 2007).
Notation For simplicity let us assume the source and target text have the same length N .
T is the number of iterations in an iterative NAR method (typically T < N ).
Let E and D denote the numbers of encoder and decoder layers.
Table 1 breaks down the comparison.
AR and NAR models use the same encoder architecture.
There are several interesting distinctions between AR and NAR decoders.
First, although their total amounts of operations are both quadratic in sequence length, an NAR decoder with T decoding iterations needs T times more computation.
Second, an AR decoder has time complexity quadratic in sequence length.
This contrasts with the linear time complexity of an NAR decoder, which is the powerhouse of its S 1 speedup (§4.1).
This is because the attention computation can be readily parallelized across target positions in NAR decoders.
By such comparisons we make the following key observations:
(a) For both AR and NAR models, the time complexity is dominated by decoders.
When T < N , an NAR model has an advantage over its AR counterpart with the same layers.
(b) Innocuous as it may seem, the constant T contributes major computational cost in terms of the total operations of NAR models.
Empirically, T needs to be at least 4 to perform competitively to AR models (Ghazvininejad et al., 2019; Kasai et al., 2020).
(a) suggests that one can signiﬁcantly speed up S 1 decoding by using shallower decoders, while increasing the encoder depths only results in a mild slowdown.
As we will show later in the experiments, AR decoders are much more robust to using fewer layers than NAR decoders.
For example, AR E - 1 can decode much faster than AR E - D and comparably to NAR E - D , while retaining the accuracy of AR E - D .
By (b), one may expect a different trend in S max from S 1 : in large mini-batch decoding, an AR model can make use of the GPU’s compute units, since now parallelization happens over the instances in a mini-batch.
In other words, under the S max evaluation where the GPU is running close to its maximum ﬂop/s, NAR can actually be slower since it needs more operations due to its iterative decoding.
This is conﬁrmed by our experiments (§4.1).
2. K NOWLEDGE D ISTILLATION
Most NAR models rely on sequence-level knowledge distillation (Hinton et al., 2015; Kim & Rush, 2016) to achieve a reasonable speed-quality tradeoff, where NAR models are trained on output translations from an (larger) AR model.
Nevertheless, standard practice in this area assumes that knowledge distillation is not required for the AR baseline.
Here, we aim for fair evaluation by applying distillation to both model families; we depart from previous practice where NAR models trained with distillation are compared with AR models trained without (Ran et al., 2019;
Sun et al., 2019; Shu et al., 2020;
Zhou et al., 2020; Saharia et al., 2020) with a few exceptions (Ghazvininejad et al., 2019; Kasai et al., 2020).
Our analysis (§5) demonstrates that AR models also beneﬁt from knowledge distillation and that the accuracy gap between AR and NAR models is wider than previously established.
E XPERIMENTS
We compare NAR and AR models with different layer allocation strategies on standard machine translation datasets of varying languages and sizes.
Our results show that deep-shallow AR models provide a better speed-quality tradeoff than NAR models.
3. B ASELINES AND C OMPARISON
Prior work has proposed various approaches to non-autoregressive machine translation (NAR).
These methods must seek a balance between speed and quality: the more decoding parallelization is introduced into a model, the more the output quality deteriorates due to a conditional independence assumption.
Some of the existing NAR models rescore the candidates with external autoregressive models (Sun et al., 2019; Li et al., 2020), or apply reordering modules (Ran et al., 2019).
We mainly compare with two iterative NAR models (Ghazvininejad et al., 2019; Kasai et al., 2020) because of their strong performance without relying on any external system:
• CMLM (Ghazvininejad et al., 2019) predicts randomly masked target tokens given observed ones as well as the source.
At inference time, it ﬁrst predicts all target words nonautoregressively, and then iteratively masks and predicts the words that the model is least conﬁdent about.
Following previous practice (Ghazvininejad et al., 2019; 2020b), we decode 5 candidate lengths in parallel ( length beam ) with T = 4 or T = 10 iterations.
• DisCo (Kasai et al., 2020) predicts every target token given an arbitrary subset of the rest of the target tokens.
Following Kasai et al.
(2020), we use their parallel easy-ﬁrst inference, and set the maximum number of iterations to 10 and the length beam size to 5.
Knowledge Distillation We apply sequence-level knowledge distillation (Hinton et al., 2015; Kim & Rush, 2016) when training both NAR and AR models (§2.3).
For the teacher models, we use leftto-right AR transformer models: transformer-large for EN-DE, EN-ZH, EN-FR, and transformerbase for EN-RO (Ghazvininejad et al., 2019; Kasai et al., 2020).
3. E XPERIMENTAL S ETUP
We experiment with 7 translation directions from four datasets of various training data sizes:
WMT14 EN-DE (4.5M pairs), WMT16 EN-RO (610K), WMT17 EN-ZH (20M), and WMT
EN-FR (36M, EN → FR only).
These datasets are all encoded into BPE subwords (Sennrich et al., 2016).We follow the preprocessing and data splits of previous work (EN-DE: Vaswani et al., 2017;
EN-RO: Lee et al., 2018; EN-ZH: Hassan et al., 2018;
Wu et al., 2019; EN-FR: Gehring et al., 2017).
Following previous practice, we use SacreBLEU (Post, 2018) to evaluate EN → ZH performance, and
BLEU (Papineni et al., 2002) for others.
For all autoregressive models, we apply beam search with size 5 and length penalty 1.0.
All models are implemented using fairseq .
S 1 and S max wall-clock time speedups (§2) are evaluated on the same single Nvidia V100 GPU with 16GB memory.
We apply half-precision training and inference (Micikevicius et al., 2018; Ott et al., 2019).
It speeds up
NAR models’ S max by 30+%, but not S 1 , in line with previous observations (Kim et al., 2019).
Hyperparameters We follow the hyperparameters of the base sized transformer (Vaswani et al., 2017): 8 attention heads, 512 model dimensions, and 2,048 hidden dimensions for both the encoder and decoder.
For each model and dataset, the dropout rate is tuned from [ 0 .
3 ] based on development BLEU performance.
The EN → FR models are trained for 500K updates, while others for 300K (Kasai et al., 2020).
Dev.
BLEU is measured after each epoch, and we average the 5 best checkpoints to obtain the ﬁnal model (Vaswani et al., 2017).
See the appendix for further details.
R ESULTS AND D ISCUSSION
We provide in-depth results comparing performance and speedup across AR and NAR models.
[Table]
66- 126- 126- 12Speedup
[Figure]
L E
U
[Figure]
0.5x 1x 1.5x26.
66- 126- 126- 12Speedup
[Figure]
0.5x 1x 1.5x 2x 32.
66- 126- 126- 12Speedup (
[Figure]
CMLM
[Figure]
NAR [Figure] CMLM T
[Figure]
NAR: DisCo
AR
[Figure]
Fig.
1 shows translation speed-quality tradeoff curves of CMLM, DisCo, and AR models on EN-DE and RO-EN test data.
For each model we plot the results of conﬁgurations with varying encoder and decoder depths.
For brevity, we denote by E - D
a model with an E -layer encoder and a D -layer decoder.
All speedups are measured relative to the AR 6-6 baseline (§2).
Firstly, under the 6-6 conﬁguration, the AR model outperforms both CMLM and DisCo by a considerable margin in BLEU, but it achieves the slowest S 1 (See Figs. A-D).
Using a single-layer decoder, AR 6-1 gains a substantial S 1 speedup (2.6x for EN → DE and 2.9x for RO → EN), but this comes at a cost of BLEU: 28.34 vs. 27.39 for EN → DE, and 34.57 vs. 34.31 for RO → EN.
AR 12-1 lands on a balanced middle ground: it yields similar BLEU to AR 6-6, but its S 1 is more than 2.5 times faster.
Notably, AR 12-1 achieves even faster S 1 than that of the CMLM 6-6 model with 10 iterations.
In contrast, NAR 12-1 models generally suffer in BLEU compared to the 6-6 conﬁguration; e.g., 26. (DisCo 12-1) vs. 27.35 (DisCo 6-6) in EN → DE.
Interestingly, all NAR models achieve slower S max than the AR 6-6 baseline (DisCo 6-6: 0.3x;
CMLM 6-6 T =10: 0.1x in RO → EN).
This is consistent with our complexity analysis in §2.2.2, where we found that with the same layer allocation, iterative NAR models need more total computation than the AR counterpart.
AR 12-1 still gains a considerable speedup over AR 6-6 (2.0x in RO → EN).
These results suggest that current NAR models have little advantage when translating a large amount of text given in advance
[Table]
and one should clarify this distinction when discussing translation speed.
See the appendix for full results from all four directions.
Model
[Table]
Table 2 presents results from large bitext, EN ↔ ZH and EN → FR.
We observe similar trends: AR deep-shallow achieves similar BLEU to AR 6-6 while boosting both S 1 and S max speed substantially.
For EN ↔ ZH, AR deep-shallow has a more S 1 speedup than DisCo (2.7x vs. 2.5x in EN → ZH, 2.
vs. 2.6 in ZH → EN).
Particularly noteworthy is its performance in EN → FR: 42.04 BLEU, a 1.4 point improvement over the best NAR model.
These results illustrate that the strategy of having a deep encoder and shallow decoder remains effective in large-scale bitext when the model has to learn potentially more complex distributions from more samples.
Lastly, Table 3 compares AR deep-shallow to recent iteration-based NAR results.
All NAR models use the 6-6 conﬁguration with the base size (Vaswani et al., 2017) except that Imputer (Saharia et al., 2020) uses 12 self-attention layers over the concatenated source and target.
Overall, our AR deep-shallow models outperform most NAR models, with the only exception being EN → RO where it underperforms Imputer by 0.6 BLEU points.
However, each iteration takes strictly more time in the Imputer model than in CMLM or DisCo, since it requires a fresh run of 12-layer self attention over a concatenation of input and output sequences.
As we saw in Fig.
1, AR deep-shallow yields comparable S 1 to CMLM 6-6 with 4 iterations, which would be about twice as fast as Imputer with 8 iterations.
4. C ONSTRAINED V IEWS
In this section, we present two controlled experiments to compare NAR and AR models thoroughly.
S 1 Speed Constraint From §4.1 we see that compared to NAR models, AR deep-shallow yields a better translation speed-quality balance—despite being slightly slower in S 1 on some of the datasets, it achieves better BLEU across the board.
To conﬁrm this result, we further compare an AR deepshallow model against two NAR models, controlling for S 1 speed.
More speciﬁcally, we experiment with NAR models of varying encoder depths, and pair each with as many decoder layers as possible until it reaches AR 12-1’s S 1 speed.
Fig.
2 (left) shows the results.
For CMLM T =4, CMLM T =10, and DisCo, the best conﬁgurations of 12-layer encoders were paired up with 12, 4, and 9 decoder layers, respectively.
All NAR models improve performance as the encoder becomes deeper and surpass the scores of the 6-6 baselines (shown as squares along x = 6 ).
Nonetheless, there is still a large BLEU gap from AR 12-1.
This illustrates that the two NAR models are not able to match AR deep-shallow’s accuracy under the same S 1 speed budget.
Layer Constraint We can speed up autoregressive translation (AR) by developing a model with a deep encoder and a one-layer decoder.
Here we thoroughly compare layer allocation strategies.
Shown in Fig.
2 (middle) are results of NAR and AR methods under the constraint of 12 transformer layers in total.
NAR models perform well when the decoder and encoder are balanced with slight tendency to deep encoders.
On the other hand, the AR models perform consistently well with 4 or [Table] [Table] Ghazvininejad
[Table] al [Table] Lev
[Table]
2019b
[Table]
DisCo
[Table]
al
[Table]
et al. (2020b); Imputer:
Saharia et al.
Best performance is bolded.
more encoder layers.
This conﬁrms that using deep encoders and shallow decoders is more effective in AR models than in NAR ones.
Note that the number of parameters in each layer allocation differs since a decoder layer contains 30% more parameters than an encoder layer, due to cross attention.
[Figure]
F URTHER A NALYSIS
Speedup and Batch Size When decoding with large batches, NAR models can be slower than their
AR counterpart (§4.1).
Here we further study this effect.
Fig.
2 (right) plots the relative speedups of different models’ decoding with varying numbers of sentences per batch up to the hardware limit (“max,” §2.1).
The speedup by NAR models diminishes as the batch size grows: they have similar decoding speed to AR 6-6 with batch size 50, and become slower with larger batch sizes.
In contrast, the speedup from AR deep-shallow decreases much more gradually.
Decoder Depth and Reordering Words From earlier results we see that NAR models need deeper decoders than AR models to perform well.
We hypothesize that one reason is that NAR decoders need to learn to adjust to diverging word order between the source and the target: an AR decoder takes as input all preceding tokens and explicitly learns a conditional distribution, while an NAR decoder needs to learn target word ordering from scratch.
To test this hypothesis, we conduct the following controlled experiment in EN → DE translation.
We choose German because of its divergence in word order from English. We ﬁrst run the fast align tool (Dyer et al., 2013) 5 on all bitext data (including the test set), and disable the NULL word 5 https
/fast_align . [Table] feature to ensure that every English word is aligned to exactly one German word.
We then shufﬂe the English words according to the order of their aligned German words.
When multiple English words are aligned to the same German word, we keep the original English order.
Finally, we apply the same BPE operations as the original data
[Table] and train and evaluate various models on the new reordered data. Table 4 (left) shows the results.
AR gains the same improvement regardless of the layer conﬁguration; in contrast, NAR 12-1 beneﬁts more than NAR 6-6.
This result supports our hypothesis that word reordering is one reason why NAR models need a deeper decoder.
Effects of Distillation We applied sequence-level knowledge distillation (Kim & Rush, 2016) to all models.
Here we analyze its effects over the WMT14 EN → DE test data (Table 4 right).
An
AR transformer large model is used as the teacher model.
All models beneﬁt from distillation as indicated by positive ∆ , including the AR models.
6 Many recent works only compare NAR models trained with distillation to AR models trained without .
Our ﬁnding shows that that AR models with distillation can be an additional baseline for future NAR research.
AR deep-shallow deteriorates much less on the raw data compared to the iterative NAR methods, suggesting that the strategy of speeding up AR models is better suited to modeling raw, complex data than the NAR methods. [Figure] Breakdown by Sentence Length Fig.
3 illustrates the relation between BLEU scores and reference translation lengths.
We observe almost identical patterns between AR 6-6 and deep-shallow models, suggesting that they perform similarly regardless of the translation length.
Can we reduce the decoder further?
We saw that an autoregressive model with a single-layer decoder and a sufﬁciently deep encoder can retain the accuracy of the baseline with 6 layers each.
One may ask whether we can make the decoder even more compact.
Our preliminary experiments showed that we can remove the feed-forward module from the decoder without hurting performance.
This increases the S 1 speed by 10%.
We leave further exploration to future work.
Length Candidates and S max for NAR Following the original works (Ghazvininejad et al., 2019;
Kasai et al., 2020), we ﬁxed the number of length candidates (i.e., the length beam size) to 5 for all
NAR models, but a smaller beam size can speed up S max by allowing more sentences to be fed in a batch. Indeed, we found that NAR models can improve their S max by reducing the beam size at the expense of some accuracy drop. For example, we observed a loss of 0.5 BLEU points in EN → DE when decreasing the length beam size from 5 to 1. Nonetheless, NAR 6-6 models with beam sizeresulted in 0.6–0.9x S max compared to the AR 6-6 baseline.
This is consistent with our results that
{+NAR models with beam size 5 yield about 0.1–0.2x S max of AR 6-6 (Fig. 
+}
and Table 2) because a model with length beam size 1 can translate about 5 times more sentences in each batch than length beam size 5.
Therefore, while reducing the length beam size is an effective strategy to improve
NAR’s S max , it still underperforms the AR baseline both in S max speed and accuracy.
F URTHER R ELATED W ORK
Non-autoregressive Machine Translation
In addition to the work already discussed, several other works proposed to iteratively reﬁne (or insert) output predictions (Mansimov et al., 2019; Stern et al., 2019;
Gu et al., 2019a; Chan et al., 2019a;b;
Li et al., 2020; Guo et al., 2020).
Other approaches include adding a light autoregressive module to parallel decoding (Kaiser et al., 2018;
Sun et al., 2019; Ran et al., 2019), partially decoding autoregressively (Stern et al., 2018; 2019), rescoring output candidates autoregressively (e.g., Gu et al., 2018), mimicking hidden states of an autoregressive teacher (Li et al., 2019), training with different objectives than vanilla cross-entropy (Libovick ´ y &
Helcl, 2018; Wang et al., 2019b; Shao et al., 2020; Tu et al., 2020; Saharia et al., 2020; Ghazvininejad et al., 2020a), reordering input sentences (Ran et al., 2019), training on additional data from an autoregressive model (Zhou & Keung, 2020), and modeling with latent variables (Ma et al., 2019;
Shu et al., 2020).
The approach of adding a light autoregressive module is closest to our method, but note that we pack all non-autoregressive computation into the encoder.
Optimizing Autoregressive Transformer
Prior work has suggested various ways to optimize autoregressive transformers for fast inference.
For example, Kim et al.
(2019) considered shallow decoders and layer tying (Dabre & Fujita, 2019; Dehghani et al., 2019) on the transformer decoder and found that it sped up inference on CPUs, but not on a GPU, which was our focus.
Kim et al.
(2019) also explored concurrent streams where multiple batches are fed at once to make better use of a GPU.
Shi & Knight (2017) proposed a vocabulary reduction method to speed up the last softmax computation.
Senellart et al.
(2018) also adopted vocabulary reduction and explored “fat decoder, thin encoder” on RNN-based models.
Zhang et al.
(2018) used dynamic programming in an average attention network to accelerate inference.
Wu et al.
(2019) developed a model with dynamic convolutions and compared its speed and accuracy with non-autoregressive models.
Other works proposed methods to reduce attention computation in autoregressive transformers (Kitaev et al., 2020;
Katharopoulos et al., 2020; Chelba et al., 2020).
Some of these methods can be used orthogonally to further facilitate fast inference in a transformer, but our goal is to fairly reexamine the speed quality tradeoff between autoregressive and non-autoregressive approaches under the same condition.
C ONCLUSION AND F UTURE W ORK
We presented theoretical and empirical studies to demonstrate that autoregressive neural machine translation can be dramatically sped up by a simple layer allocation strategy: deep encoder, shallow decoder.
Compared to strong non-autoregressive models, deep-shallow autoregressive models achieve substantial improvement in translation quality with comparable inference speed.
Our results suggest that layer allocation, knowledge distillation, and speed measurement are important aspects that future work on non-autoregressive machine translation should take into consideration.
More generally, a model with a deep encoder and a shallow decoder can be used for any sequence-tosequence task, including large-scale pretraining (Lewis et al., 2020; Liu et al., 2020).
A PPENDIX
A. R ESULTS
Table 5 provides comparisons of speed and quality in WMT14 EN − DE and WMT16 EN − RO datasets. [Table]
A. H YPERPARAMETERS AND S ETTING
All of our models are implemented in fairseq (Ott et al., 2019) and trained with 16 Telsa V
GPUs CUDA 10.1, and cuDNN 7.6.3.
We used mixed precision and distributed training over
GPUs interconnected by Inﬁniband (Micikevicius et al., 2018; Ott et al., 2018).
Apart from EN ↔ ZH where we used separate BPE operations, we tie all embeddings (Press & Wolf, 2017; Inan et al., 2017).
We generally follow the hyperparameters chosen in Vaswani et al.
; Ghazvininejad et al.
; Kasai et al.
regardless of the numbers of encoding and decoding layers.
7 Speciﬁcally, we list the hyperparameters in Table 6 for easy replication.
All other hyperparamter options are left as default values in fairseq . [Table] [Table] The previous
[Table]
The list above is certainly incomplete
The
[Table]
above is
[Table]
not complete
[Table]
Indeed, the investment in both saving lives and reining in terror needs to be sustained over the medium-term in order to effectively turn the tide in this continuing tragedy.
In fact, the investment made in saving lives and controlling terror must be maintained in the medium term in order to effectively reverse the momentum of this continuing tragedy.
Indeed, investment in saving lives and controlling terror must be maintained in the medium term in order to effectively reverse the momentum of this continuing tragedy.
[Table]
A. S AMPLE O UTPUTS
Here we provide translation outputs randomly sampled from the validation data in ZH → EN.
We do not ﬁnd a qualitative difference between AR 6-6 and deep-shallow 12-1 models.