Title: EXPLICIT SPARSE TRANSFORMER: CONCENTRATED ATTENTION THROUGH EXPLICIT SELECTION

Abstract: Self-attention-based Transformer has demonstrated the state-of-the-art performances in a number of natural language processing tasks. Self-attention is able to model long-term dependencies, but it may suffer from the extraction of irrelevant information in the context. To tackle the problem, we propose a novel model called Explicit Sparse Transformer. Explicit Sparse Transformer is able to improve the concentration of attention on the global context through an explicit selection of the most relevant segments. Extensive experimental results on a series of natural language processing and computer vision tasks, including neural machine translation, image captioning, and language modeling, all demonstrate the advantages of Explicit Sparse Transformer in model performance. We also show that our proposed sparse attention method achieves comparable or better results than the previous sparse attention method, but significantly reduces training and testing time. For example, the inference speed is twice that of sparsemax in Transformer model.

1. INTRODUCTION:

Understanding natural language requires the ability to pay attention to the most relevant information. For example, people tend to focus on the most relevant segments to search for the answers to their questions in mind during reading. However, retrieving problems may occur if irrelevant segments impose negative impacts on reading comprehension. Such distraction hinders the understanding process, which calls for an effective attention.

This principle is also applicable to the computation systems for natural language. Attention has been a vital component of the models for natural language understanding and natural language generation. Recently, Vaswani et al. (2017) proposed Transformer, a model based on the attention mechanism for Neural Machine Translation(NMT). Transformer has shown outstanding performance in natural language generation tasks. More recently, the success of BERT (Devlin et al., 2018) in natural language processing shows the great usefulness of both the attention mechanism and the framework of Transformer.

However, the attention in vanilla Transformer has a obvious drawback, as the Transformer assigns credits to all components of the context. This causes a lack of focus. As illustrated in Figure 1 , the attention in vanilla Transformer assigns high credits to many irrelevant words, while in Explicit Sparse Transformer, it concentrates on the most relevant k words. For the word "tim", the most related words should be "heart" and the immediate words. Yet the attention in vanilla Transformer does not focus on them but gives credits to some irrelevant words such as "him".

Recent works have studied applying sparse attention in Transformer model. However, they either add local attention constraints (Child et al., 2019) which break long term dependency or hurt the time efficiency (Martins & Astudillo, 2016) . Inspired by Ke et al. (2018) which introduce sparse credit assignment to the LSTM model, we propose a novel model called Explicit Sparse Transformer which is equipped with our sparse attention mechanism. We implement an explicit selection method based on top-k selection. Unlike vanilla Transformer, Explicit Sparse Transformer only pays attention to the k most contributive states. Thus Explicit Sparse Transformer can perform more concentrated attention than vanilla Transformer.

Figure 1 : Illustration of self-attention in the models. The orange bar denotes the attention score of our proposed model while the blue bar denotes the attention scores of the vanilla Transformer. The orange line denotes the attention between the target word "tim" and the selected top-k positions in the sequence. In the attention of vanilla Transformer, "tim" assigns too many non-zero attention scores to the irrelevant words. But for the proposal, the top-k largest attention scores removes the distraction from irrelevant words and the attention becomes concentrated.

We first validate our methods on three tasks. For further investigation, we compare our methods with previous sparse attention methods and experimentally answer how to choose k in a series of qualitative analyses. We are surprised to find that the proposed sparse attention method can also help with training as a regularization method. Visual analysis shows that Explicit Sparse Transformer exhibits a higher potential in performing a high-quality alignment. The contributions of this paper are presented below:

• We propose a novel model called Explicit Sparse Transformer, which enhances the concentration of the Transformer's attention through explicit selection.

• We conducted extensive experiments on three natural language processing tasks, including Neural Machine Translation, Image Captioning and Language Modeling. Compared with vanilla Transformer, Explicit Sparse Transformer demonstrates better performances in the above three tasks. Specifically, our model reaches the state-of-the-art performances in the IWSLT 2015 English-to-Vietnamese translation.

• Compared to previous sparse attention methods for transformers, our methods are much faster in training and testing, and achieves better results.

2. PREMIERS:

The review to the attention mechanism and the attention-based framework of Transformer can be found in Appendix A.1.

3. EXPLICIT SPARSE TRANSFORMER:

Lack of concentration in the attention can lead to the failure of relevant information extraction. To this end, we propose a novel model, Explicit Sparse Transformer, which enables the focus on only a few elements through explicit selection. Compared with the conventional attention, no credit will be assigned to the value that is not highly correlated to the query. We provide a comparison between the attention of vanilla Transformer and that of Explicit Sparse Transformer in Figure 2 . Explicit Sparse Transformer is still based on the Transformer framework. The difference is in the implementation of self-attention. The attention is degenerated to the sparse attention through top-k selection. In this way, the most contributive components for attention are reserved and the other irrelevant information are removed. This selective method is effective in preserving important information and removing noise. The attention can be much more concentrated on the most contributive elements of value. In the following, we first introduce the sparsification in self-attention and then extend it to context attention.

- sign 𝕄 + 1 -𝕄 -∞ x 𝒑 𝟏𝟏 -∞ … -∞ -∞ 𝒑 𝟐𝟐 … 𝒑 𝟐𝒍𝒌 . . . . . . . . . . . . 𝒑 𝒍𝒒𝟏 -∞ … -∞ 𝝈 𝜶 𝟏𝟏 𝟎

In the unihead self-attention, the key components, the query

Q[l Q , d], key K[l K , d] and value V [l V , d],

are the linear transformation of the source context, namely the input of each layer, where Q = W Q x, K = W K x and V = W V x. Explicit Sparse Transformer first generates the attention scores P as demonstrated below:

P = QK T √ d (1)

Then the model evaluates the values of the scores P based on the hypothesis that scores with larger values demonstrate higher relevance. The sparse attention masking operation M(•) is implemented upon P in order to select the top-k contributive elements. Specifically, we select the k largest element of each row in P and record their positions in the position matrix (i, j), where k is a hyperparameter. To be specific, say the k-th largest value of row i is t i , if the value of the j-th component is larger than t i , the position (i, j) is recorded. We concatenate the threshold value of each row to form a vector

t = [t 1 , t 2 , • • • , t l Q ].

The masking functions M(•, •) is illustrated as follows:

EQUATION

With the top-k selection, the high attention scores are selected through an explicit way. This is different from dropout which randomly abandons the scores. Such explicit selection can not only guarantee the preservation of important components, but also simplify the model since k is usually a small number such as 8, detailed analysis can be found in 5.2. The next step after top-k selection is normalization:

EQUATION

where A refers to the normalized scores. As the scores that are smaller than the top k largest scores are assigned with negative infinity by the masking function M(•, •), their normalized scores, namely the probabilities, approximate 0. We show the back-propagation process of Top-k selection in A.3. The output representation of self-attention C can be computed as below:

C = AV (4) Model En-De En-Vi De-En

ConvS2S (Gehring et al., 2017) 25.2 --Actor-Critic (Bahdanau et al., 2017) --28.5 NPMT+LM (Huang et al., 2017) -28.1 30.1 SACT (Lin et al., 2018) -29.1 -Var-Attn (Deng et al., 2018) --33.7 NP2MT Feng et al. (2018) -30.6 31.7 Transformer (Vaswani et al., 2017) 28.4 --RNMT (Chen et al., 2018) 28.5 --Fixup (Zhang et al., 2019) 29.3 -34.5 Weighted Transformer (Ahmed et al., 2017) 28.9 --Universal Transformer (Dehghani et al., 2018) 28.9 --Layer-wise Coordination (He et al., 2018) 29.1 --Transformer(relative position) (Shaw et al., 2018) 29.2 --Transformer (Ott et al., 2018) 29.3 --DynamicConv (Wu et al., 2019) 29 The output is the expectation of the value following the sparsified distribution A. Following the distribution of the selected components, the attention in the Explicit Sparse Transformer model can obtain more focused attention. Also, such sparse attention can extend to context attention. Resembling but different from the self-attention mechanism, the Q is no longer the linear transformation of the source context but the decoding states s. In the implementation, we replace Q with W Q s, where W Q is still learnable matrix.

In brief, the attention in our proposed Explicit Sparse Transformer sparsifies the attention weights.

The attention can then become focused on the most contributive elements, and it is compatible to both self-attention and context attention. The simple implementation of this method is in the Appendix A.4.

4. RESULTS:

We conducted a series of experiments on three natural language processing tasks, including neural machine translation, image captioning and language modeling. Detailed experimental settings are in Appendix A.2.

4.1. NEURAL MACHINE TRANSLATION:

Dataset To evaluate the performance of Explicit Sparse Transformer in NMT, we conducted experiments on three NMT tasks, English-to-German translation (En-De) with a large dataset, English-to-Vietnamese (En-Vi) translation and German-to-English translation (De-En) with two datasets of medium size. For En-De, we trained Explicit Sparse Transformer on the standard dataset for WMT 2014 En-De translation. The dataset consists of around 4.5 million sentence pairs. The source and target languages share a vocabulary of 32K sub-word units. We used the newstest 2013 for validation and the newstest 2014 as our test set. We report the results on the test set.

For En-Vi, we trained our model on the dataset in IWSLT 2015 (Cettolo et al., 2014) . The dataset consists of around 133K sentence pairs from translated TED talks. The vocabulary size for source language is around 17,200 and that for target language is around 7,800. We used tst2012 for validation, and tst2013 for testing and report the testing results. For De-En, we used the dataset in IWSLT 2014. The training set contains 160K sentence pairs and the validation set contains 7K sentences. Following Edunov et al. (2018) , we used the same test set with around 7K sentences. The data were preprocessed with byte-pair encoding (Sennrich et al., 2016) . The vocabulary size is 14,000.

Result Table 1 

4.2. IMAGE CAPTIONING:

Dataset We evaluated our approach on the image captioning task. Image captioning is a task that combines image understanding and language generation. We conducted experiments on the Microsoft COCO 2014 dataset (Chen et al., 2015a) . It contains 123,287 images, each of which is paired 5 with descriptive sentences. We report the results and evaluate the image captioning model on the MSCOCO 2014 test set for image captioning. We used the publicly-available splits provided by Karpathy & Li (2015) . The validation set and test set both contain 5,000 images.

Result Table 2 shows the results of the baseline models and Explicit Sparse Transformer on the COCO Karpathy test split. Transformer outperforms the mentioned baseline models. Explicit Sparse Transformer outperforms the implemented Transformer by +0.4 in terms of BLEU-4, +0.3 in terms of METEOR, +0.7 in terms of CIDEr. , which consistently proves its effectiveness in Image Captioning.

4.3. LANGUAGE MODELING:

Dataset Enwiki82 is large-scale dataset for character-level language modeling. It contains 100M bytes of unprocessed Wikipedia texts. The inputs include Latin alphabets, non-Latin alphabets, XML markups and special characters. The vocabulary size 205 tokens, including one for unknown characters. We used the same preprocessing method following Chung et al. (2015) . The training set contains 90M bytes of data, and the validation set and the test set contains 5M respectively.

Result Table 3 

5. DISCUSSION:

In this section, we performed several analyses for further discussion of Explicit Sparse Transformer. First, we compare the proposed method of topk selection before softmax with previous sparse attention method including various variants of sparsemax (Martins & Astudillo, 2016; Correia et al., 2019; Peters et al., 2019) . Second, we discuss about the selection of the value of k. Third, we demonstrate that the top-k sparse attention method helps training. In the end, we conducted a series of qualitative analyses to visualize proposed sparse attention in Transformer.

5.1. COMPARISON WITH OTHER SPARSE ATTENTION METHODS:

We compare the performance and speed of our method with the previous sparse attention methods3 on the basis of strong implemented transformer baseline. The training and inference speed are reported on the platform of Pytorch and IWSLT 2014 De-En translation dataset, the batch size for inference is set to 128 in terms of sentence and half precision training(FP-16) is applied.

As we can see from Table 4 , the proposed sparse attention method achieve the comparable results as previous sparse attention methods, but the training and testing speed is 2x faster than sparsemax and 10x faster than Entmax-alpha during the inference. This is due to the fact that our method does not introduce too much computation for calculating sparse attention scores.

The other group of sparse attention methods of adding local attention constraints into attention (Child et al., 2019; Sukhbaatar et al., 2019) , do not show performance on neural machine translation, so we do not compare them in Table 4 . Table 5 : Results of the ablation study of the sparsification at different phases on the En-Vi test set. "Base" denotes vanilla Transformer. "T" denotes only adding the sparsification in the training phase, and "T&P" denotes adding it at both phases as the implementation of Explicit Sparse Transformer does.

5.2. HOW TO SELECT A PROPER K?:

The natural question of how to choose the optimal k comes with the proposed method. We compare the effect of the value of k at exponential scales. We perform experiments on En-Vi and De-En from 3 different initializations for each value of K, and report the mean BLEU scores on the valid set.

The figure 3 shows that regardless of the value of 16 on the En-Vi dataset, the model performance generally rises first and then falls as k increases. Under the setting of the k ∈ {4, 8, 16, 32}, setting the value of k to 8 achieves consistent improvements over the

5.3. DO THE PROPOSED SPARSE ATTENTION METHOD HELPS TRAINING?:

We are surprised to find that only adding the sparsification in the training phase can also bring an improvement in the performance. We experiment this idea on IWSLT En-Vi and report the results on the valid set in Table 5 , . The improvement of 0.3 BLEU scores shows that vanilla Transformer may be overparameterized and the sparsification encourages the simplification of the model.

5.4. DO THE EXPLICIT SPARSE TRANSFORMER ATTEND BETTER?:

To perform a thorough evaluation of our Explicit Sparse Transformer, we conducted a case study and visualize the attention distributions of our model and the baseline for further comparison. Specifically, we conducted the analysis on the test set of En-Vi, and randomly selected a sample pair of attention visualization of both models.

The visualization of the context attention of the decoder's bottom layer in Figure 4 (a). The attention distribution of the left figure is fairly disperse. On the contrary, the right figure shows that the sparse attention can choose to focus only on several positions so that the model can be forced to stay focused. For example, when generating the phrase "for thinking about my heart"(Word-to-word translation (b) Attention of the top layer from Vietnamese), the generated word cannot be aligned to the corresponding words. As to Explicit Sparse Transformer, when generating the phrase "with all my heart", the attention can focus on the corresponding positions with strong confidence.

The visualization of the decoder's top layer is shown in Figure 4 (b). From the figure, the context attention at the top layer of the vanilla Transformer decoder suffers from focusing on the last source token. This is a common behavior of the attention in vanilla Transformer. Such attention with wrong alignment cannot sufficiently extract enough relevant source-side information for the generation. In contrast, Explicit Sparse Transformer, with simple modification on the vanilla version, does not suffer from this problem, but instead focuses on the relevant sections of the source context. The figure on the right demonstrating the attention distribution of Explicit Sparse Transformer shows that our proposed attention in the model is able to perform accurate alignment.

6. RELATED WORK:

Attention mechanism has demonstrated outstanding performances in a number of neural-networkbased methods, and it has been a focus in the NLP studies (Bahdanau et al., 2014) . A number of studies are proposed to enhance the effects of attention mechanism (Luong et al., 2015; Vaswani et al., 2017; Ke et al., 2018) . Luong et al. (2015) propose local attention and Yang et al. (2018) propose local attention for self-attention. Xu et al. (2015) propose hard attention that pays discrete attention in image captioning. Chandar et al. (2016) propose a combination soft attention with hard attention to construct hierarchical memory network. Lin et al. (2018) propose a temperature mechanism to change the softness of attention distribution. Shen et al. (2018) propose an attention which can select a small proportion for focusing. It is trained by reinforcement learning algorithms (Williams, 1992) .

In terms of memory networks, Rae et al. (2016) propose to sparse access memory Child et al. (2019) recently propose to use local attention and block attention to sparsify the transformer. Our approach differs from them in that our method does not need to block sentences and still capture long distance dependencies. Besides, we demonstrate the importance of Explicit Sparse Transformer in sequence to sequence learning. Although the variants of sparsemax (Martins & Astudillo, 2016; Correia et al., 2019; Peters et al., 2019) improve in machine translation tasks, we empirically demonstrate in 5.1 that our method introduces less computation in the standard transformer and is much faster than those sparse attention methods on GPUs.

7. CONCLUSION:

In Take the original attention mechanism in NMT as an example. Both key K ∈ R n×d and value V ∈ R n×d are the sequence of output states from the encoder. Query Q ∈ R m×d is the sequence of output states from the decoder, where m is the length of Q, n is the length of K and V , and d is the dimension of the states. Thus, the attention mechanism is formulated as:

EQUATION

where f refers to the attention score computation.

A.1.2 TRANSFORMER Transformer (Vaswani et al., 2017) , which is fully based on the attention mechanism, demonstrates the state-of-the-art performances in a series of natural language generation tasks. Specifically, we focus on self-attention and multi-head attention.

The ideology of self-attention is, as the name implies, the attention over the context itself. In the implementation, the query Q, key K and value V are the linear transformation of the input x, so that Q = W Q x, K = W K x and V = W V x where W Q , W K and W V are learnable parameters. Therefore, the computation can be formulated as below:

EQUATION

where d refers to the dimension of the states.

The aforementioned mechanism can be regarded as the unihead attention. As to the multi-head attention, the attention computation is separated into g heads (namely 8 for basic model and 16 for large model in the common practice). Thus multiple parts of the inputs can be computed individually.

For the i-th head, the output can be computed as in the following formula:

EQUATION

where C (i) refers to the output of the head, Q (i) , K (i) and V (i) are the query, key and value of the head, and d k refers to the size of each head (d k = d/g). Finally, the output of each head are concatenated for the output:

EQUATION

) In common practice, C is sent through a linear transformation with weight matrix W c for the final output of multi-head attention.

However, soft attention can assign weights to a lot more words that are less relevent to the query. Therefore, in order to improve concentration in attention for effective information extraction, we study the problem of sparse attention in Transformer and propose our model Explicit Sparse Transformer.

A.2 EXPERIMENTAL DETAILS:

We use the default setting in Vaswani et al. (2017) for the implementation of our proposed Explicit Sparse Transformer. The hyper parameters including beam size and training steps are tuned on the valid set.

Neural Machine Translation:

Training For En-Vi translation, we use default scripts and hyperparameter setting of tensor2tensor4 v1.11.0 to preprocess, train and evaluate our model. We use the default scripts of fairseq5 v0.6.1 to preprocess the De-En and En-De dataset. We train the model on the En-Vi dataset for 35K steps with batch size of 4K. For IWSLT 2015 De-En dataset, batch size is also set to 4K, we update the model every 4 steps and train the model for 90epochs. For WMT 2014 En-De dataset, we train the model for 72 epochs on 4 GPUs with update frequency of 32 and batch size of 3584. We train all models on a single RTX2080TI for two small IWSLT datasets and on a single machine of 4 RTX TITAN for WMT14 En-De. In order to reduce the impact of random initialization, we perform experiments with three different initializations for all models and report the highest for small datasets.

Evaluation We use case-sensitive tokenized BLEU score (Papineni et al., 2002) for the evaluation of WMT14 En-De, and we use case-insensitive BLEU for that of IWSLT 2015 En-Vi and IWSLT 2014 De-En following Lin et al. (2018) . Same as Vaswani et al. (2017) , compound splitting is used for WMT 14 En-De. For WMT 14 En-De and IWSLT 2014 De-En, we save checkpoints every epoch and average last 10 checkpoints every 5 epochs, We select the averaged checkpoint with best valid BLEU and report its BLEU score on the test set. For IWSLT 2015 En-Vi, we save checkpoints every 600 seconds and average last 20 checkpoints.

Image Captioning We still use the default setting of Transformer for training our proposed Explicit Sparse Transformer. We report the standard automatic evaluation metrics with the help of the COCO captioning evaluation toolkit6 (Chen et al., 2015b) , which includes the commonly-used evaluation metrics, BLEU-4 Papineni et al. (2002) , METEOR Denkowski & Lavie (2014), and CIDEr Vedantam et al. (2015) .

Language Models We follow Dai et al. (2019) and use their implementation for our Explicit Sparse Transformer. Following the previous work (Chung et al., 2015; Dai et al., 2019) , we use BPC (E[log 2 P (xt + 1|ht)]), standing for the average number of Bits-Per-Character, for evaluation. Lower BPC refers to better performance. As to the model implementation, we implement Explicit Sparse Transformer-XL, which is based on the base version of Transformer-XL. 7 Transformer-XL is a model based on Transformer but has better capability of representing long sequences.

A.3 THE BACK-PROPAGATION PROCESS OF TOP-K SELECTION:

The masking function M(•, •) is illustrated as follow:

EQUATION

Denote M = M(P, k). We regard t i as constants. When back-propagating, ∂M ij ∂P kl = 0 (i = k or j = l) (10) 

∂M ij ∂P ij = 1 if P ij ≥ t i (k-

The softmax function is evidently differentiable, therefore, we have calculated the gradient involved in top-k selection.

A.4 IMPLEMENTATION Figure 5 shows the code for the idea in case of single head self-attention, the proposed method is easy to implement and plug in the successful Transformer model.

:

While we did not find the results of Transformer on En-Vi, we reimplemented our vanilla Transformer with the same setting.

http://mattmahoney.net/dc/text.html

We borrow the implementation of Entmax1.5 in Tensorflow from https://github.com/ deep-spin/entmax, and the implementation of Sparsemax, Entmax-1.5, Entmax-alpha in Pytorch from https://gist.github.com/justheuristic/60167e77a95221586be315ae527c3cbd. We have not found a reliable Tensorflow implementation of sparsemax and entmax-alpha in the transformer (we tried to apply the official implementation of sparsemax in Tensorflow to tensor2tensor, but it reports loss of NaN.)

https://github.com/tensorflow/tensor2tensor

https://github.com/pytorch/fairseq

https://github.com/tylin/coco-caption

Due to our limited resources (TPU), we did not implement the big version of Explicit Sparse Transformer-XL.

Figures and Tables:

Figure 2: The comparison between the attentions of vanilla Transformer and Explicit Sparse Transformer and the illustration of the attention module of Explicit Sparse Transformer. With the mask based on top-k selection and softmax function, only the most contributive elements are assigned with probabilities.

Figure 3: Analyse the value of K on IWSLT En-Vi and De-En datasets. "inf" denotes the special case of the Explicit Sparse Transformer where all positions may be attended, same as the origin Transformer.

Figure 4: Figure 4(a) is the attention visualization of Transformer and Figure 4(b) is that of the Explicit Sparse Transformer. The red box shows that the attentions in vanilla Transformer at most steps are concentrated on the last token of the context.

. (2014) first introduced the attention mechanism to learn the alignment between the target-side context and the source-side context, andLuong et al. (2015) formulated several versions for local and global attention. In general, the attention mechanism maps a query and a key-value pair to an output. The attention score function and softmax normalization can turn the query Q and the key K into a distribution α. Following the distribution α, the attention mechanism computes the expectation of the value V and finally generates the output C.

Results on the MSCOCO Karpathy test split.

Table content: <table><tr><td>Model</td><td colspan="3">BLEU-4 METEOR CIDEr</td></tr><tr><td>SAT Bazzani et al. (2018b)</td><td>28.2</td><td>24.8</td><td>92.3</td></tr><tr><td>SCST Rennie et al. (2017)</td><td>32.8</td><td>26.7</td><td>106.5</td></tr><tr><td>NBT Lu et al. (2018)</td><td>34.7</td><td>27.1</td><td>107.2</td></tr><tr><td>AdaAtt Lu et al. (2017)</td><td>33.2</td><td>26.6</td><td>108.5</td></tr><tr><td>ARNN Bazzani et al. (2018a)</td><td>33.9</td><td>27.6</td><td>109.8</td></tr><tr><td>Transformer</td><td>35.3</td><td>27.7</td><td>113.1</td></tr><tr><td>UpDown Anderson et al. (2018)</td><td>36.2</td><td>27.0</td><td>113.5</td></tr><tr><td>Explicit Sparse Transformer</td><td>35.7</td><td>28.0</td><td>113.8</td></tr></table>

presents the results of the baselines and our Explicit Sparse Transformer on the three datasets. For En-De, Transformer-based models outperform the previous methods. Compared with the result of Transformer(Vaswani et al., 2017), Explicit Sparse Transformer reaches 29.4 in BLEU score evaluation, outperforming vanilla Transformer by 0.3 BLEU score. For En-Vi, vanilla Transformer

Table content: <table/>

shows the results of the baseline models and Explicit Sparse Transformer-XL on the test set of enwiki8. Compared with the other strong baselines, Transformer-XL can reach a better performance, and Explicit Sparse Transformer outperforms Transformer-XL with an advantage.

Table content: <table><tr><td>Model</td><td colspan="2">Params BPC</td></tr><tr><td>LN HyperNetworks (Ha et al., 2016)</td><td>27M</td><td>1.34</td></tr><tr><td>LN HM-LSTM (Chung et al., 2016)</td><td>35M</td><td>1.32</td></tr><tr><td>RHN (Zilly et al., 2017)</td><td>46M</td><td>1.27</td></tr><tr><td>Large FS-LSTM-4 (Mujika et al., 2017)</td><td>47M</td><td>1.25</td></tr><tr><td>Large mLSTM (Krause et al., 2016)</td><td>46M</td><td>1.24</td></tr><tr><td>Transformer (Al-Rfou et al., 2018)</td><td>44M</td><td>1.11</td></tr><tr><td>Transformer-XL (Dai et al., 2019)</td><td>41M</td><td>1.06</td></tr><tr><td>Adaptive-span (Sukhbaatar et al., 2019)</td><td>39M</td><td>1.02</td></tr><tr><td>Explicit Sparse Transformer-XL</td><td>41M</td><td>1.05</td></tr></table>

Comparison with state-of-the-art results on enwiki8. Explicit Sparse Transformer-XL refers to the Transformer with our sparsification method.

Table content: <table><tr><td>Method</td><td colspan="4">En-Vi De-En Training Speed (tokens/s) Inference Speed (tokens/s)</td></tr><tr><td>Transformer</td><td colspan="2">30.6 35.3</td><td>49K</td><td>7.0K</td></tr><tr><td>Sparsemax (Martins &amp; Astudillo, 2016)</td><td>-</td><td>31.2</td><td>39K</td><td>3.0K</td></tr><tr><td>Entmax-1.5 (Peters et al., 2019)</td><td colspan="2">30.9 35.6</td><td>40K</td><td>4.9K</td></tr><tr><td>Entmax-alpha (Correia et al., 2019)</td><td>-</td><td>35.5</td><td>13K</td><td>0.6K</td></tr><tr><td>Proposal</td><td colspan="2">31.1 35.6</td><td>48K</td><td>6.6K</td></tr></table>

In the Transformer model, the proposed method, top-k selection before softmax is faster than previous sparse attention methods and is comparable in terms of BLEU scores.

Table content: <table/>

this paper, we propose a novel model called Explicit Sparse Transformer. Explicit Sparse Transformer is able to make the attention in vanilla Transformer more concentrated on the most contributive components. Extensive experiments show that Explicit Sparse Transformer outperforms vanilla Transformer in three different NLP tasks. We conducted a series of qualitative analyses to investigate the reasons why Explicit Sparse Transformer outperforms the vanilla Transformer. Furthermore, we find an obvious problem of the attention at the top layer of the vanilla Transformer, and Explicit Sparse Transformer can alleviate this problem effectively with improved alignment effects. Hongyi Zhang, Yann N. Dauphin, and Tengyu Ma. Fixup initialization: Residual learning without normalization. CoRR, abs/1901.09321, 2019. Julian Georg Zilly, Rupesh Kumar Srivastava, Jan Koutník, and Jürgen Schmidhuber. Recurrent highway networks. In Proceedings of the 34th International Conference on Machine Learning-Volume 70, pp. 4189-4198. JMLR. org, 2017.

Table content: <table/>

th largest value of row i)0 if P ij < t i (k-th largest value of row i)(11)Under review as a conference paper at ICLR 2020The next step after top-k selection is normalization:A = softmax(M(P, k))(12)where A refers to the normalized scores. When backpropagating,∂A ij ∂M kl if P ij ≥ t i (k-th largest value of row i) 0 if P ij < t i (k-th largest value of row i)

Table content: <table><tr><td>∂A ij ∂P kl</td><td>=</td><td>l Q m=1</td><td colspan="2">l K n=1</td><td>∂A ij ∂M mn</td><td>∂M mn ∂P kl</td><td>(13)</td></tr><tr><td/><td>=</td><td colspan="2">∂A ij ∂M kl</td><td colspan="2">∂M kl ∂P kl</td><td/><td>(14)</td></tr><tr><td/><td/><td></td><td/><td/><td/><td/></tr><tr><td/><td>=</td><td></td><td/><td/><td/><td/></tr><tr><td/><td/><td></td><td/><td/><td/><td/></tr></table>

Peer review (iclr2020):
The paper proposes *sparse self-attention*, where only top K activations are kept in the softmax. The resulting transformer model is applied to NMT, image caption generation and language modeling, where it outperformed a vanilla Transformer model. In general, the idea is quite simple and easy to implement. It doesn*t add any computational or memory cost. The paper is well written and easy to read. The diverse experimental results show that it brings an improvement. And I think this can be combined with other improvements of Transformer. However, there are quite many baselines are missing from the tables. The sota on De-En is actually 35.7 by Fonollosa et.al. On enwik8, Transformer XL is not the best medium sized model as the authors claimed. See below: NTM En-De: - Wu et.al. Pay Less Attention with Lightweight and Dynamic Convolutions, 2019 - Ott et.al. Scaling Neural Machine Translation, 2018 NTM En-Vi: - Wang et.al. SwitchOut: an Efficient Data Augmentation Algorithm for Neural Machine Translation, 2018 NTM De-En: - Wu et.al. Pay Less Attention with Lightweight and Dynamic Convolutions, 2019 - Fonollosa et.al. Joint Source-Target Self Attention with Locality Constraints, 2019 - He et.al. Layer-Wise Coordination between Encoder and Decoder for Neural Machine Translation, 2018 LM Enwik8: - Sukhbaatar et.al, Adaptive Attention Span in Transformers, 2019 Other comments: - More experimental details are needed. What is the value K? How different K values affect performance? What is the number of parameters of NMT models. - The claim *top layer of the vanilla Transformer focuses on the end position of the text* can*t be true generally. Probably only true for a certain task. - Where the numbers in Figure 1 come from? Is it a single attention head or average of all? - Page 4, *the high are ...* probably typo? - The related work is missing *Scaling Memory-Augmented Neural Networks with Sparse Reads and Writes* by Rae et.al., which also uses sparse attention.