기본 정보
- 저자
- DOI
- 10.18653/v1/2021.findings-emnlp.357
- 저널
- –
- 발행년도
- 2021
- 발행기관
- –
- 피인용수
- 4
- 라이선스
- cc-by
- 논문 유형
- –
- 언어
- –
- 원문 페이지
- https://doi.org/10.18653/v1/2021.findings-emnlp.357
- 토픽
- High voltage insulation and dielectric phenomena
- OpenAlex ID
- W4206541903
평가 내용
- 관련도
- 사업분야
- 산업용 섬유 · (9) 타이어코드
- 부 분야
- –
- R&D 측면
- –
- 확신도
- –
- 근거 용어
- –
- 판단 근거
- 임베딩 유사도 기반 평가로 '산업용 섬유 > 타이어코드' 분야에 선정된 논문입니다.
- R&D 활용 포인트
- –
- 평가 입력
- –
초록
본문 29,038자
본문 펼치기
섹션 본문 23문단 · 11,986자
(제목 없음)
1Improving Transformer efficiency has become increasingly attractive recently. A wide range of methods has been proposed, e.g., pruning, quantization, new architectures and etc. But these methods are either sophisticated in implementation or dependent on hardware.In this paper, we show that the efficiency of Transformer can be improved by combining some simple and hardware-agnostic methods, including tuning hyper-parameters, better design choices and training strategies. On the WMT news translation tasks, we improve the inference efficiency of a strong Transformer system by 3.80× on CPU and 2.52× on GPU. The code is publicly available at https://github.com/Lollipop321/minidecoder-network.
Introduction
2Standard implementation of Transformer (Vaswani et al., 2017) is not efficient for inference. Researchers have explored more efficient architectures (Zhang et al., 2018;Li et al., 2021) or break the auto-regressive constraint in sequence generation (Gu et al., 2017). But most of these require significant updates of the model or hardware-dependent designs. It is still natural to ask whether the Transformer system can be optimized in a simple way (Hsu et al., 2020;Kasai et al., 2020;Kim et al., 2019;Wang and Tu, 2020).
3In this paper we show that Transformer can be optimized for efficiency by a bag of techniques. These techniques are easy to implement and some of them have been tested in related studies. Here we focus on using them in combination for Transformer speedup which has not been well investigated. In particular, our work is based on the following facts: * Authors contributed equally. † • The default Byte-Pair Encoding (BPE) setting (Sennrich et al., 2016) has a great impact on efficiency but is generally not optimal.
4• A shallow decoder (with a deeper encoder) is preferred for a fast system (Kasai et al., 2020).
5• The attention model does not need to be multiheaded in some cases (Behnke and Heafield, 2020).
6• The feedforward network sub-layer is removable (Hsu et al., 2020).
7• Knowledge Distillation (Hinton et al., 2015) is crucial to squeeze out the last potential. Removing some regularization measures like label smoothing (Szegedy et al., 2016) also helps when training such models.
8All these methods are compatible with popular Transformer codebases. In this work, we implement them on the decoder side because it occupies the inference time in many sequence generation tasks (Hsu et al., 2020;Kim et al., 2019). The end result is a simplified and fast Transformer decoder (see Table 1 speedup on GPU with performance on par with the baseline. The speedup obtained is available on most modern hardware, as it does not depend on specific hardware or library, e.g., quantization (Chung et al., 2020) and unstructured pruning (Hoefler et al., 2021) require the support of the latest hardware-dependent and acceleration libraries.
Byte-Pair Encoding
9Byte-Pair Encoding (BPE) (Sennrich et al., 2016) breaks words into subword units. It starts from the alphabet and merges characters into the most frequent subword units, then segments words in sentences by these merged subword units. BPE reduces the risk of out-of-vocabulary words with a small vocabulary, but comes with the cost of longer sentences. If more merge operations are employed, the resulting sentences will be shorter, yet the vocabulary is larger as more subword units are presented. This leads to a tradeoff between sentence length and vocabulary size, and both of them have an impact on the efficiency. In Fig. 1, the green line denotes the BLEU referencing the left axis. The red line denotes the speed change on CPU, the blue line denotes the speed change on GPU, they are both referencing the right axis. As shown in Fig. 1, tuning this hyper-parameter provides a considerable speedup without loss in performance, though most previous work simply adopts the default setting (32K). In our experiments we choose 10K because it is sufficient for good performance.
Model Structure Updates
10Inspired by the observations in Table 1, the Transformer decoder can be improved for each of its components. In this section, we describe how to Transformer Encoder Source Embedding Target Embedding simplify Transformer in a systematic way as shown in Fig. 2. Table 2 summarizes the contributions of each adopted method. We choose Baseline1 in Table 2 to analyze how each method in "Model Structure Updates" influences the model performance and inference speed after applying techniques from "Byte-Pair Encoding".
11Shallow Decoder. Recent work has shown that the deep encoder and shallow decoder architecture is promising in system speedup (Kasai et al., 2020;Li et al., 2021). In this work we follow the same idea by restricting the decoder to a 1-layer network and stacking more encoder layers until the total number of parameters matches the baseline.
12Pruning Heads. Researchers have found that most heads could be safely pruned and leaving the performance intact (Voita et al., 2019;Michel et al., 2019). So we retain only one head in decoder attentions.
13Dropping FFN. Hsu et al. (2020) used in the output projection is significantly overparameterized (Grave et al., 2017), especially when other components are compressed. To address this, we employ the low-rank approximation (Lan et al., 2020) for this matrix W = AB T to help to reduce the computation cost, where A ∈ R V ×E , B ∈ R H×E , V is the vocabulary size, E is the desired rank and H is the hidden size. We choose E = 64 in our experiments.
Training Strategies
14In our work, the methods presented in Section 2.2 can make an extremely small decoder that contains only 0.3% of the overall parameters. But we find that the model learned from scratch using the standard setting is much worse than the baseline (see Table 2). For better training, some methods are necessary. Table 3 illustrates how each proposed strategy contributes to reaching performance on par with the baseline. We choose Baseline2 in Table 3 to analyze how each method in "Training Strategies" influences the results after we have changed the BPE merge operations and simplified the model structure.
15Deep Configuration. Because our model is deep, we follow the deep model training setup provided in Wang et al. (2019).
16Weight Distillation. We also adopt a simplified version of weight distillation (WD) for training (Lin et al., 2020). This method initializes the student model with the corresponding weights from the teacher model, e.g., the first layer in the teacher encoder is reused in the first layer in the student encoder. Then it trains the student as in standard knowledge distillation (Hinton et al., 2015). Since our encoder is much deeper than the baseline, we initialize it in a round-robin manner. For the decoder, we randomly select one head from the teacher model for initialization, and the low-rank approximation of output projection is initialized by the SVD result of the teacher output projection (Golub and Reinsch, 2007).
17Weak Regularization. Because our decoder is small, we do not need to impose a strong regularization on it. We remove the dropout in the decoder and label smoothing. Dropout and label smoothing indeed do not have impacts on the inference speed. But changing them will train different models, which are unlikely to have exactly the same behavior. So some deviations in the inference speed are expected.
Setup
18We evaluate our methods on the WMT14 En-De, WMT14 En-Fr and NIST12 Zh-En machine translation tasks. We tokenize every sentence using a script from Moses and segment every word into subword units using BPE (Sennrich et al., 2016). The number of the BPE merge operations is set to 32K in the baseline and 10K for the target language in our model. In addition, we remove sentences with more than 250 subword units (Xiao et al., 2012). We choose Transformer-base (Vaswani et al., 2017) as our baseline. The hyper-parameters of the Mini-Decoder Network (MDN) are the same as the baseline except for those mentioned in Section 2.3. To produce consistent results for distillation, we choose the baseline with 10K BPE merges as the teacher model, which has the same vocabulary as MDN. We also compare our system with some recent proposed fast Transformer variants, e.g., AAN (Zhang et al., 2018), SAN and CAN (Li et al., 2021) followed from their papers. We report case-sensitive tokenized BLEU scores. For all experiments, we test on the model ensemble by averaging the last 5 checkpoints. For inference, we use a batch size of 64 and a beam width of 4. All models are evaluated on the NVIDIA TITAN V GPU and Intel(R) Xeon(R) Gold 5118 CPU. Table 4 shows the results of various systems. In both tasks, our method (MDN) has nearly the same performance as the baseline, but its speed is 3.80× and 2.52× faster on average for CPU and GPU. We find the baseline with 10K BPE merges is about 1.09× faster than the original baseline but with a similar performance, which suggests this BPE hyper-parameter is far from optimal for the baseline.
Results
19As for the recent work, i.e., AAN, SAN and CAN, all of them achieve performance similar to the baseline and are faster than the baseline (1.24×∼1.32× speedup on CPU) as reported in their papers. But our method outperforms these methods and runs consistently faster (3.80× speedup on CPU). Although the acceleration of our method in GPU (2.52× speedup) is not as obvious as it in CPU (3.80× speedup), it still outperforms CAN by 1.40×, which is highly optimized for GPU. Table 5 summarizes and compares the contributions of each proposed tricks described in Section 2. Each row of Table 5 is the result of applying the current trick to the system obtained in the previous row. This way helps to illustrate the compound effect of these tricks. We observe that using any structure simplification trick brings a significant performance degra- dation but a considerable speedup. However, our training strategies can make up for the performance loss. Among them, WD is most effective and has a boost of more than 3 BLEU points. Interestingly, we find that pruning attention heads does not have any speedup on GPU. This is because the parallelism of GPU decouples the computation cost of attention heads from the head number. Table 6 shows the results of the Transformer-deep model with a 48-layer encoder. The phenomenon here is similar to that in Table 4. The acceleration on Transformer-deep is less obvious than on Transformer-base, as a deeper encoder consumes more inference time. Moreover, compared with such a strong Transformer-deep teacher, MDN can still obtain a 2.49× speedup on CPU and a 2.09× speedup on GPU.
Sensitivity Analysis
20We study the impact of two commonly tuned hyperparameters at inference on our method, i.e., the batch size and the beam size. The left part of Fig. 3 shows that the speedup over the baseline decreases as the batch size increases, especially for GPU. This is because our shallow decoder trick exploits the parallelism of the encoder for speedup, which is not available if the batch size is large. This phenomenon is also observed by Li et al. (2021). The right part of Fig. 3 shows that the speedup is more obvious with a larger beam width. The reason is that the encoder occupies a larger portion of the inference cost at a small beam width and our work only save the cost of the decoder.
Combining with Other Models
21Our method is a bag of generic tricks and can be applied to other models. We choose AAN and CAN for testing, because AAN runs the fastest on CPU and CAN runs the fastest on GPU according to Table 4. Table 7 shows that both AAN and CAN benefit from techniques presented in this paper. Without loss in performance, AAN obtains a 1.97× speedup on CPU and CAN obtains a 1.05× speedup on GPU. It shows that AAN and CAN eventually have a similar BLEU score and speed as MDN, indicating that a highly optimized Transformer baseline already a strong candidate by itself.
Conclusion
22In this work, we present a bag of tricks to optimize the efficiency of the standard Transformer.
23The resulting model achieves a 3.61× speedup on CPU and a 2.62× speedup on GPU without loss in performance.
참고문헌 22건
- Distilling the Knowledge in a Neural Network arXiv (Cornell University) · Cornell University · 2015 10.48550/arxiv.1503.02531
- NiuTrans: An Open Source Toolkit for Phrase-based and Syntax-based Machine Translation 2012
- Rethinking the Inception Architecture for Computer Vision 2016 10.1109/cvpr.2016.308
- Efficient softmax approximation for GPUs arXiv (Cornell University) · Cornell University · 2016 10.48550/arxiv.1609.04309
- Non-Autoregressive Neural Machine Translation arXiv (Cornell University) · Cornell University · 2017 10.48550/arxiv.1711.02281
- Analyzing Multi-Head Self-Attention: Specialized Heads Do the Heavy Lifting, the Rest Can Be Pruned 2019 10.18653/v1/p19-1580
- Neural Machine Translation of Rare Words with Subword Units Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) · 2016 10.18653/v1/p16-1162
- Learning Deep Transformer Models for Machine Translation 2019 10.18653/v1/p19-1176
- Accelerating Neural Transformer via an Average Attention Network Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers) · 2018 10.18653/v1/p18-1166
- Sharing Attention Weights for Fast Transformer 2019 10.24963/ijcai.2019/735
- From Research to Production and Back: Ludicrously Fast Neural Machine Translation 2019 10.18653/v1/d19-5632
- ALBERT: A Lite BERT for Self-supervised Learning of Language\n Representations arXiv (Cornell University) · Cornell University · 2019 10.48550/arxiv.1909.11942
- Deep Encoder, Shallow Decoder: Reevaluating the Speed-Quality Tradeoff in Machine Translation arXiv (Cornell University) · Cornell University · 2020
- Extremely Low Bit Transformer Quantization for On-Device Neural Machine Translation 2020 10.18653/v1/2020.findings-emnlp.433
- Losing Heads in the Lottery: Pruning Transformer Attention in Neural Machine Translation 2020 10.18653/v1/2020.emnlp-main.211
- Efficient Inference For Neural Machine Translation 2020 10.18653/v1/2020.sustainlp-1.7
- Rethinking the Value of Transformer Components Proceedings of the 17th international conference on Computational linguistics - · 2020 10.18653/v1/2020.coling-main.529
- Weight Distillation: Transferring the Knowledge in Neural Network Parameters 2021 10.18653/v1/2021.acl-long.162
- An Efficient Transformer Decoder with Compressed Sub-layers Proceedings of the AAAI Conference on Artificial Intelligence · Association for the Advancement of Artificial Intelligence · 2021 10.1609/aaai.v35i15.17572
- Sparsity in Deep Learning: Pruning and growth for efficient inference\n and training in neural networks arXiv (Cornell University) · Cornell University · 2021 10.48550/arxiv.2102.00554
- Singular Value Decomposition and Least Squares Solutions Springer eBooks · Springer Nature · 1971 10.1007/978-3-662-39778-7_10
- MizAR 60 for Mizar 50 DROPS (Schloss Dagstuhl – Leibniz Center for Informatics) · Schloss Dagstuhl – Leibniz Center for Informatics · 2023 10.4230/lipics.itp.2023.19