mike dupont commited on
Commit
16755b1
1 Parent(s): 823d722
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Need-3_1.png ADDED

Git LFS Details

  • SHA256: d67c399967faf6448e7e37e866af591d5cd5e7cafb136bd61e7b0770e2d0da18
  • Pointer size: 131 Bytes
  • Size of remote file: 126 kB
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Need-4_1.png ADDED

Git LFS Details

  • SHA256: b60be39565d5e2a608a795cc8074f09b6a494f15a98af9b915e379f479dc3b76
  • Pointer size: 130 Bytes
  • Size of remote file: 21 kB
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Need-4_2.png ADDED

Git LFS Details

  • SHA256: c44914dba398ba745c40a101b483e48f4f30d263cb241ac819dc34e3bb9f8d73
  • Pointer size: 130 Bytes
  • Size of remote file: 42.1 kB
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Need.html ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Attention is All you Need</title>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6
+ <meta name="generator" content="pdftohtml 0.36"/>
7
+ <meta name="author" content="Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Łukasz Kaiser, Illia Polosukhin"/>
8
+ <meta name="date" content="2024-02-05T09:33:17+00:00"/>
9
+ <meta name="subject" content="Neural Information Processing Systems http://nips.cc/"/>
10
+ </head>
11
+ <frameset cols="100,*">
12
+ <frame name="links" src="Attention is All You Need_ind.html"/>
13
+ <frame name="contents" src="Attention is All You Needs.html"/>
14
+ </frameset>
15
+ </html>
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Need.org ADDED
@@ -0,0 +1,712 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <<1>>Attention Is All You Need\\
2
+ Ashish Vaswani∗\\
3
+ Noam Shazeer∗\\
4
+ Niki Parmar∗\\
5
+ Jakob Uszkoreit∗\\
6
+ Google Brain\\
7
+ Google Brain\\
8
+ Google Research\\
9
+ Google Research\\
10
+ avaswani@google.com\\
11
+ noam@google.com\\
12
+ nikip@google.com\\
13
+ usz@google.com\\
14
+ Llion Jones∗\\
15
+ Aidan N. Gomez∗ †\\
16
+ Łukasz Kaiser∗\\
17
+ Google Research\\
18
+ University of Toronto\\
19
+ Google Brain\\
20
+ llion@google.com\\
21
+ aidan@cs.toronto.edu\\
22
+ lukaszkaiser@google.com\\
23
+ Illia Polosukhin∗ ‡\\
24
+ illia.polosukhin@gmail.com\\
25
+ Abstract\\
26
+ The dominant sequence transduction models are based on complex recurrent or\\
27
+ convolutional neural networks that include an encoder and a decoder. The best\\
28
+ performing models also connect the encoder and decoder through an attention\\
29
+ mechanism. We propose a new simple network architecture, the Transformer,\\
30
+ based solely on attention mechanisms, dispensing with recurrence and convolutions\\
31
+ entirely. Experiments on two machine translation tasks show these models to\\
32
+ be superior in quality while being more parallelizable and requiring significantly\\
33
+ less time to train. Our model achieves 28.4 BLEU on the WMT 2014 English-\\
34
+ to-German translation task, improving over the existing best results, including\\
35
+ ensembles, by over 2 BLEU. On the WMT 2014 English-to-French translation task,\\
36
+ our model establishes a new single-model state-of-the-art BLEU score of 41.0 after\\
37
+ training for 3.5 days on eight GPUs, a small fraction of the training costs of the\\
38
+ best models from the literature.\\
39
+ 1\\
40
+ Introduction\\
41
+ Recurrent neural networks, long short-term memory [[][[12] ]]and gated recurrent [[][[7] ]]neural networks\\
42
+ in particular, have been firmly established as state of the art approaches in sequence modeling and\\
43
+ transduction problems such as language modeling and machine translation [[][[29, 2, 5]. ]]Numerous\\
44
+ efforts have since continued to push the boundaries of recurrent language models and encoder-decoder\\
45
+ architectures [[][[31, 21, 13].]]\\
46
+ ∗Equal contribution. Listing order is random. Jakob proposed replacing RNNs with self-attention and started\\
47
+ the effort to evaluate this idea. Ashish, with Illia, designed and implemented the first Transformer models and\\
48
+ has been crucially involved in every aspect of this work. Noam proposed scaled dot-product attention, multi-head\\
49
+ attention and the parameter-free position representation and became the other person involved in nearly every\\
50
+ detail. Niki designed, implemented, tuned and evaluated countless model variants in our original codebase and\\
51
+ tensor2tensor. Llion also experimented with novel model variants, was responsible for our initial codebase, and\\
52
+ efficient inference and visualizations. Lukasz and Aidan spent countless long days designing various parts of and\\
53
+ implementing tensor2tensor, replacing our earlier codebase, greatly improving results and massively accelerating\\
54
+ our research.\\
55
+ †Work performed while at Google Brain.\\
56
+ ‡Work performed while at Google Research.\\
57
+ 31st Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA.\\
58
+
59
+ --------------
60
+
61
+ <<2>>Recurrent models typically factor computation along the symbol positions of the input and output\\
62
+ sequences. Aligning the positions to steps in computation time, they generate a sequence of hidden\\
63
+ states ht, as a function of the previous hidden state ht−1 and the input for position t. This inherently\\
64
+ sequential nature precludes parallelization within training examples, which becomes critical at longer\\
65
+ sequence lengths, as memory constraints limit batching across examples. Recent work has achieved\\
66
+ significant improvements in computational efficiency through factorization tricks [[][[18] ]]and conditional\\
67
+ computation [[][[26], ]]while also improving model performance in case of the latter. The fundamental\\
68
+ constraint of sequential computation, however, remains.\\
69
+ Attention mechanisms have become an integral part of compelling sequence modeling and transduc-\\
70
+ tion models in various tasks, allowing modeling of dependencies without regard to their distance in\\
71
+ the input or output sequences [[][[2, 16]. ]]In all but a few cases [[][[22], ]]however, such attention mechanisms\\
72
+ are used in conjunction with a recurrent network.\\
73
+ In this work we propose the Transformer, a model architecture eschewing recurrence and instead\\
74
+ relying entirely on an attention mechanism to draw global dependencies between input and output.\\
75
+ The Transformer allows for significantly more parallelization and can reach a new state of the art in\\
76
+ translation quality after being trained for as little as twelve hours on eight P100 GPUs.\\
77
+ 2\\
78
+ Background\\
79
+ The goal of reducing sequential computation also forms the foundation of the Extended Neural GPU\\
80
+ [[][[20], ]]ByteNet [[][[15] ]]and ConvS2S [[][[8], ]]all of which use convolutional neural networks as basic building\\
81
+ block, computing hidden representations in parallel for all input and output positions. In these models,\\
82
+ the number of operations required to relate signals from two arbitrary input or output positions grows\\
83
+ in the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes\\
84
+ it more difficult to learn dependencies between distant positions [[][[11]. ]]In the Transformer this is\\
85
+ reduced to a constant number of operations, albeit at the cost of reduced effective resolution due\\
86
+ to averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as\\
87
+ described in section [[][3.2.]]\\
88
+ Self-attention, sometimes called intra-attention is an attention mechanism relating different positions\\
89
+ of a single sequence in order to compute a representation of the sequence. Self-attention has been\\
90
+ used successfully in a variety of tasks including reading comprehension, abstractive summarization,\\
91
+ textual entailment and learning task-independent sentence representations [[][[4, 22, 23, 19].]]\\
92
+ End-to-end memory networks are based on a recurrent attention mechanism instead of sequence-\\
93
+ aligned recurrence and have been shown to perform well on simple-language question answering and\\
94
+ language modeling tasks [[][[28].]]\\
95
+ To the best of our knowledge, however, the Transformer is the first transduction model relying\\
96
+ entirely on self-attention to compute representations of its input and output without using sequence-\\
97
+ aligned RNNs or convolution. In the following sections, we will describe the Transformer, motivate\\
98
+ self-attention and discuss its advantages over models such as [[][[14, 15] ]]and [[][[8].]]\\
99
+ 3\\
100
+ Model Architecture\\
101
+ Most competitive neural sequence transduction models have an encoder-decoder structure [[][[5, 2, 29].\\
102
+ ]]Here, the encoder maps an input sequence of symbol representations (x1, ..., xn) to a sequence\\
103
+ of continuous representations z = (z1, ..., zn). Given z, the decoder then generates an output\\
104
+ sequence (y1, ..., ym) of symbols one element at a time. At each step the model is auto-regressive\\
105
+ [[][[9], ]]consuming the previously generated symbols as additional input when generating the next.\\
106
+ The Transformer follows this overall architecture using stacked self-attention and point-wise, fully\\
107
+ connected layers for both the encoder and decoder, shown in the left and right halves of Figure [[][1,\\
108
+ ]]respectively.\\
109
+ 3.1\\
110
+ Encoder and Decoder Stacks\\
111
+ Encoder:\\
112
+ The encoder is composed of a stack of N = 6 identical layers. Each layer has two\\
113
+ sub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, position-\\
114
+ 2\\
115
+
116
+ --------------
117
+
118
+ <<3>>[[file:Attention%20is%20All%20You%20Need-3_1.png]]\\
119
+ Figure 1: The Transformer - model architecture.\\
120
+ wise fully connected feed-forward network. We employ a residual connection [[][[10] ]]around each of\\
121
+ the two sub-layers, followed by layer normalization [[][[1]. ]]That is, the output of each sub-layer is\\
122
+ LayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer\\
123
+ itself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding\\
124
+ layers, produce outputs of dimension dmodel = 512.\\
125
+ Decoder:\\
126
+ The decoder is also composed of a stack of N = 6 identical layers. In addition to the two\\
127
+ sub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head\\
128
+ attention over the output of the encoder stack. Similar to the encoder, we employ residual connections\\
129
+ around each of the sub-layers, followed by layer normalization. We also modify the self-attention\\
130
+ sub-layer in the decoder stack to prevent positions from attending to subsequent positions. This\\
131
+ masking, combined with fact that the output embeddings are offset by one position, ensures that the\\
132
+ predictions for position i can depend only on the known outputs at positions less than i.\\
133
+ 3.2\\
134
+ Attention\\
135
+ An attention function can be described as mapping a query and a set of key-value pairs to an output,\\
136
+ where the query, keys, values, and output are all vectors. The output is computed as a weighted sum\\
137
+ of the values, where the weight assigned to each value is computed by a compatibility function of the\\
138
+ query with the corresponding key.\\
139
+ 3.2.1\\
140
+ Scaled Dot-Product Attention\\
141
+ We call our particular attention "Scaled Dot-Product Attention" (Figure [[][2). ]]The input consists of\\
142
+ queries and keys of dimension dk, and values of dimension dv. We compute the dot products of the\\
143
+ 3\\
144
+
145
+ --------------
146
+
147
+ <<4>>[[file:Attention%20is%20All%20You%20Need-4_1.png]]\\
148
+ [[file:Attention%20is%20All%20You%20Need-4_2.png]]\\
149
+ Scaled Dot-Product Attention\\
150
+ Multi-Head Attention\\
151
+ Figure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several\\
152
+ attention layers running in parallel.\\
153
+ √\\
154
+ query with all keys, divide each by\\
155
+ dk, and apply a softmax function to obtain the weights on the\\
156
+ values.\\
157
+ In practice, we compute the attention function on a set of queries simultaneously, packed together\\
158
+ into a matrix Q. The keys and values are also packed together into matrices K and V . We compute\\
159
+ the matrix of outputs as:\\
160
+ QKT\\
161
+ Attention(Q, K, V ) = softmax( √\\
162
+ )V\\
163
+ (1)\\
164
+ dk\\
165
+ The two most commonly used attention functions are additive attention [[][[2], ]]and dot-product (multi-\\
166
+ plicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor\\
167
+ of\\
168
+ 1\\
169
+ √\\
170
+ . Additive attention computes the compatibility function using a feed-forward network with\\
171
+ dk\\
172
+ a single hidden layer. While the two are similar in theoretical complexity, dot-product attention is\\
173
+ much faster and more space-efficient in practice, since it can be implemented using highly optimized\\
174
+ matrix multiplication code.\\
175
+ While for small values of dk the two mechanisms perform similarly, additive attention outperforms\\
176
+ dot product attention without scaling for larger values of dk [[][[3]. ]]We suspect that for large values of\\
177
+ dk, the dot products grow large in magnitude, pushing the softmax function into regions where it has\\
178
+ extremely small gradients [[][4. ]]To counteract this effect, we scale the dot products by\\
179
+ 1\\
180
+ √\\
181
+ .\\
182
+ dk\\
183
+ 3.2.2\\
184
+ Multi-Head Attention\\
185
+ Instead of performing a single attention function with dmodel-dimensional keys, values and queries,\\
186
+ we found it beneficial to linearly project the queries, keys and values h times with different, learned\\
187
+ linear projections to dk, dk and dv dimensions, respectively. On each of these projected versions of\\
188
+ queries, keys and values we then perform the attention function in parallel, yielding dv-dimensional\\
189
+ output values. These are concatenated and once again projected, resulting in the final values, as\\
190
+ depicted in Figure [[][2.]]\\
191
+ Multi-head attention allows the model to jointly attend to information from different representation\\
192
+ subspaces at different positions. With a single attention head, averaging inhibits this.\\
193
+ 4To illustrate why the dot products get large, assume that the components of q and k are independent random\\
194
+ Pd\\
195
+ variables with mean 0 and variance 1. Then their dot product, q\\
196
+ k\\
197
+ · k =\\
198
+ q\\
199
+ i=1 iki, has mean 0 and variance dk .\\
200
+ 4\\
201
+
202
+ --------------
203
+
204
+ <<5>>MultiHead(Q, K, V ) = Concat(head1, ..., headh)W O\\
205
+ where headi = Attention(QW Q, KW K\\
206
+ i\\
207
+ i , V W V\\
208
+ i )\\
209
+ Where the projections are parameter matrices W Q\\
210
+ i\\
211
+ ∈ Rdmodel×dk , W K\\
212
+ i\\
213
+ ∈ Rdmodel×dk , W V\\
214
+ i\\
215
+ ∈ Rdmodel×dv\\
216
+ and W O ∈ Rhdv×dmodel.\\
217
+ In this work we employ h = 8 parallel attention layers, or heads. For each of these we use\\
218
+ dk = dv = dmodel/h = 64. Due to the reduced dimension of each head, the total computational cost\\
219
+ is similar to that of single-head attention with full dimensionality.\\
220
+ 3.2.3\\
221
+ Applications of Attention in our Model\\
222
+ The Transformer uses multi-head attention in three different ways:\\
223
+ • In "encoder-decoder attention" layers, the queries come from the previous decoder layer,\\
224
+ and the memory keys and values come from the output of the encoder. This allows every\\
225
+ position in the decoder to attend over all positions in the input sequence. This mimics the\\
226
+ typical encoder-decoder attention mechanisms in sequence-to-sequence models such as\\
227
+ [[][[31, 2, 8].]]\\
228
+ • The encoder contains self-attention layers. In a self-attention layer all of the keys, values\\
229
+ and queries come from the same place, in this case, the output of the previous layer in the\\
230
+ encoder. Each position in the encoder can attend to all positions in the previous layer of the\\
231
+ encoder.\\
232
+ • Similarly, self-attention layers in the decoder allow each position in the decoder to attend to\\
233
+ all positions in the decoder up to and including that position. We need to prevent leftward\\
234
+ information flow in the decoder to preserve the auto-regressive property. We implement this\\
235
+ inside of scaled dot-product attention by masking out (setting to −∞) all values in the input\\
236
+ of the softmax which correspond to illegal connections. See Figure [[][2.]]\\
237
+ 3.3\\
238
+ Position-wise Feed-Forward Networks\\
239
+ In addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully\\
240
+ connected feed-forward network, which is applied to each position separately and identically. This\\
241
+ consists of two linear transformations with a ReLU activation in between.\\
242
+ FFN(x) = max(0, xW1 + b1)W2 + b2\\
243
+ (2)\\
244
+ While the linear transformations are the same across different positions, they use different parameters\\
245
+ from layer to layer. Another way of describing this is as two convolutions with kernel size 1.\\
246
+ The dimensionality of input and output is dmodel = 512, and the inner-layer has dimensionality\\
247
+ dff = 2048.\\
248
+ 3.4\\
249
+ Embeddings and Softmax\\
250
+ Similarly to other sequence transduction models, we use learned embeddings to convert the input\\
251
+ tokens and output tokens to vectors of dimension dmodel. We also use the usual learned linear transfor-\\
252
+ mation and softmax function to convert the decoder output to predicted next-token probabilities. In\\
253
+ our model, we share the same weight matrix between the two embedding layers and the pre-softmax\\
254
+ √\\
255
+ linear transformation, similar to [[][[24]. ]]In the embedding layers, we multiply those weights by\\
256
+ dmodel.\\
257
+ 3.5\\
258
+ Positional Encoding\\
259
+ Since our model contains no recurrence and no convolution, in order for the model to make use of the\\
260
+ order of the sequence, we must inject some information about the relative or absolute position of the\\
261
+ tokens in the sequence. To this end, we add "positional encodings" to the input embeddings at the\\
262
+ 5\\
263
+
264
+ --------------
265
+
266
+ <<6>>Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations\\
267
+ for different layer types. n is the sequence length, d is the representation dimension, k is the kernel\\
268
+ size of convolutions and r the size of the neighborhood in restricted self-attention.\\
269
+ Layer Type\\
270
+ Complexity per Layer\\
271
+ Sequential\\
272
+ Maximum Path Length\\
273
+ Operations\\
274
+ Self-Attention\\
275
+ O(n2 · d)\\
276
+ O(1)\\
277
+ O(1)\\
278
+ Recurrent\\
279
+ O(n · d2)\\
280
+ O(n)\\
281
+ O(n)\\
282
+ Convolutional\\
283
+ O(k · n · d2)\\
284
+ O(1)\\
285
+ O(logk(n))\\
286
+ Self-Attention (restricted)\\
287
+ O(r · n · d)\\
288
+ O(1)\\
289
+ O(n/r)\\
290
+ bottoms of the encoder and decoder stacks. The positional encodings have the same dimension dmodel\\
291
+ as the embeddings, so that the two can be summed. There are many choices of positional encodings,\\
292
+ learned and fixed [[][[8].]]\\
293
+ In this work, we use sine and cosine functions of different frequencies:\\
294
+ P E(pos,2i) = sin(pos/100002i/dmodel)\\
295
+ P E(pos,2i+1) = cos(pos/100002i/dmodel)\\
296
+ where pos is the position and i is the dimension. That is, each dimension of the positional encoding\\
297
+ corresponds to a sinusoid. The wavelengths form a geometric progression from 2π to 10000 · 2π. We\\
298
+ chose this function because we hypothesized it would allow the model to easily learn to attend by\\
299
+ relative positions, since for any fixed offset k, P Epos+k can be represented as a linear function of\\
300
+ P Epos.\\
301
+ We also experimented with using learned positional embeddings [[][[8] ]]instead, and found that the two\\
302
+ versions produced nearly identical results (see Table [[][3 ]]row (E)). We chose the sinusoidal version\\
303
+ because it may allow the model to extrapolate to sequence lengths longer than the ones encountered\\
304
+ during training.\\
305
+ 4\\
306
+ Why Self-Attention\\
307
+ In this section we compare various aspects of self-attention layers to the recurrent and convolu-\\
308
+ tional layers commonly used for mapping one variable-length sequence of symbol representations\\
309
+ (x1, ..., xn) to another sequence of equal length (z1, ..., zn), with xi, zi ∈ Rd, such as a hidden\\
310
+ layer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we\\
311
+ consider three desiderata.\\
312
+ One is the total computational complexity per layer. Another is the amount of computation that can\\
313
+ be parallelized, as measured by the minimum number of sequential operations required.\\
314
+ The third is the path length between long-range dependencies in the network. Learning long-range\\
315
+ dependencies is a key challenge in many sequence transduction tasks. One key factor affecting the\\
316
+ ability to learn such dependencies is the length of the paths forward and backward signals have to\\
317
+ traverse in the network. The shorter these paths between any combination of positions in the input\\
318
+ and output sequences, the easier it is to learn long-range dependencies [[][[11]. ]]Hence we also compare\\
319
+ the maximum path length between any two input and output positions in networks composed of the\\
320
+ different layer types.\\
321
+ As noted in Table [[][1, ]]a self-attention layer connects all positions with a constant number of sequentially\\
322
+ executed operations, whereas a recurrent layer requires O(n) sequential operations. In terms of\\
323
+ computational complexity, self-attention layers are faster than recurrent layers when the sequence\\
324
+ length n is smaller than the representation dimensionality d, which is most often the case with\\
325
+ sentence representations used by state-of-the-art models in machine translations, such as word-piece\\
326
+ [[][[31] ]]and byte-pair [[][[25] ]]representations. To improve computational performance for tasks involving\\
327
+ very long sequences, self-attention could be restricted to considering only a neighborhood of size r in\\
328
+ 6\\
329
+
330
+ --------------
331
+
332
+ <<7>>the input sequence centered around the respective output position. This would increase the maximum\\
333
+ path length to O(n/r). We plan to investigate this approach further in future work.\\
334
+ A single convolutional layer with kernel width k < n does not connect all pairs of input and output\\
335
+ positions. Doing so requires a stack of O(n/k) convolutional layers in the case of contiguous kernels,\\
336
+ or O(logk(n)) in the case of dilated convolutions [[][[15], ]]increasing the length of the longest paths\\
337
+ between any two positions in the network. Convolutional layers are generally more expensive than\\
338
+ recurrent layers, by a factor of k. Separable convolutions [[][[6], ]]however, decrease the complexity\\
339
+ considerably, to O(k · n · d + n · d2). Even with k = n, however, the complexity of a separable\\
340
+ convolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer,\\
341
+ the approach we take in our model.\\
342
+ As side benefit, self-attention could yield more interpretable models. We inspect attention distributions\\
343
+ from our models and present and discuss examples in the appendix. Not only do individual attention\\
344
+ heads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic\\
345
+ and semantic structure of the sentences.\\
346
+ 5\\
347
+ Training\\
348
+ This section describes the training regime for our models.\\
349
+ 5.1\\
350
+ Training Data and Batching\\
351
+ We trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million\\
352
+ sentence pairs. Sentences were encoded using byte-pair encoding [[][[3], ]]which has a shared source-\\
353
+ target vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT\\
354
+ 2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece\\
355
+ vocabulary [[][[31]. ]]Sentence pairs were batched together by approximate sequence length. Each training\\
356
+ batch contained a set of sentence pairs containing approximately 25000 source tokens and 25000\\
357
+ target tokens.\\
358
+ 5.2\\
359
+ Hardware and Schedule\\
360
+ We trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using\\
361
+ the hyperparameters described throughout the paper, each training step took about 0.4 seconds. We\\
362
+ trained the base models for a total of 100,000 steps or 12 hours. For our big models,(described on the\\
363
+ bottom line of table [[][3), ]]step time was 1.0 seconds. The big models were trained for 300,000 steps\\
364
+ (3.5 days).\\
365
+ 5.3\\
366
+ Optimizer\\
367
+ We used the Adam optimizer [[][[17] ]]with β1 = 0.9, β2 = 0.98 and ǫ = 10−9. We varied the learning\\
368
+ rate over the course of training, according to the formula:\\
369
+ lrate = d−0.5\\
370
+ model · min(step_num−0.5, step_num · warmup_steps−1.5)\\
371
+ (3)\\
372
+ This corresponds to increasing the learning rate linearly for the first warmup_steps training steps,\\
373
+ and decreasing it thereafter proportionally to the inverse square root of the step number. We used\\
374
+ warmup_steps = 4000.\\
375
+ 5.4\\
376
+ Regularization\\
377
+ We employ three types of regularization during training:\\
378
+ Residual Dropout\\
379
+ We apply dropout [[][[27] ]]to the output of each sub-layer, before it is added to the\\
380
+ sub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the\\
381
+ positional encodings in both the encoder and decoder stacks. For the base model, we use a rate of\\
382
+ Pdrop = 0.1.\\
383
+ 7\\
384
+
385
+ --------------
386
+
387
+ <<8>>Table 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the\\
388
+ English-to-German and English-to-French newstest2014 tests at a fraction of the training cost.\\
389
+ BLEU\\
390
+ Training Cost (FLOPs)\\
391
+ Model\\
392
+ EN-DE\\
393
+ EN-FR\\
394
+ EN-DE\\
395
+ EN-FR\\
396
+ ByteNet [[][[15]]]\\
397
+ 23.75\\
398
+ Deep-Att + PosUnk [[][[32]]]\\
399
+ 39.2\\
400
+ 1.0 · 1020\\
401
+ GNMT + RL [[][[31]]]\\
402
+ 24.6\\
403
+ 39.92\\
404
+ 2.3 · 1019\\
405
+ 1.4 · 1020\\
406
+ ConvS2S [[][[8]]]\\
407
+ 25.16\\
408
+ 40.46\\
409
+ 9.6 · 1018\\
410
+ 1.5 · 1020\\
411
+ MoE [[][[26]]]\\
412
+ 26.03\\
413
+ 40.56\\
414
+ 2.0 · 1019\\
415
+ 1.2 · 1020\\
416
+ Deep-Att + PosUnk Ensemble [[][[32]]]\\
417
+ 40.4\\
418
+ 8.0 · 1020\\
419
+ GNMT + RL Ensemble [[][[31]]]\\
420
+ 26.30\\
421
+ 41.16\\
422
+ 1.8 · 1020\\
423
+ 1.1 · 1021\\
424
+ ConvS2S Ensemble [[][[8]]]\\
425
+ 26.36\\
426
+ 41.29\\
427
+ 7.7 · 1019\\
428
+ 1.2 · 1021\\
429
+ Transformer (base model)\\
430
+ 27.3\\
431
+ 38.1\\
432
+ 3 3\\
433
+ .\\
434
+ · 1018\\
435
+ Transformer (big)\\
436
+ 28.4\\
437
+ 41.0\\
438
+ 2.3 · 1019\\
439
+ Label Smoothing\\
440
+ During training, we employed label smoothing of value ǫls = 0.1 [[][[30]. ]]This\\
441
+ hurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.\\
442
+ 6\\
443
+ Results\\
444
+ 6.1\\
445
+ Machine Translation\\
446
+ On the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big)\\
447
+ in Table [[][2) ]]outperforms the best previously reported models (including ensembles) by more than 2.0\\
448
+ BLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is\\
449
+ listed in the bottom line of Table [[][3. ]]Training took 3.5 days on 8 P100 GPUs. Even our base model\\
450
+ surpasses all previously published models and ensembles, at a fraction of the training cost of any of\\
451
+ the competitive models.\\
452
+ On the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0,\\
453
+ outperforming all of the previously published single models, at less than 1/4 the training cost of the\\
454
+ previous state-of-the-art model. The Transformer (big) model trained for English-to-French used\\
455
+ dropout rate Pdrop = 0.1, instead of 0.3.\\
456
+ For the base models, we used a single model obtained by averaging the last 5 checkpoints, which\\
457
+ were written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We\\
458
+ used beam search with a beam size of 4 and length penalty α = 0.6 [[][[31]. ]]These hyperparameters\\
459
+ were chosen after experimentation on the development set. We set the maximum output length during\\
460
+ inference to input length + 50, but terminate early when possible [[][[31].]]\\
461
+ Table [[][2 ]]summarizes our results and compares our translation quality and training costs to other model\\
462
+ architectures from the literature. We estimate the number of floating point operations used to train a\\
463
+ model by multiplying the training time, the number of GPUs used, and an estimate of the sustained\\
464
+ single-precision floating-point capacity of each GPU [[][5.]]\\
465
+ 6.2\\
466
+ Model Variations\\
467
+ To evaluate the importance of different components of the Transformer, we varied our base model\\
468
+ in different ways, measuring the change in performance on English-to-German translation on the\\
469
+ development set, newstest2013. We used beam search as described in the previous section, but no\\
470
+ checkpoint averaging. We present these results in Table [[][3.]]\\
471
+ In Table [[][3 ]]rows (A), we vary the number of attention heads and the attention key and value dimensions,\\
472
+ keeping the amount of computation constant, as described in Section [[][3.2.2. ]]While single-head\\
473
+ attention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.\\
474
+ 5We used values of 2.8, 3.7, 6.0 and 9.5 TFLOPS for K80, K40, M40 and P100, respectively.\\
475
+ 8\\
476
+
477
+ --------------
478
+
479
+ <<9>>Table 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base\\
480
+ model. All metrics are on the English-to-German translation development set, newstest2013. Listed\\
481
+ perplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to\\
482
+ per-word perplexities.\\
483
+ train\\
484
+ PPL\\
485
+ BLEU\\
486
+ params\\
487
+ N\\
488
+ dmodel\\
489
+ dff\\
490
+ h\\
491
+ dk\\
492
+ dv\\
493
+ Pdrop\\
494
+ ǫls\\
495
+ steps\\
496
+ (dev)\\
497
+ (dev)\\
498
+ ×106\\
499
+ base\\
500
+ 6\\
501
+ 512\\
502
+ 2048\\
503
+ 8\\
504
+ 64\\
505
+ 64\\
506
+ 0.1\\
507
+ 0.1\\
508
+ 100K\\
509
+ 4.92\\
510
+ 25.8\\
511
+ 65\\
512
+ 1\\
513
+ 512\\
514
+ 512\\
515
+ 5.29\\
516
+ 24.9\\
517
+ 4\\
518
+ 128\\
519
+ 128\\
520
+ 5.00\\
521
+ 25.5\\
522
+ (A)\\
523
+ 16\\
524
+ 32\\
525
+ 32\\
526
+ 4.91\\
527
+ 25.8\\
528
+ 32\\
529
+ 16\\
530
+ 16\\
531
+ 5.01\\
532
+ 25.4\\
533
+ 16\\
534
+ 5.16\\
535
+ 25.1\\
536
+ 58\\
537
+ (B)\\
538
+ 32\\
539
+ 5.01\\
540
+ 25.4\\
541
+ 60\\
542
+ 2\\
543
+ 6.11\\
544
+ 23.7\\
545
+ 36\\
546
+ 4\\
547
+ 5.19\\
548
+ 25.3\\
549
+ 50\\
550
+ 8\\
551
+ 4.88\\
552
+ 25.5\\
553
+ 80\\
554
+ (C)\\
555
+ 256\\
556
+ 32\\
557
+ 32\\
558
+ 5.75\\
559
+ 24.5\\
560
+ 28\\
561
+ 1024\\
562
+ 128\\
563
+ 128\\
564
+ 4.66\\
565
+ 26.0\\
566
+ 168\\
567
+ 1024\\
568
+ 5.12\\
569
+ 25.4\\
570
+ 53\\
571
+ 4096\\
572
+ 4.75\\
573
+ 26.2\\
574
+ 90\\
575
+ 0.0\\
576
+ 5.77\\
577
+ 24.6\\
578
+ 0.2\\
579
+ 4.95\\
580
+ 25.5\\
581
+ (D)\\
582
+ 0.0\\
583
+ 4.67\\
584
+ 25.3\\
585
+ 0.2\\
586
+ 5.47\\
587
+ 25.7\\
588
+ (E)\\
589
+ positional embedding instead of sinusoids\\
590
+ 4.92\\
591
+ 25.7\\
592
+ big\\
593
+ 6\\
594
+ 1024\\
595
+ 4096\\
596
+ 16\\
597
+ 0.3\\
598
+ 300K\\
599
+ 4.33\\
600
+ 26.4\\
601
+ 213\\
602
+ In Table [[][3 ]]rows (B), we observe that reducing the attention key size dk hurts model quality. This\\
603
+ suggests that determining compatibility is not easy and that a more sophisticated compatibility\\
604
+ function than dot product may be beneficial. We further observe in rows (C) and (D) that, as expected,\\
605
+ bigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our\\
606
+ sinusoidal positional encoding with learned positional embeddings [[][[8], ]]and observe nearly identical\\
607
+ results to the base model.\\
608
+ 7\\
609
+ Conclusion\\
610
+ In this work, we presented the Transformer, the first sequence transduction model based entirely on\\
611
+ attention, replacing the recurrent layers most commonly used in encoder-decoder architectures with\\
612
+ multi-headed self-attention.\\
613
+ For translation tasks, the Transformer can be trained significantly faster than architectures based\\
614
+ on recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014\\
615
+ English-to-French translation tasks, we achieve a new state of the art. In the former task our best\\
616
+ model outperforms even all previously reported ensembles.\\
617
+ We are excited about the future of attention-based models and plan to apply them to other tasks. We\\
618
+ plan to extend the Transformer to problems involving input and output modalities other than text and\\
619
+ to investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs\\
620
+ such as images, audio and video. Making generation less sequential is another research goals of ours.\\
621
+ The code we used to train and evaluate our models is available at [[https://github.com/tensorflow/tensor2tensor][https://github.com/]]\\
622
+ [[https://github.com/tensorflow/tensor2tensor][tensorflow/tensor2tensor.]]\\
623
+ Acknowledgements\\
624
+ We are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful\\
625
+ comments, corrections and inspiration.\\
626
+ 9\\
627
+
628
+ --------------
629
+
630
+ <<10>>References\\
631
+ [1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. Layer normalization. /arXiv preprint/\\
632
+ /arXiv:1607.06450/, 2016.\\
633
+ [2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. Neural machine translation by jointly\\
634
+ learning to align and translate. /CoRR/, abs/1409.0473, 2014.\\
635
+ [3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. Massive exploration of neural\\
636
+ machine translation architectures. /CoRR/, abs/1703.03906, 2017.\\
637
+ [4] Jianpeng Cheng, Li Dong, and Mirella Lapata. Long short-term memory-networks for machine\\
638
+ reading. /arXiv preprint arXiv:1601.06733/, 2016.\\
639
+ [5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk,\\
640
+ and Yoshua Bengio. Learning phrase representations using rnn encoder-decoder for statistical\\
641
+ machine translation. /CoRR/, abs/1406.1078, 2014.\\
642
+ [6] Francois Chollet. Xception: Deep learning with depthwise separable convolutions. /arXiv/\\
643
+ /preprint arXiv:1610.02357/, 2016.\\
644
+ [7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. Empirical evaluation\\
645
+ of gated recurrent neural networks on sequence modeling. /CoRR/, abs/1412.3555, 2014.\\
646
+ [8] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. Convolu-\\
647
+ tional sequence to sequence learning. /arXiv preprint arXiv:1705.03122v2/, 2017.\\
648
+ [9] Alex Graves.\\
649
+ Generating sequences with recurrent neural networks.\\
650
+ /arXiv preprint/\\
651
+ /arXiv:1308.0850/, 2013.\\
652
+ [10] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for im-\\
653
+ age recognition. In /Proceedings of the IEEE Conference on Computer Vision and Pattern/\\
654
+ /Recognition/, pages 770--778, 2016.\\
655
+ [11] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. Gradient flow in\\
656
+ recurrent nets: the difficulty of learning long-term dependencies, 2001.\\
657
+ [12] Sepp Hochreiter and Jürgen Schmidhuber. Long short-term memory. /Neural computation/,\\
658
+ 9(8):1735--1780, 1997.\\
659
+ [13] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. Exploring\\
660
+ the limits of language modeling. /arXiv preprint arXiv:1602.02410/, 2016.\\
661
+ [14] Łukasz Kaiser and Ilya Sutskever. Neural GPUs learn algorithms. In /International Conference/\\
662
+ /on Learning Representations (ICLR)/, 2016.\\
663
+ [15] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Ko-\\
664
+ ray Kavukcuoglu. Neural machine translation in linear time. /arXiv preprint arXiv:1610.10099v2/,\\
665
+ 2017.\\
666
+ [16] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. Structured attention networks.\\
667
+ In /International Conference on Learning Representations/, 2017.\\
668
+ [17] Diederik Kingma and Jimmy Ba. Adam: A method for stochastic optimization. In /ICLR/, 2015.\\
669
+ [18] Oleksii Kuchaiev and Boris Ginsburg. Factorization tricks for LSTM networks. /arXiv preprint/\\
670
+ /arXiv:1703.10722/, 2017.\\
671
+ [19] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen\\
672
+ Zhou, and Yoshua Bengio. A structured self-attentive sentence embedding. /arXiv preprint\\
673
+ arXiv:1703.03130/, 2017.\\
674
+ [20] Samy Bengio Łukasz Kaiser. Can active memory replace attention? In /Advances in Neural/\\
675
+ /Information Processing Systems, (NIPS)/, 2016.\\
676
+ 10\\
677
+
678
+ --------------
679
+
680
+ <<11>>[21] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. Effective approaches to attention-\\
681
+ based neural machine translation. /arXiv preprint arXiv:1508.04025/, 2015.\\
682
+ [22] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. A decomposable attention\\
683
+ model. In /Empirical Methods in Natural Language Processing/, 2016.\\
684
+ [23] Romain Paulus, Caiming Xiong, and Richard Socher. A deep reinforced model for abstractive\\
685
+ summarization. /arXiv preprint arXiv:1705.04304/, 2017.\\
686
+ [24] Ofir Press and Lior Wolf. Using the output embedding to improve language models. /arXiv/\\
687
+ /preprint arXiv:1608.05859/, 2016.\\
688
+ [25] Rico Sennrich, Barry Haddow, and Alexandra Birch. Neural machine translation of rare words\\
689
+ with subword units. /arXiv preprint arXiv:1508.07909/, 2015.\\
690
+ [26] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton,\\
691
+ and Jeff Dean. Outrageously large neural networks: The sparsely-gated mixture-of-experts\\
692
+ layer. /arXiv preprint arXiv:1701.06538/, 2017.\\
693
+ [27] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdi-\\
694
+ nov. Dropout: a simple way to prevent neural networks from overfitting. /Journal of Machine/\\
695
+ /Learning Research/, 15(1):1929--1958, 2014.\\
696
+ [28] Sainbayar Sukhbaatar, arthur szlam, Jason Weston, and Rob Fergus. End-to-end memory\\
697
+ networks. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors,\\
698
+ /Advances in Neural Information Processing Systems 28/, pages 2440--2448. Curran Associates,\\
699
+ Inc., 2015.\\
700
+ [29] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. Sequence to sequence learning with neural\\
701
+ networks. In /Advances in Neural Information Processing Systems/, pages 3104--3112, 2014.\\
702
+ [30] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna.\\
703
+ Rethinking the inception architecture for computer vision. /CoRR/, abs/1512.00567, 2015.\\
704
+ [31] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang\\
705
+ Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. Google's neural machine\\
706
+ translation system: Bridging the gap between human and machine translation. /arXiv preprint\\
707
+ arXiv:1609.08144/, 2016.\\
708
+ [32] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. Deep recurrent models with\\
709
+ fast-forward connections for neural machine translation. /CoRR/, abs/1606.04199, 2016.\\
710
+ 11\\
711
+
712
+ --------------
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Need.pdf ADDED
Binary file (404 kB). View file
 
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Need_ind.html ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
2
+ <head>
3
+ <title></title>
4
+ </head>
5
+ <body>
6
+ <a href="Attention is All You Needs.html#1" target="contents" >Page 1</a><br/>
7
+ <a href="Attention is All You Needs.html#2" target="contents" >Page 2</a><br/>
8
+ <a href="Attention is All You Needs.html#3" target="contents" >Page 3</a><br/>
9
+ <a href="Attention is All You Needs.html#4" target="contents" >Page 4</a><br/>
10
+ <a href="Attention is All You Needs.html#5" target="contents" >Page 5</a><br/>
11
+ <a href="Attention is All You Needs.html#6" target="contents" >Page 6</a><br/>
12
+ <a href="Attention is All You Needs.html#7" target="contents" >Page 7</a><br/>
13
+ <a href="Attention is All You Needs.html#8" target="contents" >Page 8</a><br/>
14
+ <a href="Attention is All You Needs.html#9" target="contents" >Page 9</a><br/>
15
+ <a href="Attention is All You Needs.html#10" target="contents" >Page 10</a><br/>
16
+ <a href="Attention is All You Needs.html#11" target="contents" >Page 11</a><br/>
17
+ </body>
18
+ </html>
2017/12/04/USA/LongBeachCA/NIPS2017/Attention is All You Needs.html ADDED
@@ -0,0 +1,558 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html><html>
2
+ <head>
3
+ <title></title>
4
+ <style type="text/css">
5
+ <!--
6
+ .xflip {
7
+ -moz-transform: scaleX(-1);
8
+ -webkit-transform: scaleX(-1);
9
+ -o-transform: scaleX(-1);
10
+ transform: scaleX(-1);
11
+ filter: fliph;
12
+ }
13
+ .yflip {
14
+ -moz-transform: scaleY(-1);
15
+ -webkit-transform: scaleY(-1);
16
+ -o-transform: scaleY(-1);
17
+ transform: scaleY(-1);
18
+ filter: flipv;
19
+ }
20
+ .xyflip {
21
+ -moz-transform: scaleX(-1) scaleY(-1);
22
+ -webkit-transform: scaleX(-1) scaleY(-1);
23
+ -o-transform: scaleX(-1) scaleY(-1);
24
+ transform: scaleX(-1) scaleY(-1);
25
+ filter: fliph + flipv;
26
+ }
27
+ -->
28
+ </style>
29
+ </head>
30
+ <body>
31
+ <a name=1></a>Attention&#160;Is&#160;All&#160;You&#160;Need<br/>
32
+ Ashish&#160;Vaswani∗<br/>
33
+ Noam&#160;Shazeer∗<br/>
34
+ Niki&#160;Parmar∗<br/>
35
+ Jakob&#160;Uszkoreit∗<br/>
36
+ Google&#160;Brain<br/>
37
+ Google&#160;Brain<br/>
38
+ Google&#160;Research<br/>
39
+ Google&#160;Research<br/>
40
+ avaswani@google.com<br/>
41
+ noam@google.com<br/>
42
+ nikip@google.com<br/>
43
+ usz@google.com<br/>
44
+ Llion&#160;Jones∗<br/>
45
+ Aidan&#160;N.&#160;Gomez∗&#160;†<br/>
46
+ Łukasz&#160;Kaiser∗<br/>
47
+ Google&#160;Research<br/>
48
+ University&#160;of&#160;Toronto<br/>
49
+ Google&#160;Brain<br/>
50
+ llion@google.com<br/>
51
+ aidan@cs.toronto.edu<br/>
52
+ lukaszkaiser@google.com<br/>
53
+ Illia&#160;Polosukhin∗&#160;‡<br/>
54
+ illia.polosukhin@gmail.com<br/>
55
+ Abstract<br/>
56
+ The&#160;dominant&#160;sequence&#160;transduction&#160;models&#160;are&#160;based&#160;on&#160;complex&#160;recurrent&#160;or<br/>convolutional&#160;neural&#160;networks&#160;that&#160;include&#160;an&#160;encoder&#160;and&#160;a&#160;decoder.&#160;The&#160;best<br/>performing&#160;models&#160;also&#160;connect&#160;the&#160;encoder&#160;and&#160;decoder&#160;through&#160;an&#160;attention<br/>mechanism.&#160;We&#160;propose&#160;a&#160;new&#160;simple&#160;network&#160;architecture,&#160;the&#160;Transformer,<br/>based&#160;solely&#160;on&#160;attention&#160;mechanisms,&#160;dispensing&#160;with&#160;recurrence&#160;and&#160;convolutions<br/>entirely.&#160;Experiments&#160;on&#160;two&#160;machine&#160;translation&#160;tasks&#160;show&#160;these&#160;models&#160;to<br/>be&#160;superior&#160;in&#160;quality&#160;while&#160;being&#160;more&#160;parallelizable&#160;and&#160;requiring&#160;significantly<br/>less&#160;time&#160;to&#160;train.&#160;Our&#160;model&#160;achieves&#160;28.4&#160;BLEU&#160;on&#160;the&#160;WMT&#160;2014&#160;English-<br/>to-German&#160;translation&#160;task,&#160;improving&#160;over&#160;the&#160;existing&#160;best&#160;results,&#160;including<br/>ensembles,&#160;by&#160;over&#160;2&#160;BLEU.&#160;On&#160;the&#160;WMT&#160;2014&#160;English-to-French&#160;translation&#160;task,<br/>our&#160;model&#160;establishes&#160;a&#160;new&#160;single-model&#160;state-of-the-art&#160;BLEU&#160;score&#160;of&#160;41.0&#160;after<br/>training&#160;for&#160;3.5&#160;days&#160;on&#160;eight&#160;GPUs,&#160;a&#160;small&#160;fraction&#160;of&#160;the&#160;training&#160;costs&#160;of&#160;the<br/>best&#160;models&#160;from&#160;the&#160;literature.<br/>
57
+ 1<br/>
58
+ Introduction<br/>
59
+ Recurrent&#160;neural&#160;networks,&#160;long&#160;short-term&#160;memory&#160;<a href="">[12]&#160;</a>and&#160;gated&#160;recurrent&#160;<a href="">[7]&#160;</a>neural&#160;networks<br/>in&#160;particular,&#160;have&#160;been&#160;firmly&#160;established&#160;as&#160;state&#160;of&#160;the&#160;art&#160;approaches&#160;in&#160;sequence&#160;modeling&#160;and<br/>transduction&#160;problems&#160;such&#160;as&#160;language&#160;modeling&#160;and&#160;machine&#160;translation&#160;<a href="">[29,&#160;2,&#160;5].&#160;</a>Numerous<br/>efforts&#160;have&#160;since&#160;continued&#160;to&#160;push&#160;the&#160;boundaries&#160;of&#160;recurrent&#160;language&#160;models&#160;and&#160;encoder-decoder<br/>architectures&#160;<a href="">[31,&#160;21,&#160;13].</a><br/>
60
+ ∗Equal&#160;contribution.&#160;Listing&#160;order&#160;is&#160;random.&#160;Jakob&#160;proposed&#160;replacing&#160;RNNs&#160;with&#160;self-attention&#160;and&#160;started<br/>
61
+ the&#160;effort&#160;to&#160;evaluate&#160;this&#160;idea.&#160;Ashish,&#160;with&#160;Illia,&#160;designed&#160;and&#160;implemented&#160;the&#160;first&#160;Transformer&#160;models&#160;and<br/>has&#160;been&#160;crucially&#160;involved&#160;in&#160;every&#160;aspect&#160;of&#160;this&#160;work.&#160;Noam&#160;proposed&#160;scaled&#160;dot-product&#160;attention,&#160;multi-head<br/>attention&#160;and&#160;the&#160;parameter-free&#160;position&#160;representation&#160;and&#160;became&#160;the&#160;other&#160;person&#160;involved&#160;in&#160;nearly&#160;every<br/>detail.&#160;Niki&#160;designed,&#160;implemented,&#160;tuned&#160;and&#160;evaluated&#160;countless&#160;model&#160;variants&#160;in&#160;our&#160;original&#160;codebase&#160;and<br/>tensor2tensor.&#160;Llion&#160;also&#160;experimented&#160;with&#160;novel&#160;model&#160;variants,&#160;was&#160;responsible&#160;for&#160;our&#160;initial&#160;codebase,&#160;and<br/>efficient&#160;inference&#160;and&#160;visualizations.&#160;Lukasz&#160;and&#160;Aidan&#160;spent&#160;countless&#160;long&#160;days&#160;designing&#160;various&#160;parts&#160;of&#160;and<br/>implementing&#160;tensor2tensor,&#160;replacing&#160;our&#160;earlier&#160;codebase,&#160;greatly&#160;improving&#160;results&#160;and&#160;massively&#160;accelerating<br/>our&#160;research.<br/>
62
+ †Work&#160;performed&#160;while&#160;at&#160;Google&#160;Brain.<br/>‡Work&#160;performed&#160;while&#160;at&#160;Google&#160;Research.<br/>
63
+ 31st&#160;Conference&#160;on&#160;Neural&#160;Information&#160;Processing&#160;Systems&#160;(NIPS&#160;2017),&#160;Long&#160;Beach,&#160;CA,&#160;USA.<br/>
64
+ <hr/>
65
+ <a name=2></a>Recurrent&#160;models&#160;typically&#160;factor&#160;computation&#160;along&#160;the&#160;symbol&#160;positions&#160;of&#160;the&#160;input&#160;and&#160;output<br/>sequences.&#160;Aligning&#160;the&#160;positions&#160;to&#160;steps&#160;in&#160;computation&#160;time,&#160;they&#160;generate&#160;a&#160;sequence&#160;of&#160;hidden<br/>states&#160;ht,&#160;as&#160;a&#160;function&#160;of&#160;the&#160;previous&#160;hidden&#160;state&#160;ht−1&#160;and&#160;the&#160;input&#160;for&#160;position&#160;t.&#160;This&#160;inherently<br/>
66
+ sequential&#160;nature&#160;precludes&#160;parallelization&#160;within&#160;training&#160;examples,&#160;which&#160;becomes&#160;critical&#160;at&#160;longer<br/>sequence&#160;lengths,&#160;as&#160;memory&#160;constraints&#160;limit&#160;batching&#160;across&#160;examples.&#160;Recent&#160;work&#160;has&#160;achieved<br/>significant&#160;improvements&#160;in&#160;computational&#160;efficiency&#160;through&#160;factorization&#160;tricks&#160;<a href="">[18]&#160;</a>and&#160;conditional<br/>computation&#160;<a href="">[26],&#160;</a>while&#160;also&#160;improving&#160;model&#160;performance&#160;in&#160;case&#160;of&#160;the&#160;latter.&#160;The&#160;fundamental<br/>constraint&#160;of&#160;sequential&#160;computation,&#160;however,&#160;remains.<br/>
67
+ Attention&#160;mechanisms&#160;have&#160;become&#160;an&#160;integral&#160;part&#160;of&#160;compelling&#160;sequence&#160;modeling&#160;and&#160;transduc-<br/>
68
+ tion&#160;models&#160;in&#160;various&#160;tasks,&#160;allowing&#160;modeling&#160;of&#160;dependencies&#160;without&#160;regard&#160;to&#160;their&#160;distance&#160;in<br/>the&#160;input&#160;or&#160;output&#160;sequences&#160;<a href="">[2,&#160;16].&#160;</a>In&#160;all&#160;but&#160;a&#160;few&#160;cases&#160;<a href="">[22],&#160;</a>however,&#160;such&#160;attention&#160;mechanisms<br/>are&#160;used&#160;in&#160;conjunction&#160;with&#160;a&#160;recurrent&#160;network.<br/>
69
+ In&#160;this&#160;work&#160;we&#160;propose&#160;the&#160;Transformer,&#160;a&#160;model&#160;architecture&#160;eschewing&#160;recurrence&#160;and&#160;instead<br/>relying&#160;entirely&#160;on&#160;an&#160;attention&#160;mechanism&#160;to&#160;draw&#160;global&#160;dependencies&#160;between&#160;input&#160;and&#160;output.<br/>
70
+ The&#160;Transformer&#160;allows&#160;for&#160;significantly&#160;more&#160;parallelization&#160;and&#160;can&#160;reach&#160;a&#160;new&#160;state&#160;of&#160;the&#160;art&#160;in<br/>
71
+ translation&#160;quality&#160;after&#160;being&#160;trained&#160;for&#160;as&#160;little&#160;as&#160;twelve&#160;hours&#160;on&#160;eight&#160;P100&#160;GPUs.<br/>
72
+ 2<br/>
73
+ Background<br/>
74
+ The&#160;goal&#160;of&#160;reducing&#160;sequential&#160;computation&#160;also&#160;forms&#160;the&#160;foundation&#160;of&#160;the&#160;Extended&#160;Neural&#160;GPU<br/>
75
+ <a href="">[20],&#160;</a>ByteNet&#160;<a href="">[15]&#160;</a>and&#160;ConvS2S&#160;<a href="">[8],&#160;</a>all&#160;of&#160;which&#160;use&#160;convolutional&#160;neural&#160;networks&#160;as&#160;basic&#160;building<br/>block,&#160;computing&#160;hidden&#160;representations&#160;in&#160;parallel&#160;for&#160;all&#160;input&#160;and&#160;output&#160;positions.&#160;In&#160;these&#160;models,<br/>the&#160;number&#160;of&#160;operations&#160;required&#160;to&#160;relate&#160;signals&#160;from&#160;two&#160;arbitrary&#160;input&#160;or&#160;output&#160;positions&#160;grows<br/>in&#160;the&#160;distance&#160;between&#160;positions,&#160;linearly&#160;for&#160;ConvS2S&#160;and&#160;logarithmically&#160;for&#160;ByteNet.&#160;This&#160;makes<br/>it&#160;more&#160;difficult&#160;to&#160;learn&#160;dependencies&#160;between&#160;distant&#160;positions&#160;<a href="">[11].&#160;</a>In&#160;the&#160;Transformer&#160;this&#160;is<br/>reduced&#160;to&#160;a&#160;constant&#160;number&#160;of&#160;operations,&#160;albeit&#160;at&#160;the&#160;cost&#160;of&#160;reduced&#160;effective&#160;resolution&#160;due<br/>to&#160;averaging&#160;attention-weighted&#160;positions,&#160;an&#160;effect&#160;we&#160;counteract&#160;with&#160;Multi-Head&#160;Attention&#160;as<br/>described&#160;in&#160;section&#160;<a href="">3.2.</a><br/>
76
+ Self-attention,&#160;sometimes&#160;called&#160;intra-attention&#160;is&#160;an&#160;attention&#160;mechanism&#160;relating&#160;different&#160;positions<br/>of&#160;a&#160;single&#160;sequence&#160;in&#160;order&#160;to&#160;compute&#160;a&#160;representation&#160;of&#160;the&#160;sequence.&#160;Self-attention&#160;has&#160;been<br/>used&#160;successfully&#160;in&#160;a&#160;variety&#160;of&#160;tasks&#160;including&#160;reading&#160;comprehension,&#160;abstractive&#160;summarization,<br/>textual&#160;entailment&#160;and&#160;learning&#160;task-independent&#160;sentence&#160;representations&#160;<a href="">[4,&#160;22,&#160;23,&#160;19].</a><br/>
77
+ End-to-end&#160;memory&#160;networks&#160;are&#160;based&#160;on&#160;a&#160;recurrent&#160;attention&#160;mechanism&#160;instead&#160;of&#160;sequence-<br/>aligned&#160;recurrence&#160;and&#160;have&#160;been&#160;shown&#160;to&#160;perform&#160;well&#160;on&#160;simple-language&#160;question&#160;answering&#160;and<br/>language&#160;modeling&#160;tasks&#160;<a href="">[28].</a><br/>
78
+ To&#160;the&#160;best&#160;of&#160;our&#160;knowledge,&#160;however,&#160;the&#160;Transformer&#160;is&#160;the&#160;first&#160;transduction&#160;model&#160;relying<br/>
79
+ entirely&#160;on&#160;self-attention&#160;to&#160;compute&#160;representations&#160;of&#160;its&#160;input&#160;and&#160;output&#160;without&#160;using&#160;sequence-<br/>aligned&#160;RNNs&#160;or&#160;convolution.&#160;In&#160;the&#160;following&#160;sections,&#160;we&#160;will&#160;describe&#160;the&#160;Transformer,&#160;motivate<br/>self-attention&#160;and&#160;discuss&#160;its&#160;advantages&#160;over&#160;models&#160;such&#160;as&#160;<a href="">[14,&#160;15]&#160;</a>and&#160;<a href="">[8].</a><br/>
80
+ 3<br/>
81
+ Model&#160;Architecture<br/>
82
+ Most&#160;competitive&#160;neural&#160;sequence&#160;transduction&#160;models&#160;have&#160;an&#160;encoder-decoder&#160;structure&#160;<a href="">[5,&#160;2,&#160;29].<br/></a>Here,&#160;the&#160;encoder&#160;maps&#160;an&#160;input&#160;sequence&#160;of&#160;symbol&#160;representations&#160;(x1,&#160;...,&#160;xn)&#160;to&#160;a&#160;sequence<br/>of&#160;continuous&#160;representations&#160;z&#160;=&#160;(z1,&#160;...,&#160;zn).&#160;Given&#160;z,&#160;the&#160;decoder&#160;then&#160;generates&#160;an&#160;output<br/>sequence&#160;(y1,&#160;...,&#160;ym)&#160;of&#160;symbols&#160;one&#160;element&#160;at&#160;a&#160;time.&#160;At&#160;each&#160;step&#160;the&#160;model&#160;is&#160;auto-regressive<br/><a href="">[9],&#160;</a>consuming&#160;the&#160;previously&#160;generated&#160;symbols&#160;as&#160;additional&#160;input&#160;when&#160;generating&#160;the&#160;next.<br/>
83
+ The&#160;Transformer&#160;follows&#160;this&#160;overall&#160;architecture&#160;using&#160;stacked&#160;self-attention&#160;and&#160;point-wise,&#160;fully<br/>
84
+ connected&#160;layers&#160;for&#160;both&#160;the&#160;encoder&#160;and&#160;decoder,&#160;shown&#160;in&#160;the&#160;left&#160;and&#160;right&#160;halves&#160;of&#160;Figure&#160;<a href="">1,<br/></a>respectively.<br/>
85
+ 3.1<br/>
86
+ Encoder&#160;and&#160;Decoder&#160;Stacks<br/>
87
+ Encoder:<br/>
88
+ The&#160;encoder&#160;is&#160;composed&#160;of&#160;a&#160;stack&#160;of&#160;N&#160;=&#160;6&#160;identical&#160;layers.&#160;Each&#160;layer&#160;has&#160;two<br/>
89
+ sub-layers.&#160;The&#160;first&#160;is&#160;a&#160;multi-head&#160;self-attention&#160;mechanism,&#160;and&#160;the&#160;second&#160;is&#160;a&#160;simple,&#160;position-<br/>
90
+ 2<br/>
91
+ <hr/>
92
+ <a name=3></a><img src="Attention is All You Need-3_1.png"/><br/>
93
+ Figure&#160;1:&#160;The&#160;Transformer&#160;-&#160;model&#160;architecture.<br/>
94
+ wise&#160;fully&#160;connected&#160;feed-forward&#160;network.&#160;We&#160;employ&#160;a&#160;residual&#160;connection&#160;<a href="">[10]&#160;</a>around&#160;each&#160;of<br/>
95
+ the&#160;two&#160;sub-layers,&#160;followed&#160;by&#160;layer&#160;normalization&#160;<a href="">[1].&#160;</a>That&#160;is,&#160;the&#160;output&#160;of&#160;each&#160;sub-layer&#160;is<br/>LayerNorm(x&#160;+&#160;Sublayer(x)),&#160;where&#160;Sublayer(x)&#160;is&#160;the&#160;function&#160;implemented&#160;by&#160;the&#160;sub-layer<br/>itself.&#160;To&#160;facilitate&#160;these&#160;residual&#160;connections,&#160;all&#160;sub-layers&#160;in&#160;the&#160;model,&#160;as&#160;well&#160;as&#160;the&#160;embedding<br/>layers,&#160;produce&#160;outputs&#160;of&#160;dimension&#160;dmodel&#160;=&#160;512.<br/>
96
+ Decoder:<br/>
97
+ The&#160;decoder&#160;is&#160;also&#160;composed&#160;of&#160;a&#160;stack&#160;of&#160;N&#160;=&#160;6&#160;identical&#160;layers.&#160;In&#160;addition&#160;to&#160;the&#160;two<br/>
98
+ sub-layers&#160;in&#160;each&#160;encoder&#160;layer,&#160;the&#160;decoder&#160;inserts&#160;a&#160;third&#160;sub-layer,&#160;which&#160;performs&#160;multi-head<br/>attention&#160;over&#160;the&#160;output&#160;of&#160;the&#160;encoder&#160;stack.&#160;Similar&#160;to&#160;the&#160;encoder,&#160;we&#160;employ&#160;residual&#160;connections<br/>around&#160;each&#160;of&#160;the&#160;sub-layers,&#160;followed&#160;by&#160;layer&#160;normalization.&#160;We&#160;also&#160;modify&#160;the&#160;self-attention<br/>sub-layer&#160;in&#160;the&#160;decoder&#160;stack&#160;to&#160;prevent&#160;positions&#160;from&#160;attending&#160;to&#160;subsequent&#160;positions.&#160;This<br/>masking,&#160;combined&#160;with&#160;fact&#160;that&#160;the&#160;output&#160;embeddings&#160;are&#160;offset&#160;by&#160;one&#160;position,&#160;ensures&#160;that&#160;the<br/>predictions&#160;for&#160;position&#160;i&#160;can&#160;depend&#160;only&#160;on&#160;the&#160;known&#160;outputs&#160;at&#160;positions&#160;less&#160;than&#160;i.<br/>
99
+ 3.2<br/>
100
+ Attention<br/>
101
+ An&#160;attention&#160;function&#160;can&#160;be&#160;described&#160;as&#160;mapping&#160;a&#160;query&#160;and&#160;a&#160;set&#160;of&#160;key-value&#160;pairs&#160;to&#160;an&#160;output,<br/>where&#160;the&#160;query,&#160;keys,&#160;values,&#160;and&#160;output&#160;are&#160;all&#160;vectors.&#160;The&#160;output&#160;is&#160;computed&#160;as&#160;a&#160;weighted&#160;sum<br/>
102
+ of&#160;the&#160;values,&#160;where&#160;the&#160;weight&#160;assigned&#160;to&#160;each&#160;value&#160;is&#160;computed&#160;by&#160;a&#160;compatibility&#160;function&#160;of&#160;the<br/>query&#160;with&#160;the&#160;corresponding&#160;key.<br/>
103
+ 3.2.1<br/>
104
+ Scaled&#160;Dot-Product&#160;Attention<br/>
105
+ We&#160;call&#160;our&#160;particular&#160;attention&#160;&#34;Scaled&#160;Dot-Product&#160;Attention&#34;&#160;(Figure&#160;<a href="">2).&#160;</a>The&#160;input&#160;consists&#160;of<br/>
106
+ queries&#160;and&#160;keys&#160;of&#160;dimension&#160;dk,&#160;and&#160;values&#160;of&#160;dimension&#160;dv.&#160;We&#160;compute&#160;the&#160;dot&#160;products&#160;of&#160;the<br/>
107
+ 3<br/>
108
+ <hr/>
109
+ <a name=4></a><img src="Attention is All You Need-4_1.png"/><br/>
110
+ <img src="Attention is All You Need-4_2.png"/><br/>
111
+ Scaled&#160;Dot-Product&#160;Attention<br/>
112
+ Multi-Head&#160;Attention<br/>
113
+ Figure&#160;2:&#160;(left)&#160;Scaled&#160;Dot-Product&#160;Attention.&#160;(right)&#160;Multi-Head&#160;Attention&#160;consists&#160;of&#160;several<br/>attention&#160;layers&#160;running&#160;in&#160;parallel.<br/>
114
+ √<br/>
115
+ query&#160;with&#160;all&#160;keys,&#160;divide&#160;each&#160;by<br/>
116
+ dk,&#160;and&#160;apply&#160;a&#160;softmax&#160;function&#160;to&#160;obtain&#160;the&#160;weights&#160;on&#160;the<br/>
117
+ values.<br/>
118
+ In&#160;practice,&#160;we&#160;compute&#160;the&#160;attention&#160;function&#160;on&#160;a&#160;set&#160;of&#160;queries&#160;simultaneously,&#160;packed&#160;together<br/>into&#160;a&#160;matrix&#160;Q.&#160;The&#160;keys&#160;and&#160;values&#160;are&#160;also&#160;packed&#160;together&#160;into&#160;matrices&#160;K&#160;and&#160;V&#160;.&#160;We&#160;compute<br/>the&#160;matrix&#160;of&#160;outputs&#160;as:<br/>
119
+ QKT<br/>
120
+ Attention(Q,&#160;K,&#160;V&#160;)&#160;=&#160;softmax(&#160;√<br/>
121
+ )V<br/>
122
+ (1)<br/>
123
+ dk<br/>
124
+ The&#160;two&#160;most&#160;commonly&#160;used&#160;attention&#160;functions&#160;are&#160;additive&#160;attention&#160;<a href="">[2],&#160;</a>and&#160;dot-product&#160;(multi-<br/>
125
+ plicative)&#160;attention.&#160;Dot-product&#160;attention&#160;is&#160;identical&#160;to&#160;our&#160;algorithm,&#160;except&#160;for&#160;the&#160;scaling&#160;factor<br/>of<br/>
126
+ 1<br/>
127
+ √<br/>
128
+ .&#160;Additive&#160;attention&#160;computes&#160;the&#160;compatibility&#160;function&#160;using&#160;a&#160;feed-forward&#160;network&#160;with<br/>
129
+ dk<br/>
130
+ a&#160;single&#160;hidden&#160;layer.&#160;While&#160;the&#160;two&#160;are&#160;similar&#160;in&#160;theoretical&#160;complexity,&#160;dot-product&#160;attention&#160;is<br/>much&#160;faster&#160;and&#160;more&#160;space-efficient&#160;in&#160;practice,&#160;since&#160;it&#160;can&#160;be&#160;implemented&#160;using&#160;highly&#160;optimized<br/>matrix&#160;multiplication&#160;code.<br/>
131
+ While&#160;for&#160;small&#160;values&#160;of&#160;dk&#160;the&#160;two&#160;mechanisms&#160;perform&#160;similarly,&#160;additive&#160;attention&#160;outperforms<br/>
132
+ dot&#160;product&#160;attention&#160;without&#160;scaling&#160;for&#160;larger&#160;values&#160;of&#160;dk&#160;<a href="">[3].&#160;</a>We&#160;suspect&#160;that&#160;for&#160;large&#160;values&#160;of<br/>dk,&#160;the&#160;dot&#160;products&#160;grow&#160;large&#160;in&#160;magnitude,&#160;pushing&#160;the&#160;softmax&#160;function&#160;into&#160;regions&#160;where&#160;it&#160;has<br/>extremely&#160;small&#160;gradients&#160;<a href="">4.&#160;</a>To&#160;counteract&#160;this&#160;effect,&#160;we&#160;scale&#160;the&#160;dot&#160;products&#160;by<br/>
133
+ 1<br/>
134
+ √<br/>
135
+ .<br/>
136
+ dk<br/>
137
+ 3.2.2<br/>
138
+ Multi-Head&#160;Attention<br/>
139
+ Instead&#160;of&#160;performing&#160;a&#160;single&#160;attention&#160;function&#160;with&#160;dmodel-dimensional&#160;keys,&#160;values&#160;and&#160;queries,<br/>
140
+ we&#160;found&#160;it&#160;beneficial&#160;to&#160;linearly&#160;project&#160;the&#160;queries,&#160;keys&#160;and&#160;values&#160;h&#160;times&#160;with&#160;different,&#160;learned<br/>
141
+ linear&#160;projections&#160;to&#160;dk,&#160;dk&#160;and&#160;dv&#160;dimensions,&#160;respectively.&#160;On&#160;each&#160;of&#160;these&#160;projected&#160;versions&#160;of<br/>queries,&#160;keys&#160;and&#160;values&#160;we&#160;then&#160;perform&#160;the&#160;attention&#160;function&#160;in&#160;parallel,&#160;yielding&#160;dv-dimensional<br/>output&#160;values.&#160;These&#160;are&#160;concatenated&#160;and&#160;once&#160;again&#160;projected,&#160;resulting&#160;in&#160;the&#160;final&#160;values,&#160;as<br/>depicted&#160;in&#160;Figure&#160;<a href="">2.</a><br/>
142
+ Multi-head&#160;attention&#160;allows&#160;the&#160;model&#160;to&#160;jointly&#160;attend&#160;to&#160;information&#160;from&#160;different&#160;representation<br/>subspaces&#160;at&#160;different&#160;positions.&#160;With&#160;a&#160;single&#160;attention&#160;head,&#160;averaging&#160;inhibits&#160;this.<br/>
143
+ 4To&#160;illustrate&#160;why&#160;the&#160;dot&#160;products&#160;get&#160;large,&#160;assume&#160;that&#160;the&#160;components&#160;of&#160;q&#160;and&#160;k&#160;are&#160;independent&#160;random<br/>
144
+ Pd<br/>
145
+ variables&#160;with&#160;mean&#160;0&#160;and&#160;variance&#160;1.&#160;Then&#160;their&#160;dot&#160;product,&#160;q<br/>
146
+ k<br/>
147
+ ·&#160;k&#160;=<br/>
148
+ q<br/>
149
+ i=1&#160;iki,&#160;has&#160;mean&#160;0&#160;and&#160;variance&#160;dk&#160;.<br/>
150
+ 4<br/>
151
+ <hr/>
152
+ <a name=5></a>MultiHead(Q,&#160;K,&#160;V&#160;)&#160;=&#160;Concat(head1,&#160;...,&#160;headh)W&#160;O<br/>
153
+ where&#160;headi&#160;=&#160;Attention(QW&#160;Q,&#160;KW&#160;K<br/>
154
+ i<br/>
155
+ i&#160;,&#160;V&#160;W&#160;V<br/>
156
+ i&#160;)<br/>
157
+ Where&#160;the&#160;projections&#160;are&#160;parameter&#160;matrices&#160;W&#160;Q<br/>
158
+ i<br/>
159
+ ∈&#160;Rdmodel×dk&#160;,&#160;W&#160;K<br/>
160
+ i<br/>
161
+ ∈&#160;Rdmodel×dk&#160;,&#160;W&#160;V<br/>
162
+ i<br/>
163
+ ∈&#160;Rdmodel×dv<br/>
164
+ and&#160;W&#160;O&#160;∈&#160;Rhdv×dmodel.<br/>
165
+ In&#160;this&#160;work&#160;we&#160;employ&#160;h&#160;=&#160;8&#160;parallel&#160;attention&#160;layers,&#160;or&#160;heads.&#160;For&#160;each&#160;of&#160;these&#160;we&#160;use<br/>dk&#160;=&#160;dv&#160;=&#160;dmodel/h&#160;=&#160;64.&#160;Due&#160;to&#160;the&#160;reduced&#160;dimension&#160;of&#160;each&#160;head,&#160;the&#160;total&#160;computational&#160;cost<br/>is&#160;similar&#160;to&#160;that&#160;of&#160;single-head&#160;attention&#160;with&#160;full&#160;dimensionality.<br/>
166
+ 3.2.3<br/>
167
+ Applications&#160;of&#160;Attention&#160;in&#160;our&#160;Model<br/>
168
+ The&#160;Transformer&#160;uses&#160;multi-head&#160;attention&#160;in&#160;three&#160;different&#160;ways:<br/>
169
+ •&#160;In&#160;&#34;encoder-decoder&#160;attention&#34;&#160;layers,&#160;the&#160;queries&#160;come&#160;from&#160;the&#160;previous&#160;decoder&#160;layer,<br/>
170
+ and&#160;the&#160;memory&#160;keys&#160;and&#160;values&#160;come&#160;from&#160;the&#160;output&#160;of&#160;the&#160;encoder.&#160;This&#160;allows&#160;every<br/>position&#160;in&#160;the&#160;decoder&#160;to&#160;attend&#160;over&#160;all&#160;positions&#160;in&#160;the&#160;input&#160;sequence.&#160;This&#160;mimics&#160;the<br/>typical&#160;encoder-decoder&#160;attention&#160;mechanisms&#160;in&#160;sequence-to-sequence&#160;models&#160;such&#160;as<br/><a href="">[31,&#160;2,&#160;8].</a><br/>
171
+ •&#160;The&#160;encoder&#160;contains&#160;self-attention&#160;layers.&#160;In&#160;a&#160;self-attention&#160;layer&#160;all&#160;of&#160;the&#160;keys,&#160;values<br/>
172
+ and&#160;queries&#160;come&#160;from&#160;the&#160;same&#160;place,&#160;in&#160;this&#160;case,&#160;the&#160;output&#160;of&#160;the&#160;previous&#160;layer&#160;in&#160;the<br/>encoder.&#160;Each&#160;position&#160;in&#160;the&#160;encoder&#160;can&#160;attend&#160;to&#160;all&#160;positions&#160;in&#160;the&#160;previous&#160;layer&#160;of&#160;the<br/>encoder.<br/>
173
+ •&#160;Similarly,&#160;self-attention&#160;layers&#160;in&#160;the&#160;decoder&#160;allow&#160;each&#160;position&#160;in&#160;the&#160;decoder&#160;to&#160;attend&#160;to<br/>
174
+ all&#160;positions&#160;in&#160;the&#160;decoder&#160;up&#160;to&#160;and&#160;including&#160;that&#160;position.&#160;We&#160;need&#160;to&#160;prevent&#160;leftward<br/>information&#160;flow&#160;in&#160;the&#160;decoder&#160;to&#160;preserve&#160;the&#160;auto-regressive&#160;property.&#160;We&#160;implement&#160;this<br/>inside&#160;of&#160;scaled&#160;dot-product&#160;attention&#160;by&#160;masking&#160;out&#160;(setting&#160;to&#160;−∞)&#160;all&#160;values&#160;in&#160;the&#160;input<br/>of&#160;the&#160;softmax&#160;which&#160;correspond&#160;to&#160;illegal&#160;connections.&#160;See&#160;Figure&#160;<a href="">2.</a><br/>
175
+ 3.3<br/>
176
+ Position-wise&#160;Feed-Forward&#160;Networks<br/>
177
+ In&#160;addition&#160;to&#160;attention&#160;sub-layers,&#160;each&#160;of&#160;the&#160;layers&#160;in&#160;our&#160;encoder&#160;and&#160;decoder&#160;contains&#160;a&#160;fully<br/>connected&#160;feed-forward&#160;network,&#160;which&#160;is&#160;applied&#160;to&#160;each&#160;position&#160;separately&#160;and&#160;identically.&#160;This<br/>consists&#160;of&#160;two&#160;linear&#160;transformations&#160;with&#160;a&#160;ReLU&#160;activation&#160;in&#160;between.<br/>
178
+ FFN(x)&#160;=&#160;max(0,&#160;xW1&#160;+&#160;b1)W2&#160;+&#160;b2<br/>
179
+ (2)<br/>
180
+ While&#160;the&#160;linear&#160;transformations&#160;are&#160;the&#160;same&#160;across&#160;different&#160;positions,&#160;they&#160;use&#160;different&#160;parameters<br/>
181
+ from&#160;layer&#160;to&#160;layer.&#160;Another&#160;way&#160;of&#160;describing&#160;this&#160;is&#160;as&#160;two&#160;convolutions&#160;with&#160;kernel&#160;size&#160;1.<br/>
182
+ The&#160;dimensionality&#160;of&#160;input&#160;and&#160;output&#160;is&#160;dmodel&#160;=&#160;512,&#160;and&#160;the&#160;inner-layer&#160;has&#160;dimensionality<br/>
183
+ dff&#160;=&#160;2048.<br/>
184
+ 3.4<br/>
185
+ Embeddings&#160;and&#160;Softmax<br/>
186
+ Similarly&#160;to&#160;other&#160;sequence&#160;transduction&#160;models,&#160;we&#160;use&#160;learned&#160;embeddings&#160;to&#160;convert&#160;the&#160;input<br/>tokens&#160;and&#160;output&#160;tokens&#160;to&#160;vectors&#160;of&#160;dimension&#160;dmodel.&#160;We&#160;also&#160;use&#160;the&#160;usual&#160;learned&#160;linear&#160;transfor-<br/>mation&#160;and&#160;softmax&#160;function&#160;to&#160;convert&#160;the&#160;decoder&#160;output&#160;to&#160;predicted&#160;next-token&#160;probabilities.&#160;In<br/>our&#160;model,&#160;we&#160;share&#160;the&#160;same&#160;weight&#160;matrix&#160;between&#160;the&#160;two&#160;embedding&#160;layers&#160;and&#160;the&#160;pre-softmax<br/>
187
+ √<br/>
188
+ linear&#160;transformation,&#160;similar&#160;to&#160;<a href="">[24].&#160;</a>In&#160;the&#160;embedding&#160;layers,&#160;we&#160;multiply&#160;those&#160;weights&#160;by<br/>
189
+ dmodel.<br/>
190
+ 3.5<br/>
191
+ Positional&#160;Encoding<br/>
192
+ Since&#160;our&#160;model&#160;contains&#160;no&#160;recurrence&#160;and&#160;no&#160;convolution,&#160;in&#160;order&#160;for&#160;the&#160;model&#160;to&#160;make&#160;use&#160;of&#160;the<br/>order&#160;of&#160;the&#160;sequence,&#160;we&#160;must&#160;inject&#160;some&#160;information&#160;about&#160;the&#160;relative&#160;or&#160;absolute&#160;position&#160;of&#160;the<br/>tokens&#160;in&#160;the&#160;sequence.&#160;To&#160;this&#160;end,&#160;we&#160;add&#160;&#34;positional&#160;encodings&#34;&#160;to&#160;the&#160;input&#160;embeddings&#160;at&#160;the<br/>
193
+ 5<br/>
194
+ <hr/>
195
+ <a name=6></a>Table&#160;1:&#160;Maximum&#160;path&#160;lengths,&#160;per-layer&#160;complexity&#160;and&#160;minimum&#160;number&#160;of&#160;sequential&#160;operations<br/>
196
+ for&#160;different&#160;layer&#160;types.&#160;n&#160;is&#160;the&#160;sequence&#160;length,&#160;d&#160;is&#160;the&#160;representation&#160;dimension,&#160;k&#160;is&#160;the&#160;kernel<br/>size&#160;of&#160;convolutions&#160;and&#160;r&#160;the&#160;size&#160;of&#160;the&#160;neighborhood&#160;in&#160;restricted&#160;self-attention.<br/>
197
+ Layer&#160;Type<br/>
198
+ Complexity&#160;per&#160;Layer<br/>
199
+ Sequential<br/>
200
+ Maximum&#160;Path&#160;Length<br/>
201
+ Operations<br/>
202
+ Self-Attention<br/>
203
+ O(n2&#160;·&#160;d)<br/>
204
+ O(1)<br/>
205
+ O(1)<br/>
206
+ Recurrent<br/>
207
+ O(n&#160;·&#160;d2)<br/>
208
+ O(n)<br/>
209
+ O(n)<br/>
210
+ Convolutional<br/>
211
+ O(k&#160;·&#160;n&#160;·&#160;d2)<br/>
212
+ O(1)<br/>
213
+ O(logk(n))<br/>
214
+ Self-Attention&#160;(restricted)<br/>
215
+ O(r&#160;·&#160;n&#160;·&#160;d)<br/>
216
+ O(1)<br/>
217
+ O(n/r)<br/>
218
+ bottoms&#160;of&#160;the&#160;encoder&#160;and&#160;decoder&#160;stacks.&#160;The&#160;positional&#160;encodings&#160;have&#160;the&#160;same&#160;dimension&#160;dmodel<br/>as&#160;the&#160;embeddings,&#160;so&#160;that&#160;the&#160;two&#160;can&#160;be&#160;summed.&#160;There&#160;are&#160;many&#160;choices&#160;of&#160;positional&#160;encodings,<br/>learned&#160;and&#160;fixed&#160;<a href="">[8].</a><br/>
219
+ In&#160;this&#160;work,&#160;we&#160;use&#160;sine&#160;and&#160;cosine&#160;functions&#160;of&#160;different&#160;frequencies:<br/>
220
+ P&#160;E(pos,2i)&#160;=&#160;sin(pos/100002i/dmodel)<br/>
221
+ P&#160;E(pos,2i+1)&#160;=&#160;cos(pos/100002i/dmodel)<br/>
222
+ where&#160;pos&#160;is&#160;the&#160;position&#160;and&#160;i&#160;is&#160;the&#160;dimension.&#160;That&#160;is,&#160;each&#160;dimension&#160;of&#160;the&#160;positional&#160;encoding<br/>
223
+ corresponds&#160;to&#160;a&#160;sinusoid.&#160;The&#160;wavelengths&#160;form&#160;a&#160;geometric&#160;progression&#160;from&#160;2π&#160;to&#160;10000&#160;·&#160;2π.&#160;We<br/>chose&#160;this&#160;function&#160;because&#160;we&#160;hypothesized&#160;it&#160;would&#160;allow&#160;the&#160;model&#160;to&#160;easily&#160;learn&#160;to&#160;attend&#160;by<br/>relative&#160;positions,&#160;since&#160;for&#160;any&#160;fixed&#160;offset&#160;k,&#160;P&#160;Epos+k&#160;can&#160;be&#160;represented&#160;as&#160;a&#160;linear&#160;function&#160;of<br/>P&#160;Epos.<br/>
224
+ We&#160;also&#160;experimented&#160;with&#160;using&#160;learned&#160;positional&#160;embeddings&#160;<a href="">[8]&#160;</a>instead,&#160;and&#160;found&#160;that&#160;the&#160;two<br/>versions&#160;produced&#160;nearly&#160;identical&#160;results&#160;(see&#160;Table&#160;<a href="">3&#160;</a>row&#160;(E)).&#160;We&#160;chose&#160;the&#160;sinusoidal&#160;version<br/>
225
+ because&#160;it&#160;may&#160;allow&#160;the&#160;model&#160;to&#160;extrapolate&#160;to&#160;sequence&#160;lengths&#160;longer&#160;than&#160;the&#160;ones&#160;encountered<br/>during&#160;training.<br/>
226
+ 4<br/>
227
+ Why&#160;Self-Attention<br/>
228
+ In&#160;this&#160;section&#160;we&#160;compare&#160;various&#160;aspects&#160;of&#160;self-attention&#160;layers&#160;to&#160;the&#160;recurrent&#160;and&#160;convolu-<br/>tional&#160;layers&#160;commonly&#160;used&#160;for&#160;mapping&#160;one&#160;variable-length&#160;sequence&#160;of&#160;symbol&#160;representations<br/>
229
+ (x1,&#160;...,&#160;xn)&#160;to&#160;another&#160;sequence&#160;of&#160;equal&#160;length&#160;(z1,&#160;...,&#160;zn),&#160;with&#160;xi,&#160;zi&#160;∈&#160;Rd,&#160;such&#160;as&#160;a&#160;hidden<br/>
230
+ layer&#160;in&#160;a&#160;typical&#160;sequence&#160;transduction&#160;encoder&#160;or&#160;decoder.&#160;Motivating&#160;our&#160;use&#160;of&#160;self-attention&#160;we<br/>consider&#160;three&#160;desiderata.<br/>
231
+ One&#160;is&#160;the&#160;total&#160;computational&#160;complexity&#160;per&#160;layer.&#160;Another&#160;is&#160;the&#160;amount&#160;of&#160;computation&#160;that&#160;can<br/>be&#160;parallelized,&#160;as&#160;measured&#160;by&#160;the&#160;minimum&#160;number&#160;of&#160;sequential&#160;operations&#160;required.<br/>
232
+ The&#160;third&#160;is&#160;the&#160;path&#160;length&#160;between&#160;long-range&#160;dependencies&#160;in&#160;the&#160;network.&#160;Learning&#160;long-range<br/>
233
+ dependencies&#160;is&#160;a&#160;key&#160;challenge&#160;in&#160;many&#160;sequence&#160;transduction&#160;tasks.&#160;One&#160;key&#160;factor&#160;affecting&#160;the<br/>ability&#160;to&#160;learn&#160;such&#160;dependencies&#160;is&#160;the&#160;length&#160;of&#160;the&#160;paths&#160;forward&#160;and&#160;backward&#160;signals&#160;have&#160;to<br/>traverse&#160;in&#160;the&#160;network.&#160;The&#160;shorter&#160;these&#160;paths&#160;between&#160;any&#160;combination&#160;of&#160;positions&#160;in&#160;the&#160;input<br/>and&#160;output&#160;sequences,&#160;the&#160;easier&#160;it&#160;is&#160;to&#160;learn&#160;long-range&#160;dependencies&#160;<a href="">[11].&#160;</a>Hence&#160;we&#160;also&#160;compare<br/>the&#160;maximum&#160;path&#160;length&#160;between&#160;any&#160;two&#160;input&#160;and&#160;output&#160;positions&#160;in&#160;networks&#160;composed&#160;of&#160;the<br/>different&#160;layer&#160;types.<br/>
234
+ As&#160;noted&#160;in&#160;Table&#160;<a href="">1,&#160;</a>a&#160;self-attention&#160;layer&#160;connects&#160;all&#160;positions&#160;with&#160;a&#160;constant&#160;number&#160;of&#160;sequentially<br/>
235
+ executed&#160;operations,&#160;whereas&#160;a&#160;recurrent&#160;layer&#160;requires&#160;O(n)&#160;sequential&#160;operations.&#160;In&#160;terms&#160;of<br/>computational&#160;complexity,&#160;self-attention&#160;layers&#160;are&#160;faster&#160;than&#160;recurrent&#160;layers&#160;when&#160;the&#160;sequence<br/>length&#160;n&#160;is&#160;smaller&#160;than&#160;the&#160;representation&#160;dimensionality&#160;d,&#160;which&#160;is&#160;most&#160;often&#160;the&#160;case&#160;with<br/>sentence&#160;representations&#160;used&#160;by&#160;state-of-the-art&#160;models&#160;in&#160;machine&#160;translations,&#160;such&#160;as&#160;word-piece<br/><a href="">[31]&#160;</a>and&#160;byte-pair&#160;<a href="">[25]&#160;</a>representations.&#160;To&#160;improve&#160;computational&#160;performance&#160;for&#160;tasks&#160;involving<br/>very&#160;long&#160;sequences,&#160;self-attention&#160;could&#160;be&#160;restricted&#160;to&#160;considering&#160;only&#160;a&#160;neighborhood&#160;of&#160;size&#160;r&#160;in<br/>
236
+ 6<br/>
237
+ <hr/>
238
+ <a name=7></a>the&#160;input&#160;sequence&#160;centered&#160;around&#160;the&#160;respective&#160;output&#160;position.&#160;This&#160;would&#160;increase&#160;the&#160;maximum<br/>path&#160;length&#160;to&#160;O(n/r).&#160;We&#160;plan&#160;to&#160;investigate&#160;this&#160;approach&#160;further&#160;in&#160;future&#160;work.<br/>
239
+ A&#160;single&#160;convolutional&#160;layer&#160;with&#160;kernel&#160;width&#160;k&#160;&lt;&#160;n&#160;does&#160;not&#160;connect&#160;all&#160;pairs&#160;of&#160;input&#160;and&#160;output<br/>
240
+ positions.&#160;Doing&#160;so&#160;requires&#160;a&#160;stack&#160;of&#160;O(n/k)&#160;convolutional&#160;layers&#160;in&#160;the&#160;case&#160;of&#160;contiguous&#160;kernels,<br/>or&#160;O(logk(n))&#160;in&#160;the&#160;case&#160;of&#160;dilated&#160;convolutions&#160;<a href="">[15],&#160;</a>increasing&#160;the&#160;length&#160;of&#160;the&#160;longest&#160;paths<br/>between&#160;any&#160;two&#160;positions&#160;in&#160;the&#160;network.&#160;Convolutional&#160;layers&#160;are&#160;generally&#160;more&#160;expensive&#160;than<br/>recurrent&#160;layers,&#160;by&#160;a&#160;factor&#160;of&#160;k.&#160;Separable&#160;convolutions&#160;<a href="">[6],&#160;</a>however,&#160;decrease&#160;the&#160;complexity<br/>considerably,&#160;to&#160;O(k&#160;·&#160;n&#160;·&#160;d&#160;+&#160;n&#160;·&#160;d2).&#160;Even&#160;with&#160;k&#160;=&#160;n,&#160;however,&#160;the&#160;complexity&#160;of&#160;a&#160;separable<br/>convolution&#160;is&#160;equal&#160;to&#160;the&#160;combination&#160;of&#160;a&#160;self-attention&#160;layer&#160;and&#160;a&#160;point-wise&#160;feed-forward&#160;layer,<br/>the&#160;approach&#160;we&#160;take&#160;in&#160;our&#160;model.<br/>
241
+ As&#160;side&#160;benefit,&#160;self-attention&#160;could&#160;yield&#160;more&#160;interpretable&#160;models.&#160;We&#160;inspect&#160;attention&#160;distributions<br/>
242
+ from&#160;our&#160;models&#160;and&#160;present&#160;and&#160;discuss&#160;examples&#160;in&#160;the&#160;appendix.&#160;Not&#160;only&#160;do&#160;individual&#160;attention<br/>heads&#160;clearly&#160;learn&#160;to&#160;perform&#160;different&#160;tasks,&#160;many&#160;appear&#160;to&#160;exhibit&#160;behavior&#160;related&#160;to&#160;the&#160;syntactic<br/>and&#160;semantic&#160;structure&#160;of&#160;the&#160;sentences.<br/>
243
+ 5<br/>
244
+ Training<br/>
245
+ This&#160;section&#160;describes&#160;the&#160;training&#160;regime&#160;for&#160;our&#160;models.<br/>
246
+ 5.1<br/>
247
+ Training&#160;Data&#160;and&#160;Batching<br/>
248
+ We&#160;trained&#160;on&#160;the&#160;standard&#160;WMT&#160;2014&#160;English-German&#160;dataset&#160;consisting&#160;of&#160;about&#160;4.5&#160;million<br/>
249
+ sentence&#160;pairs.&#160;Sentences&#160;were&#160;encoded&#160;using&#160;byte-pair&#160;encoding&#160;<a href="">[3],&#160;</a>which&#160;has&#160;a&#160;shared&#160;source-<br/>target&#160;vocabulary&#160;of&#160;about&#160;37000&#160;tokens.&#160;For&#160;English-French,&#160;we&#160;used&#160;the&#160;significantly&#160;larger&#160;WMT<br/>2014&#160;English-French&#160;dataset&#160;consisting&#160;of&#160;36M&#160;sentences&#160;and&#160;split&#160;tokens&#160;into&#160;a&#160;32000&#160;word-piece<br/>vocabulary&#160;<a href="">[31].&#160;</a>Sentence&#160;pairs&#160;were&#160;batched&#160;together&#160;by&#160;approximate&#160;sequence&#160;length.&#160;Each&#160;training<br/>batch&#160;contained&#160;a&#160;set&#160;of&#160;sentence&#160;pairs&#160;containing&#160;approximately&#160;25000&#160;source&#160;tokens&#160;and&#160;25000<br/>target&#160;tokens.<br/>
250
+ 5.2<br/>
251
+ Hardware&#160;and&#160;Schedule<br/>
252
+ We&#160;trained&#160;our&#160;models&#160;on&#160;one&#160;machine&#160;with&#160;8&#160;NVIDIA&#160;P100&#160;GPUs.&#160;For&#160;our&#160;base&#160;models&#160;using<br/>
253
+ the&#160;hyperparameters&#160;described&#160;throughout&#160;the&#160;paper,&#160;each&#160;training&#160;step&#160;took&#160;about&#160;0.4&#160;seconds.&#160;We<br/>trained&#160;the&#160;base&#160;models&#160;for&#160;a&#160;total&#160;of&#160;100,000&#160;steps&#160;or&#160;12&#160;hours.&#160;For&#160;our&#160;big&#160;models,(described&#160;on&#160;the<br/>bottom&#160;line&#160;of&#160;table&#160;<a href="">3),&#160;</a>step&#160;time&#160;was&#160;1.0&#160;seconds.&#160;The&#160;big&#160;models&#160;were&#160;trained&#160;for&#160;300,000&#160;steps<br/>
254
+ (3.5&#160;days).<br/>
255
+ 5.3<br/>
256
+ Optimizer<br/>
257
+ We&#160;used&#160;the&#160;Adam&#160;optimizer&#160;<a href="">[17]&#160;</a>with&#160;β1&#160;=&#160;0.9,&#160;β2&#160;=&#160;0.98&#160;and&#160;ǫ&#160;=&#160;10−9.&#160;We&#160;varied&#160;the&#160;learning<br/>
258
+ rate&#160;over&#160;the&#160;course&#160;of&#160;training,&#160;according&#160;to&#160;the&#160;formula:<br/>
259
+ lrate&#160;=&#160;d−0.5<br/>
260
+ model&#160;·&#160;min(step_num−0.5,&#160;step_num&#160;·&#160;warmup_steps−1.5)<br/>
261
+ (3)<br/>
262
+ This&#160;corresponds&#160;to&#160;increasing&#160;the&#160;learning&#160;rate&#160;linearly&#160;for&#160;the&#160;first&#160;warmup_steps&#160;training&#160;steps,<br/>
263
+ and&#160;decreasing&#160;it&#160;thereafter&#160;proportionally&#160;to&#160;the&#160;inverse&#160;square&#160;root&#160;of&#160;the&#160;step&#160;number.&#160;We&#160;used<br/>warmup_steps&#160;=&#160;4000.<br/>
264
+ 5.4<br/>
265
+ Regularization<br/>
266
+ We&#160;employ&#160;three&#160;types&#160;of&#160;regularization&#160;during&#160;training:<br/>
267
+ Residual&#160;Dropout<br/>
268
+ We&#160;apply&#160;dropout&#160;<a href="">[27]&#160;</a>to&#160;the&#160;output&#160;of&#160;each&#160;sub-layer,&#160;before&#160;it&#160;is&#160;added&#160;to&#160;the<br/>
269
+ sub-layer&#160;input&#160;and&#160;normalized.&#160;In&#160;addition,&#160;we&#160;apply&#160;dropout&#160;to&#160;the&#160;sums&#160;of&#160;the&#160;embeddings&#160;and&#160;the<br/>positional&#160;encodings&#160;in&#160;both&#160;the&#160;encoder&#160;and&#160;decoder&#160;stacks.&#160;For&#160;the&#160;base&#160;model,&#160;we&#160;use&#160;a&#160;rate&#160;of<br/>Pdrop&#160;=&#160;0.1.<br/>
270
+ 7<br/>
271
+ <hr/>
272
+ <a name=8></a>Table&#160;2:&#160;The&#160;Transformer&#160;achieves&#160;better&#160;BLEU&#160;scores&#160;than&#160;previous&#160;state-of-the-art&#160;models&#160;on&#160;the<br/>
273
+ English-to-German&#160;and&#160;English-to-French&#160;newstest2014&#160;tests&#160;at&#160;a&#160;fraction&#160;of&#160;the&#160;training&#160;cost.<br/>
274
+ BLEU<br/>
275
+ Training&#160;Cost&#160;(FLOPs)<br/>
276
+ Model<br/>
277
+ EN-DE<br/>
278
+ EN-FR<br/>
279
+ EN-DE<br/>
280
+ EN-FR<br/>
281
+ ByteNet&#160;<a href="">[15]</a><br/>
282
+ 23.75<br/>
283
+ Deep-Att&#160;+&#160;PosUnk&#160;<a href="">[32]</a><br/>
284
+ 39.2<br/>
285
+ 1.0&#160;·&#160;1020<br/>
286
+ GNMT&#160;+&#160;RL&#160;<a href="">[31]</a><br/>
287
+ 24.6<br/>
288
+ 39.92<br/>
289
+ 2.3&#160;·&#160;1019<br/>
290
+ 1.4&#160;·&#160;1020<br/>
291
+ ConvS2S&#160;<a href="">[8]</a><br/>
292
+ 25.16<br/>
293
+ 40.46<br/>
294
+ 9.6&#160;·&#160;1018<br/>
295
+ 1.5&#160;·&#160;1020<br/>
296
+ MoE&#160;<a href="">[26]</a><br/>
297
+ 26.03<br/>
298
+ 40.56<br/>
299
+ 2.0&#160;·&#160;1019<br/>
300
+ 1.2&#160;·&#160;1020<br/>
301
+ Deep-Att&#160;+&#160;PosUnk&#160;Ensemble&#160;<a href="">[32]</a><br/>
302
+ 40.4<br/>
303
+ 8.0&#160;·&#160;1020<br/>
304
+ GNMT&#160;+&#160;RL&#160;Ensemble&#160;<a href="">[31]</a><br/>
305
+ 26.30<br/>
306
+ 41.16<br/>
307
+ 1.8&#160;·&#160;1020<br/>
308
+ 1.1&#160;·&#160;1021<br/>
309
+ ConvS2S&#160;Ensemble&#160;<a href="">[8]</a><br/>
310
+ 26.36<br/>
311
+ 41.29<br/>
312
+ 7.7&#160;·&#160;1019<br/>
313
+ 1.2&#160;·&#160;1021<br/>
314
+ Transformer&#160;(base&#160;model)<br/>
315
+ 27.3<br/>
316
+ 38.1<br/>
317
+ 3&#160;3<br/>
318
+ .<br/>
319
+ ·&#160;1018<br/>
320
+ Transformer&#160;(big)<br/>
321
+ 28.4<br/>
322
+ 41.0<br/>
323
+ 2.3&#160;·&#160;1019<br/>
324
+ Label&#160;Smoothing<br/>
325
+ During&#160;training,&#160;we&#160;employed&#160;label&#160;smoothing&#160;of&#160;value&#160;ǫls&#160;=&#160;0.1&#160;<a href="">[30].&#160;</a>This<br/>
326
+ hurts&#160;perplexity,&#160;as&#160;the&#160;model&#160;learns&#160;to&#160;be&#160;more&#160;unsure,&#160;but&#160;improves&#160;accuracy&#160;and&#160;BLEU&#160;score.<br/>
327
+ 6<br/>
328
+ Results<br/>
329
+ 6.1<br/>
330
+ Machine&#160;Translation<br/>
331
+ On&#160;the&#160;WMT&#160;2014&#160;English-to-German&#160;translation&#160;task,&#160;the&#160;big&#160;transformer&#160;model&#160;(Transformer&#160;(big)<br/>in&#160;Table&#160;<a href="">2)&#160;</a>outperforms&#160;the&#160;best&#160;previously&#160;reported&#160;models&#160;(including&#160;ensembles)&#160;by&#160;more&#160;than&#160;2.0<br/>BLEU,&#160;establishing&#160;a&#160;new&#160;state-of-the-art&#160;BLEU&#160;score&#160;of&#160;28.4.&#160;The&#160;configuration&#160;of&#160;this&#160;model&#160;is<br/>listed&#160;in&#160;the&#160;bottom&#160;line&#160;of&#160;Table&#160;<a href="">3.&#160;</a>Training&#160;took&#160;3.5&#160;days&#160;on&#160;8&#160;P100&#160;GPUs.&#160;Even&#160;our&#160;base&#160;model<br/>surpasses&#160;all&#160;previously&#160;published&#160;models&#160;and&#160;ensembles,&#160;at&#160;a&#160;fraction&#160;of&#160;the&#160;training&#160;cost&#160;of&#160;any&#160;of<br/>the&#160;competitive&#160;models.<br/>
332
+ On&#160;the&#160;WMT&#160;2014&#160;English-to-French&#160;translation&#160;task,&#160;our&#160;big&#160;model&#160;achieves&#160;a&#160;BLEU&#160;score&#160;of&#160;41.0,<br/>outperforming&#160;all&#160;of&#160;the&#160;previously&#160;published&#160;single&#160;models,&#160;at&#160;less&#160;than&#160;1/4&#160;the&#160;training&#160;cost&#160;of&#160;the<br/>previous&#160;state-of-the-art&#160;model.&#160;The&#160;Transformer&#160;(big)&#160;model&#160;trained&#160;for&#160;English-to-French&#160;used<br/>dropout&#160;rate&#160;Pdrop&#160;=&#160;0.1,&#160;instead&#160;of&#160;0.3.<br/>
333
+ For&#160;the&#160;base&#160;models,&#160;we&#160;used&#160;a&#160;single&#160;model&#160;obtained&#160;by&#160;averaging&#160;the&#160;last&#160;5&#160;checkpoints,&#160;which<br/>
334
+ were&#160;written&#160;at&#160;10-minute&#160;intervals.&#160;For&#160;the&#160;big&#160;models,&#160;we&#160;averaged&#160;the&#160;last&#160;20&#160;checkpoints.&#160;We<br/>
335
+ used&#160;beam&#160;search&#160;with&#160;a&#160;beam&#160;size&#160;of&#160;4&#160;and&#160;length&#160;penalty&#160;α&#160;=&#160;0.6&#160;<a href="">[31].&#160;</a>These&#160;hyperparameters<br/>
336
+ were&#160;chosen&#160;after&#160;experimentation&#160;on&#160;the&#160;development&#160;set.&#160;We&#160;set&#160;the&#160;maximum&#160;output&#160;length&#160;during<br/>
337
+ inference&#160;to&#160;input&#160;length&#160;+&#160;50,&#160;but&#160;terminate&#160;early&#160;when&#160;possible&#160;<a href="">[31].</a><br/>
338
+ Table&#160;<a href="">2&#160;</a>summarizes&#160;our&#160;results&#160;and&#160;compares&#160;our&#160;translation&#160;quality&#160;and&#160;training&#160;costs&#160;to&#160;other&#160;model<br/>
339
+ architectures&#160;from&#160;the&#160;literature.&#160;We&#160;estimate&#160;the&#160;number&#160;of&#160;floating&#160;point&#160;operations&#160;used&#160;to&#160;train&#160;a<br/>model&#160;by&#160;multiplying&#160;the&#160;training&#160;time,&#160;the&#160;number&#160;of&#160;GPUs&#160;used,&#160;and&#160;an&#160;estimate&#160;of&#160;the&#160;sustained<br/>single-precision&#160;floating-point&#160;capacity&#160;of&#160;each&#160;GPU&#160;<a href="">5.</a><br/>
340
+ 6.2<br/>
341
+ Model&#160;Variations<br/>
342
+ To&#160;evaluate&#160;the&#160;importance&#160;of&#160;different&#160;components&#160;of&#160;the&#160;Transformer,&#160;we&#160;varied&#160;our&#160;base&#160;model<br/>
343
+ in&#160;different&#160;ways,&#160;measuring&#160;the&#160;change&#160;in&#160;performance&#160;on&#160;English-to-German&#160;translation&#160;on&#160;the<br/>development&#160;set,&#160;newstest2013.&#160;We&#160;used&#160;beam&#160;search&#160;as&#160;described&#160;in&#160;the&#160;previous&#160;section,&#160;but&#160;no<br/>checkpoint&#160;averaging.&#160;We&#160;present&#160;these&#160;results&#160;in&#160;Table&#160;<a href="">3.</a><br/>
344
+ In&#160;Table&#160;<a href="">3&#160;</a>rows&#160;(A),&#160;we&#160;vary&#160;the&#160;number&#160;of&#160;attention&#160;heads&#160;and&#160;the&#160;attention&#160;key&#160;and&#160;value&#160;dimensions,<br/>keeping&#160;the&#160;amount&#160;of&#160;computation&#160;constant,&#160;as&#160;described&#160;in&#160;Section&#160;<a href="">3.2.2.&#160;</a>While&#160;single-head<br/>attention&#160;is&#160;0.9&#160;BLEU&#160;worse&#160;than&#160;the&#160;best&#160;setting,&#160;quality&#160;also&#160;drops&#160;off&#160;with&#160;too&#160;many&#160;heads.<br/>
345
+ 5We&#160;used&#160;values&#160;of&#160;2.8,&#160;3.7,&#160;6.0&#160;and&#160;9.5&#160;TFLOPS&#160;for&#160;K80,&#160;K40,&#160;M40&#160;and&#160;P100,&#160;respectively.<br/>
346
+ 8<br/>
347
+ <hr/>
348
+ <a name=9></a>Table&#160;3:&#160;Variations&#160;on&#160;the&#160;Transformer&#160;architecture.&#160;Unlisted&#160;values&#160;are&#160;identical&#160;to&#160;those&#160;of&#160;the&#160;base<br/>
349
+ model.&#160;All&#160;metrics&#160;are&#160;on&#160;the&#160;English-to-German&#160;translation&#160;development&#160;set,&#160;newstest2013.&#160;Listed<br/>perplexities&#160;are&#160;per-wordpiece,&#160;according&#160;to&#160;our&#160;byte-pair&#160;encoding,&#160;and&#160;should&#160;not&#160;be&#160;compared&#160;to<br/>per-word&#160;perplexities.<br/>
350
+ train<br/>
351
+ PPL<br/>
352
+ BLEU<br/>
353
+ params<br/>
354
+ N<br/>
355
+ dmodel<br/>
356
+ dff<br/>
357
+ h<br/>
358
+ dk<br/>
359
+ dv<br/>
360
+ Pdrop<br/>
361
+ ǫls<br/>
362
+ steps<br/>
363
+ (dev)<br/>
364
+ (dev)<br/>
365
+ ×106<br/>
366
+ base<br/>
367
+ 6<br/>
368
+ 512<br/>
369
+ 2048<br/>
370
+ 8<br/>
371
+ 64<br/>
372
+ 64<br/>
373
+ 0.1<br/>
374
+ 0.1<br/>
375
+ 100K<br/>
376
+ 4.92<br/>
377
+ 25.8<br/>
378
+ 65<br/>
379
+ 1<br/>
380
+ 512<br/>
381
+ 512<br/>
382
+ 5.29<br/>
383
+ 24.9<br/>
384
+ 4<br/>
385
+ 128<br/>
386
+ 128<br/>
387
+ 5.00<br/>
388
+ 25.5<br/>
389
+ (A)<br/>
390
+ 16<br/>
391
+ 32<br/>
392
+ 32<br/>
393
+ 4.91<br/>
394
+ 25.8<br/>
395
+ 32<br/>
396
+ 16<br/>
397
+ 16<br/>
398
+ 5.01<br/>
399
+ 25.4<br/>
400
+ 16<br/>
401
+ 5.16<br/>
402
+ 25.1<br/>
403
+ 58<br/>
404
+ (B)<br/>
405
+ 32<br/>
406
+ 5.01<br/>
407
+ 25.4<br/>
408
+ 60<br/>
409
+ 2<br/>
410
+ 6.11<br/>
411
+ 23.7<br/>
412
+ 36<br/>
413
+ 4<br/>
414
+ 5.19<br/>
415
+ 25.3<br/>
416
+ 50<br/>
417
+ 8<br/>
418
+ 4.88<br/>
419
+ 25.5<br/>
420
+ 80<br/>
421
+ (C)<br/>
422
+ 256<br/>
423
+ 32<br/>
424
+ 32<br/>
425
+ 5.75<br/>
426
+ 24.5<br/>
427
+ 28<br/>
428
+ 1024<br/>
429
+ 128<br/>
430
+ 128<br/>
431
+ 4.66<br/>
432
+ 26.0<br/>
433
+ 168<br/>
434
+ 1024<br/>
435
+ 5.12<br/>
436
+ 25.4<br/>
437
+ 53<br/>
438
+ 4096<br/>
439
+ 4.75<br/>
440
+ 26.2<br/>
441
+ 90<br/>
442
+ 0.0<br/>
443
+ 5.77<br/>
444
+ 24.6<br/>
445
+ 0.2<br/>
446
+ 4.95<br/>
447
+ 25.5<br/>
448
+ (D)<br/>
449
+ 0.0<br/>
450
+ 4.67<br/>
451
+ 25.3<br/>
452
+ 0.2<br/>
453
+ 5.47<br/>
454
+ 25.7<br/>
455
+ (E)<br/>
456
+ positional&#160;embedding&#160;instead&#160;of&#160;sinusoids<br/>
457
+ 4.92<br/>
458
+ 25.7<br/>
459
+ big<br/>
460
+ 6<br/>
461
+ 1024<br/>
462
+ 4096<br/>
463
+ 16<br/>
464
+ 0.3<br/>
465
+ 300K<br/>
466
+ 4.33<br/>
467
+ 26.4<br/>
468
+ 213<br/>
469
+ In&#160;Table&#160;<a href="">3&#160;</a>rows&#160;(B),&#160;we&#160;observe&#160;that&#160;reducing&#160;the&#160;attention&#160;key&#160;size&#160;dk&#160;hurts&#160;model&#160;quality.&#160;This<br/>suggests&#160;that&#160;determining&#160;compatibility&#160;is&#160;not&#160;easy&#160;and&#160;that&#160;a&#160;more&#160;sophisticated&#160;compatibility<br/>function&#160;than&#160;dot&#160;product&#160;may&#160;be&#160;beneficial.&#160;We&#160;further&#160;observe&#160;in&#160;rows&#160;(C)&#160;and&#160;(D)&#160;that,&#160;as&#160;expected,<br/>bigger&#160;models&#160;are&#160;better,&#160;and&#160;dropout&#160;is&#160;very&#160;helpful&#160;in&#160;avoiding&#160;over-fitting.&#160;In&#160;row&#160;(E)&#160;we&#160;replace&#160;our<br/>sinusoidal&#160;positional&#160;encoding&#160;with&#160;learned&#160;positional&#160;embeddings&#160;<a href="">[8],&#160;</a>and&#160;observe&#160;nearly&#160;identical<br/>results&#160;to&#160;the&#160;base&#160;model.<br/>
470
+ 7<br/>
471
+ Conclusion<br/>
472
+ In&#160;this&#160;work,&#160;we&#160;presented&#160;the&#160;Transformer,&#160;the&#160;first&#160;sequence&#160;transduction&#160;model&#160;based&#160;entirely&#160;on<br/>attention,&#160;replacing&#160;the&#160;recurrent&#160;layers&#160;most&#160;commonly&#160;used&#160;in&#160;encoder-decoder&#160;architectures&#160;with<br/>multi-headed&#160;self-attention.<br/>
473
+ For&#160;translation&#160;tasks,&#160;the&#160;Transformer&#160;can&#160;be&#160;trained&#160;significantly&#160;faster&#160;than&#160;architectures&#160;based<br/>on&#160;recurrent&#160;or&#160;convolutional&#160;layers.&#160;On&#160;both&#160;WMT&#160;2014&#160;English-to-German&#160;and&#160;WMT&#160;2014<br/>English-to-French&#160;translation&#160;tasks,&#160;we&#160;achieve&#160;a&#160;new&#160;state&#160;of&#160;the&#160;art.&#160;In&#160;the&#160;former&#160;task&#160;our&#160;best<br/>model&#160;outperforms&#160;even&#160;all&#160;previously&#160;reported&#160;ensembles.<br/>
474
+ We&#160;are&#160;excited&#160;about&#160;the&#160;future&#160;of&#160;attention-based&#160;models&#160;and&#160;plan&#160;to&#160;apply&#160;them&#160;to&#160;other&#160;tasks.&#160;We<br/>
475
+ plan&#160;to&#160;extend&#160;the&#160;Transformer&#160;to&#160;problems&#160;involving&#160;input&#160;and&#160;output&#160;modalities&#160;other&#160;than&#160;text&#160;and<br/>to&#160;investigate&#160;local,&#160;restricted&#160;attention&#160;mechanisms&#160;to&#160;efficiently&#160;handle&#160;large&#160;inputs&#160;and&#160;outputs<br/>such&#160;as&#160;images,&#160;audio&#160;and&#160;video.&#160;Making&#160;generation&#160;less&#160;sequential&#160;is&#160;another&#160;research&#160;goals&#160;of&#160;ours.<br/>
476
+ The&#160;code&#160;we&#160;used&#160;to&#160;train&#160;and&#160;evaluate&#160;our&#160;models&#160;is&#160;available&#160;at&#160;<a href="https://github.com/tensorflow/tensor2tensor">https://github.com/</a><br/>
477
+ <a href="https://github.com/tensorflow/tensor2tensor">tensorflow/tensor2tensor.</a><br/>
478
+ Acknowledgements<br/>
479
+ We&#160;are&#160;grateful&#160;to&#160;Nal&#160;Kalchbrenner&#160;and&#160;Stephan&#160;Gouws&#160;for&#160;their&#160;fruitful<br/>
480
+ comments,&#160;corrections&#160;and&#160;inspiration.<br/>
481
+ 9<br/>
482
+ <hr/>
483
+ <a name=10></a>References<br/>
484
+ [1]&#160;Jimmy&#160;Lei&#160;Ba,&#160;Jamie&#160;Ryan&#160;Kiros,&#160;and&#160;Geoffrey&#160;E&#160;Hinton.&#160;Layer&#160;normalization.&#160;<i>arXiv&#160;preprint</i><br/>
485
+ <i>arXiv:1607.06450</i>,&#160;2016.<br/>
486
+ [2]&#160;Dzmitry&#160;Bahdanau,&#160;Kyunghyun&#160;Cho,&#160;and&#160;Yoshua&#160;Bengio.&#160;Neural&#160;machine&#160;translation&#160;by&#160;jointly<br/>
487
+ learning&#160;to&#160;align&#160;and&#160;translate.&#160;<i>CoRR</i>,&#160;abs/1409.0473,&#160;2014.<br/>
488
+ [3]&#160;Denny&#160;Britz,&#160;Anna&#160;Goldie,&#160;Minh-Thang&#160;Luong,&#160;and&#160;Quoc&#160;V.&#160;Le.&#160;Massive&#160;exploration&#160;of&#160;neural<br/>
489
+ machine&#160;translation&#160;architectures.&#160;<i>CoRR</i>,&#160;abs/1703.03906,&#160;2017.<br/>
490
+ [4]&#160;Jianpeng&#160;Cheng,&#160;Li&#160;Dong,&#160;and&#160;Mirella&#160;Lapata.&#160;Long&#160;short-term&#160;memory-networks&#160;for&#160;machine<br/>
491
+ reading.&#160;<i>arXiv&#160;preprint&#160;arXiv:1601.06733</i>,&#160;2016.<br/>
492
+ [5]&#160;Kyunghyun&#160;Cho,&#160;Bart&#160;van&#160;Merrienboer,&#160;Caglar&#160;Gulcehre,&#160;Fethi&#160;Bougares,&#160;Holger&#160;Schwenk,<br/>
493
+ and&#160;Yoshua&#160;Bengio.&#160;Learning&#160;phrase&#160;representations&#160;using&#160;rnn&#160;encoder-decoder&#160;for&#160;statistical<br/>machine&#160;translation.&#160;<i>CoRR</i>,&#160;abs/1406.1078,&#160;2014.<br/>
494
+ [6]&#160;Francois&#160;Chollet.&#160;Xception:&#160;Deep&#160;learning&#160;with&#160;depthwise&#160;separable&#160;convolutions.&#160;<i>arXiv</i><br/>
495
+ <i>preprint&#160;arXiv:1610.02357</i>,&#160;2016.<br/>
496
+ [7]&#160;Junyoung&#160;Chung,&#160;Çaglar&#160;Gülçehre,&#160;Kyunghyun&#160;Cho,&#160;and&#160;Yoshua&#160;Bengio.&#160;Empirical&#160;evaluation<br/>
497
+ of&#160;gated&#160;recurrent&#160;neural&#160;networks&#160;on&#160;sequence&#160;modeling.&#160;<i>CoRR</i>,&#160;abs/1412.3555,&#160;2014.<br/>
498
+ [8]&#160;Jonas&#160;Gehring,&#160;Michael&#160;Auli,&#160;David&#160;Grangier,&#160;Denis&#160;Yarats,&#160;and&#160;Yann&#160;N.&#160;Dauphin.&#160;Convolu-<br/>
499
+ tional&#160;sequence&#160;to&#160;sequence&#160;learning.&#160;<i>arXiv&#160;preprint&#160;arXiv:1705.03122v2</i>,&#160;2017.<br/>
500
+ [9]&#160;Alex&#160;Graves.<br/>
501
+ Generating&#160;sequences&#160;with&#160;recurrent&#160;neural&#160;networks.<br/>
502
+ <i>arXiv&#160;preprint</i><br/>
503
+ <i>arXiv:1308.0850</i>,&#160;2013.<br/>
504
+ [10]&#160;Kaiming&#160;He,&#160;Xiangyu&#160;Zhang,&#160;Shaoqing&#160;Ren,&#160;and&#160;Jian&#160;Sun.&#160;Deep&#160;residual&#160;learning&#160;for&#160;im-<br/>
505
+ age&#160;recognition.&#160;In&#160;<i>Proceedings&#160;of&#160;the&#160;IEEE&#160;Conference&#160;on&#160;Computer&#160;Vision&#160;and&#160;Pattern</i><br/>
506
+ <i>Recognition</i>,&#160;pages&#160;770–778,&#160;2016.<br/>
507
+ [11]&#160;Sepp&#160;Hochreiter,&#160;Yoshua&#160;Bengio,&#160;Paolo&#160;Frasconi,&#160;and&#160;Jürgen&#160;Schmidhuber.&#160;Gradient&#160;flow&#160;in<br/>
508
+ recurrent&#160;nets:&#160;the&#160;difficulty&#160;of&#160;learning&#160;long-term&#160;dependencies,&#160;2001.<br/>
509
+ [12]&#160;Sepp&#160;Hochreiter&#160;and&#160;Jürgen&#160;Schmidhuber.&#160;Long&#160;short-term&#160;memory.&#160;<i>Neural&#160;computation</i>,<br/>
510
+ 9(8):1735–1780,&#160;1997.<br/>
511
+ [13]&#160;Rafal&#160;Jozefowicz,&#160;Oriol&#160;Vinyals,&#160;Mike&#160;Schuster,&#160;Noam&#160;Shazeer,&#160;and&#160;Yonghui&#160;Wu.&#160;Exploring<br/>
512
+ the&#160;limits&#160;of&#160;language&#160;modeling.&#160;<i>arXiv&#160;preprint&#160;arXiv:1602.02410</i>,&#160;2016.<br/>
513
+ [14]&#160;Łukasz&#160;Kaiser&#160;and&#160;Ilya&#160;Sutskever.&#160;Neural&#160;GPUs&#160;learn&#160;algorithms.&#160;In&#160;<i>International&#160;Conference</i><br/>
514
+ <i>on&#160;Learning&#160;Representations&#160;(ICLR)</i>,&#160;2016.<br/>
515
+ [15]&#160;Nal&#160;Kalchbrenner,&#160;Lasse&#160;Espeholt,&#160;Karen&#160;Simonyan,&#160;Aaron&#160;van&#160;den&#160;Oord,&#160;Alex&#160;Graves,&#160;and&#160;Ko-<br/>
516
+ ray&#160;Kavukcuoglu.&#160;Neural&#160;machine&#160;translation&#160;in&#160;linear&#160;time.&#160;<i>arXiv&#160;preprint&#160;arXiv:1610.10099v2</i>,<br/>2017.<br/>
517
+ [16]&#160;Yoon&#160;Kim,&#160;Carl&#160;Denton,&#160;Luong&#160;Hoang,&#160;and&#160;Alexander&#160;M.&#160;Rush.&#160;Structured&#160;attention&#160;networks.<br/>
518
+ In&#160;<i>International&#160;Conference&#160;on&#160;Learning&#160;Representations</i>,&#160;2017.<br/>
519
+ [17]&#160;Diederik&#160;Kingma&#160;and&#160;Jimmy&#160;Ba.&#160;Adam:&#160;A&#160;method&#160;for&#160;stochastic&#160;optimization.&#160;In&#160;<i>ICLR</i>,&#160;2015.<br/>
520
+ [18]&#160;Oleksii&#160;Kuchaiev&#160;and&#160;Boris&#160;Ginsburg.&#160;Factorization&#160;tricks&#160;for&#160;LSTM&#160;networks.&#160;<i>arXiv&#160;preprint</i><br/>
521
+ <i>arXiv:1703.10722</i>,&#160;2017.<br/>
522
+ [19]&#160;Zhouhan&#160;Lin,&#160;Minwei&#160;Feng,&#160;Cicero&#160;Nogueira&#160;dos&#160;Santos,&#160;Mo&#160;Yu,&#160;Bing&#160;Xiang,&#160;Bowen<br/>
523
+ Zhou,&#160;and&#160;Yoshua&#160;Bengio.&#160;A&#160;structured&#160;self-attentive&#160;sentence&#160;embedding.&#160;<i>arXiv&#160;preprint<br/>arXiv:1703.03130</i>,&#160;2017.<br/>
524
+ [20]&#160;Samy&#160;Bengio&#160;Łukasz&#160;Kaiser.&#160;Can&#160;active&#160;memory&#160;replace&#160;attention?&#160;In&#160;<i>Advances&#160;in&#160;Neural</i><br/>
525
+ <i>Information&#160;Processing&#160;Systems,&#160;(NIPS)</i>,&#160;2016.<br/>
526
+ 10<br/>
527
+ <hr/>
528
+ <a name=11></a>[21]&#160;Minh-Thang&#160;Luong,&#160;Hieu&#160;Pham,&#160;and&#160;Christopher&#160;D&#160;Manning.&#160;Effective&#160;approaches&#160;to&#160;attention-<br/>
529
+ based&#160;neural&#160;machine&#160;translation.&#160;<i>arXiv&#160;preprint&#160;arXiv:1508.04025</i>,&#160;2015.<br/>
530
+ [22]&#160;Ankur&#160;Parikh,&#160;Oscar&#160;Täckström,&#160;Dipanjan&#160;Das,&#160;and&#160;Jakob&#160;Uszkoreit.&#160;A&#160;decomposable&#160;attention<br/>
531
+ model.&#160;In&#160;<i>Empirical&#160;Methods&#160;in&#160;Natural&#160;Language&#160;Processing</i>,&#160;2016.<br/>
532
+ [23]&#160;Romain&#160;Paulus,&#160;Caiming&#160;Xiong,&#160;and&#160;Richard&#160;Socher.&#160;A&#160;deep&#160;reinforced&#160;model&#160;for&#160;abstractive<br/>
533
+ summarization.&#160;<i>arXiv&#160;preprint&#160;arXiv:1705.04304</i>,&#160;2017.<br/>
534
+ [24]&#160;Ofir&#160;Press&#160;and&#160;Lior&#160;Wolf.&#160;Using&#160;the&#160;output&#160;embedding&#160;to&#160;improve&#160;language&#160;models.&#160;<i>arXiv</i><br/>
535
+ <i>preprint&#160;arXiv:1608.05859</i>,&#160;2016.<br/>
536
+ [25]&#160;Rico&#160;Sennrich,&#160;Barry&#160;Haddow,&#160;and&#160;Alexandra&#160;Birch.&#160;Neural&#160;machine&#160;translation&#160;of&#160;rare&#160;words<br/>
537
+ with&#160;subword&#160;units.&#160;<i>arXiv&#160;preprint&#160;arXiv:1508.07909</i>,&#160;2015.<br/>
538
+ [26]&#160;Noam&#160;Shazeer,&#160;Azalia&#160;Mirhoseini,&#160;Krzysztof&#160;Maziarz,&#160;Andy&#160;Davis,&#160;Quoc&#160;Le,&#160;Geoffrey&#160;Hinton,<br/>
539
+ and&#160;Jeff&#160;Dean.&#160;Outrageously&#160;large&#160;neural&#160;networks:&#160;The&#160;sparsely-gated&#160;mixture-of-experts<br/>layer.&#160;<i>arXiv&#160;preprint&#160;arXiv:1701.06538</i>,&#160;2017.<br/>
540
+ [27]&#160;Nitish&#160;Srivastava,&#160;Geoffrey&#160;E&#160;Hinton,&#160;Alex&#160;Krizhevsky,&#160;Ilya&#160;Sutskever,&#160;and&#160;Ruslan&#160;Salakhutdi-<br/>
541
+ nov.&#160;Dropout:&#160;a&#160;simple&#160;way&#160;to&#160;prevent&#160;neural&#160;networks&#160;from&#160;overfitting.&#160;<i>Journal&#160;of&#160;Machine</i><br/>
542
+ <i>Learning&#160;Research</i>,&#160;15(1):1929–1958,&#160;2014.<br/>
543
+ [28]&#160;Sainbayar&#160;Sukhbaatar,&#160;arthur&#160;szlam,&#160;Jason&#160;Weston,&#160;and&#160;Rob&#160;Fergus.&#160;End-to-end&#160;memory<br/>
544
+ networks.&#160;In&#160;C.&#160;Cortes,&#160;N.&#160;D.&#160;Lawrence,&#160;D.&#160;D.&#160;Lee,&#160;M.&#160;Sugiyama,&#160;and&#160;R.&#160;Garnett,&#160;editors,<br/>
545
+ <i>Advances&#160;in&#160;Neural&#160;Information&#160;Processing&#160;Systems&#160;28</i>,&#160;pages&#160;2440–2448.&#160;Curran&#160;Associates,<br/>
546
+ Inc.,&#160;2015.<br/>
547
+ [29]&#160;Ilya&#160;Sutskever,&#160;Oriol&#160;Vinyals,&#160;and&#160;Quoc&#160;VV&#160;Le.&#160;Sequence&#160;to&#160;sequence&#160;learning&#160;with&#160;neural<br/>
548
+ networks.&#160;In&#160;<i>Advances&#160;in&#160;Neural&#160;Information&#160;Processing&#160;Systems</i>,&#160;pages&#160;3104–3112,&#160;2014.<br/>
549
+ [30]&#160;Christian&#160;Szegedy,&#160;Vincent&#160;Vanhoucke,&#160;Sergey&#160;Ioffe,&#160;Jonathon&#160;Shlens,&#160;and&#160;Zbigniew&#160;Wojna.<br/>
550
+ Rethinking&#160;the&#160;inception&#160;architecture&#160;for&#160;computer&#160;vision.&#160;<i>CoRR</i>,&#160;abs/1512.00567,&#160;2015.<br/>
551
+ [31]&#160;Yonghui&#160;Wu,&#160;Mike&#160;Schuster,&#160;Zhifeng&#160;Chen,&#160;Quoc&#160;V&#160;Le,&#160;Mohammad&#160;Norouzi,&#160;Wolfgang<br/>
552
+ Macherey,&#160;Maxim&#160;Krikun,&#160;Yuan&#160;Cao,&#160;Qin&#160;Gao,&#160;Klaus&#160;Macherey,&#160;et&#160;al.&#160;Google’s&#160;neural&#160;machine<br/>translation&#160;system:&#160;Bridging&#160;the&#160;gap&#160;between&#160;human&#160;and&#160;machine&#160;translation.&#160;<i>arXiv&#160;preprint<br/>arXiv:1609.08144</i>,&#160;2016.<br/>
553
+ [32]&#160;Jie&#160;Zhou,&#160;Ying&#160;Cao,&#160;Xuguang&#160;Wang,&#160;Peng&#160;Li,&#160;and&#160;Wei&#160;Xu.&#160;Deep&#160;recurrent&#160;models&#160;with<br/>
554
+ fast-forward&#160;connections&#160;for&#160;neural&#160;machine&#160;translation.&#160;<i>CoRR</i>,&#160;abs/1606.04199,&#160;2016.<br/>
555
+ 11<br/>
556
+ <hr/>
557
+ </body>
558
+ </html>