
论文地址:Attention Is All You Need
Abstract
The dominant sequence transduction models are based on complex recurrent or convolutional neural networks that include an encoder and a decoder. The best performing models also connect the encoder and decoder through an attention mechanism. We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely. Experiments on two machine translation tasks show these models to be superior in quality while being more parallelizable and requiring significantly less time to train. Our model achieves 28.4 BLEU on the WMT 2014 English - to - German translation task, improving over the existing best results, including ensembles, by over 2 BLEU. On the WMT 2014 English - to - French translation task, our model establishes a new single - model state - of - the - art BLEU score of 41.8 after training for 3.5 days on eight GPUs, a small fraction of the training costs of the best models from the literature. We show that the Transformer generalizes well to other tasks by applying it successfully to English constituency parsing both with large and limited training data.
主流的序列转导模型基于包含编码器和解码器的复杂循环神经网络或卷积神经网络。性能最佳的模型还通过注意力机制将编码器和解码器连接起来。我们提出了一种新的简单网络架构——Transformer,它完全基于注意力机制,完全摒弃了循环和卷积操作。在两项机器翻译任务上的实验表明,这些模型在质量上更具优势,同时具有更高的可并行性,且训练时间显著减少。我们的模型在WMT 2014英德翻译任务上达到了28.4的BLEU (Bilingual Evaluation Understudy)得分,比包括集成模型在内的现有最佳结果提高了2分以上BLEU。在WMT 2014英法翻译任务中,我们的模型在使用八个GPU训练3.5天后,达到了41.8的BLEU得分,创下了新的单模型最优成绩,而训练成本仅为文献中最佳模型的一小部分。我们通过将Transformer成功应用于大规模和有限训练数据下的英语句法成分解析任务,证明了它在其他任务上也具有良好的泛化能力。
1. Introduction
Recurrent neural networks, long short-term memory [13] and gated recurrent [7] neural networks in particular, have been firmly established as state of the art approaches in sequence modeling and transduction problems such as language modeling and machine translation [35, 2, 5]. Numerous efforts have since continued to push the boundaries of recurrent language models and encoder-decoder architectures [38, 24, 15].
循环神经网络,特别是长短期记忆(LSTM)神经网络[13]和门控循环(GRU)神经网络[7],已被公认为是序列建模和转换问题(如语言建模和机器翻译)中的最先进方法[35, 2, 5]。此后,许多研究工作继续拓展循环语言模型和编码器 - 解码器架构的边界[38, 24, 15]。
Recurrent models typically factor computation along the symbol positions of the input and output sequences. Aligning the positions to steps in computation time, they generate a sequence of hidden states h t h_{t} ht , as a function of the previous hidden state h t − 1 h_{t-1} ht−1 and the input for position t t t . This inherently sequential nature precludes parallelization within training examples, which becomes critical at longer sequence lengths, as memory constraints limit batching across examples. Recent work has achieved significant improvements in computational efficiency through factorization tricks [21] and conditional computation [32], while also improving model performance in case of the latter. The fundamental constraint of sequential computation, however, remains.
循环模型通常沿着输入和输出序列的符号位置来分解计算。它们将位置与计算时间中的步骤对齐,根据前一个隐藏状态 h t − 1 h_{t - 1} ht−1和位置 t t t的输入,生成一系列隐藏状态 h t h_t ht。这种固有的顺序性本质排除了训练样本内的并行化,当序列长度较长时,这一问题变得至关重要,因为内存限制会影响跨样本的批量处理。最近的研究工作通过分解技巧[21]和条件计算[32]在计算效率上取得了显著提升,并且在后者的情况下还提高了模型性能。然而,顺序计算的基本限制仍然存在。
Attention mechanisms have become an integral part of compelling sequence modeling and transduction models in various tasks, allowing modeling of dependencies without regard to their distance in the input or output sequences [2, 19]. In all but a few cases [27], however, such attention mechanisms are used in conjunction with a recurrent network.
注意力机制已成为各种任务中出色的序列建模和转换模型的重要组成部分,它允许对依赖关系进行建模,而无需考虑它们在输入或输出序列中的距离[2, 19]。然而,除了少数情况[27]外,这种注意力机制通常与循环网络结合使用。
In this work we propose the Transformer, a model architecture eschewing recurrence and instead relying entirely on an attention mechanism to draw global dependencies between input and output. The Transformer allows for significantly more parallelization and can reach a new state of the art in translation quality after being trained for as little as twelve hours on eight P100 GPUs.
在这项工作中,我们提出了Transformer,这是一种避开循环的模型架构,而是完全依赖注意力机制来提取输入和输出之间的全局依赖关系。Transformer支持显著更多的并行化,并且在8个P100 GPU上仅训练12小时后,就能在翻译质量上达到一个新的水平。
2. Background
The goal of reducing sequential computation also forms the foundation of the Extended Neural GPU [16], ByteNet [18] and ConvS2S [9], all of which use convolutional neural networks as basic building block, computing hidden representations in parallel for all input and output positions. In these models, the number of operations required to relate signals from two arbitrary input or output positions grows in the distance between positions, linearly for ConvS2S and logarithmically for ByteNet. This makes it more difficult to learn dependencies between distant positions [12]. In the Transformer this is reduced to a constant number of operations, albeit at the cost of reduced effective resolution due to averaging attention-weighted positions, an effect we counteract with Multi-Head Attention as described in section 3.2.
减少顺序计算的目标也是Extended Neural GPU [16]、ByteNet [18]和ConvS2S [9]的设计基础。这些模型均以卷积神经网络为基本构建块,能并行计算所有输入和输出位置的隐藏表示。在这些模型中,关联两个任意输入或输出位置信号所需的操作次数,会随位置间距离的增加而增长:ConvS2S呈线性增长,ByteNet呈对数增长。这使得模型更难学习远距离位置之间的依赖关系[12]。而在Transformer中,这一操作次数被简化为常数,尽管代价是由于对注意力加权位置进行平均而降低了有效分辨率——我们通过3.2节所述的多头注意力机制抵消了这一影响。
Self-attention, sometimes called intra-attention is an attention mechanism relating different positions of a single sequence in order to compute a representation of the sequence. Self-attention has been used successfully in a variety of tasks including reading comprehension, abstractive summarization, textual entailment and learning task-independent sentence representations [4, 27, 28, 22]
自注意力(有时称为内部注意力)是一种关联单个序列中不同位置以计算序列表示的注意力机制。它已成功应用于多种任务,包括阅读理解、抽象摘要、文本蕴含以及学习与任务无关的句子表示[4, 27, 28, 22]。
End-to-end memory networks are based on a recurrent attention mechanism instead of sequencealigned recurrence and have been shown to perform well on simple-language question answering and language modeling tasks [34].
端到端记忆网络基于循环注意力机制而非序列对齐的循环结构,已被证明在简单语言问答和语言建模任务中表现良好[34]。
To the best of our knowledge, however, the Transformer is the first transduction model relying entirely on self-attention to compute representations of its input and output without using sequencealigned RNNs or convolution. In the following sections, we will describe the Transformer, motivate self-attention and discuss its advantages over models such as [17, 18] and [9].
然而,据我们所知,Transformer是首个完全依赖自注意力来计算输入和输出表示的转导模型,它不使用序列对齐的循环神经网络或卷积。在后续章节中,我们将详细描述Transformer,阐述自注意力的设计动机,并讨论其相对于[17, 18]和[9]等模型的优势。
3. Model Architecture
Most competitive neural sequence transduction models have an encoder-decoder structure [5, 2, 35]. Here, the encoder maps an input sequence of symbol representations ( x 1 , . . . , x n ) (x_{1}, ..., x_{n}) (x1,...,xn) to a sequence of continuous representations z = ( z 1 , . . . , z n ) z=(z_{1}, ..., z_{n}) z=(z1,...,zn). Given z z z, the decoder then generates an output sequence ( y 1 , . . . , y m ) (y_{1}, ..., y_{m}) (y1,...,ym) of symbols one element at a time. At each step the model is auto-regressive [10], consuming the previously generated symbols as additional input when generating the next.
大多数具有竞争力的神经序列转导模型都采用编码器 - 解码器结构[5, 2, 35]。在这里,编码器将输入的符号表示序列 ( x 1 , . . . , x n ) (x_{1}, ..., x_{n}) (x1,...,xn)映射为连续表示序列 z = ( z 1 , . . . , z n ) z=(z_{1}, ..., z_{n}) z=(z1,...,zn)。在给定 z z z的情况下,解码器会逐个生成符号输出序列 ( y 1 , . . . , y m ) (y_{1}, ..., y_{m}) (y1,...,ym)。在每一步中,模型都是自回归的[10],即在生成下一个符号时,会将之前生成的符号作为额外输入。
The Transformer follows this overall architecture using stacked self-attention and point-wise, fully connected layers for both the encoder and decoder, shown in the left and right halves of Figure 1, respectively.
Transformer遵循这种整体架构,其编码器和解码器均使用堆叠的自注意力层以及逐点全连接层,分别如图1的左半部分和右半部分所示。
Figure 1: The Transformer - model architecture.

The Transformer follows this overall architecture using stacked self-attention and point-wise, fully connected layers for both the encoder and decoder, shown in the left and right halves of Figure 1, respectively.
Transformer遵循这种整体架构,其编码器和解码器均采用堆叠的自注意力层和逐点全连接层,分别如图1的左半部分和右半部分所示。
3.1 Encoder and Decoder Stacks
Encoder: The encoder is composed of a stack of N = 6 N=6 N=6 identical layers. Each layer has two sub-layers. The first is a multi-head self-attention mechanism, and the second is a simple, positionwise fully connected feed-forward network. We employ a residual connection [11] around each of the two sub-layers, followed by layer normalization [1]. That is, the output of each sub-layer is LayerNorm(x + Sublayer(x)), where Sublayer(x) is the function implemented by the sub-layer itself. To facilitate these residual connections, all sub-layers in the model, as well as the embedding layers, produce outputs of dimension d m o d e l = 512 d_{model}=512 dmodel=512.
编码器:编码器由 N = 6 N=6 N=6个相同的层堆叠而成。每个层包含两个子层:第一个是多头自注意力机制,第二个是简单的逐位置全连接前馈网络。我们在这两个子层的周围都使用了残差连接[11],随后进行层归一化[1]。也就是说,每个子层的输出为LayerNorm(x + Sublayer(x)),其中Sublayer(x)是该子层自身实现的函数。为便于这些残差连接的实现,模型中的所有子层以及嵌入层的输出维度均为 d m o d e l = 512 d_{model}=512 dmodel=512。
Decoder: The decoder is also composed of a stack of N = 6 N=6 N=6 identical layers. In addition to the two sub-layers in each encoder layer, the decoder inserts a third sub-layer, which performs multi-head attention over the output of the encoder stack. Similar to the encoder, we employ residual connections around each of the sub-layers, followed by layer normalization. We also modify the self-attention sub-layer in the decoder stack to prevent positions from attending to subsequent positions. This masking, combined with the fact that the output embeddings are offset by one position, ensures that the predictions for position i can depend only on the known outputs at positions less than i.
解码器:解码器同样由 N = 6 N=6 N=6个相同的层堆叠而成。除了包含编码器每层中的两个子层外,解码器还增加了第三个子层,该子层会对编码器堆叠的输出执行多头注意力操作。与编码器类似,我们在每个子层周围都使用了残差连接,随后进行层归一化。此外,我们对解码器堆叠中的自注意力子层进行了修改,以防止当前位置关注后续位置的信息。这种掩码操作,再加上输出嵌入会偏移一个位置这一设计,确保了对位置i的预测只能依赖于位置 i i i之前的已知输出。
3.2 Attention
An attention function can be described as mapping a query and a set of key-value pairs to an output, where the query, keys, values, and output are all vectors. The output is computed as a weighted sum of the values, where the weight assigned to each value is computed by a compatibility function of the query with the corresponding key.
注意力函数可以描述为将一个查询(query)和一组键值对(key-value pairs)映射到一个输出,其中查询、键、值和输出均为向量。输出是通过对值进行加权求和计算得到的,而分配给每个值的权重则是通过查询与对应键的兼容性函数计算得出的。
Figure 2

Figure 2: (left) Scaled Dot-Product Attention. (right) Multi-Head Attention consists of several attention layers running in parallel.
图2:(左)缩放点积注意力。(右)多头注意力由多个并行运行的注意力层组成。
3.2.1 Scaled Dot-Product Attention
We call our particular attention “Scaled Dot-Product Attention” (Figure 2). The input consists of queries and keys of dimension
d
k
d_{k}
dk, and values of dimension
d
v
d_{v}
dv. We compute the dot products of the query with all keys, divide each by
d
k
\sqrt{d_{k}}
dk, and apply a softmax function to obtain the weights on the values.
In practice, we compute the attention function on a set of queries simultaneously, packed together into a matrix Q. The keys and values are also packed together into matrices K and V. We compute the matrix of outputs as:
A
t
t
e
n
t
i
o
n
(
Q
,
K
,
V
)
=
s
o
f
t
m
a
x
(
Q
K
T
d
k
)
V
(
1
)
Attention(Q, K, V)=softmax\left(\frac{Q K^{T}}{\sqrt{d_{k}}}\right) V \quad (1)
Attention(Q,K,V)=softmax(dkQKT)V(1)
我们将自己使用的特定注意力机制称为“缩放点积注意力”(图2)。其输入包括维度为
d
k
d_{k}
dk的查询(queries)和键(keys),以及维度为
d
v
d_{v}
dv的值(values)。我们先计算查询与所有键的点积,再将每个结果除以
d
k
\sqrt{d_{k}}
dk,然后应用softmax函数以得到值的权重。
在实际应用中,我们会同时对一组查询计算注意力函数,将这些查询打包成矩阵Q。键和值也分别打包成矩阵K和V。输出矩阵的计算公式如下:
A
t
t
e
n
t
i
o
n
(
Q
,
K
,
V
)
=
s
o
f
t
m
a
x
(
Q
K
T
d
k
)
V
(
1
)
Attention(Q, K, V)=softmax\left(\frac{Q K^{T}}{\sqrt{d_{k}}}\right) V \quad (1)
Attention(Q,K,V)=softmax(dkQKT)V(1)
The two most commonly used attention functions are additive attention [2], and dot-product (multiplicative) attention. Dot-product attention is identical to our algorithm, except for the scaling factor of 1 d k \frac{1}{\sqrt{d_{k}}} dk1. Additive attention computes the compatibility function using a feed-forward network with a single hidden layer. While the two are similar in theoretical complexity, dot-product attention is much faster and more space-efficient in practice, since it can be implemented using highly optimized matrix multiplication code.
两种最常用的注意力函数是加性注意力[2]和点积(乘性)注意力。点积注意力与我们的算法基本相同,唯一区别是缺少 1 d k \frac{1}{\sqrt{d_{k}}} dk1这个缩放因子。加性注意力通过一个包含单个隐藏层的前馈网络来计算兼容性函数。虽然两者在理论复杂度上相近,但在实际应用中,点积注意力速度更快、空间效率更高,因为它可以通过高度优化的矩阵乘法代码实现。
While for small values of d k d_{k} dk the two mechanisms perform similarly, additive attention outperforms dot product attention without scaling for larger values of d k d_{k} dk [3]. We suspect that for large values of d k d_{k} dk, the dot products grow large in magnitude, pushing the softmax function into regions where it has extremely small gradients. To counteract this effect, we scale the dot products by 1 d k \frac{1}{\sqrt{d_{k}}} dk1.
当 d k d_{k} dk的值较小时,这两种机制的表现相近;但当 d k d_{k} dk的值较大时,不加缩放的点积注意力性能会落后于加性注意力[3]。我们推测,当 d k d_{k} dk较大时,点积的数值会变得很大,这会将softmax函数推向梯度极小的区域。为了抵消这种影响,我们用 1 d k \frac{1}{\sqrt{d_{k}}} dk1对点积结果进行缩放。
3.2.2 Multi-Head Attention
Instead of performing a single attention function with d m o d e l d_{model} dmodel-dimensional keys, values and queries, we found it beneficial to linearly project the queries, keys and values h times with different, learned linear projections to d k d_{k} dk, d k d_{k} dk and d v d_{v} dv dimensions, respectively. On each of these projected versions of queries, keys and values we then perform the attention function in parallel, yielding d v d_{v} dv-dimensional output values. These are concatenated and once again projected, resulting in the final values, as depicted in Figure 2.
我们没有使用具有 d m o d e l d_{model} dmodel维度的键、值和查询来执行单一的注意力函数,而是发现通过不同的、经过学习的线性投影,将查询、键和值分别进行h次线性投影,投影到 d k d_k dk、 d k d_k dk和 d v d_v dv维度,会更有益处。然后,我们在这些经过投影的查询、键和值的每个版本上并行执行注意力函数,得到 d v d_v dv维度的输出值。这些输出值被拼接起来并再次进行投影,最终得到结果值,如图2所示。
Multi-head attention allows the model to jointly attend to information from different representation subspaces at different positions. With a single attention head, averaging inhibits this.
多头注意力使模型能够联合关注不同位置上不同表示子空间的信息。而使用单个注意力头时,平均操作会阻碍这一点。
M u l t i H e a d ( Q , K , V ) = C o n c a t ( h e a d 1 , . . . , h e a d h ) W O MultiHead(Q, K, V) = Concat\left(head_1, ..., head_h\right) W^O MultiHead(Q,K,V)=Concat(head1,...,headh)WO
w h e r e h e a d i = A t t e n t i o n ( Q W i Q , K W i K , V W i V ) where\ head_i = Attention\left(Q W_i^Q, K W_i^K, V W_i^V\right) where headi=Attention(QWiQ,KWiK,VWiV)
Where the projections are parameter matrices (其中,投影矩阵为参数矩阵) W i Q ∈ R d m o d e l × d k W_i^Q \in \mathbb{R}^{d_{model} \times d_k} WiQ∈Rdmodel×dk, W i K ∈ R d m o d e l × d k W_i^K \in \mathbb{R}^{d_{model} \times d_k} WiK∈Rdmodel×dk, W i V ∈ R d m o d e l × d v W_i^V \in \mathbb{R}^{d_{model} \times d_v} WiV∈Rdmodel×dv, and W O ∈ R h d v × d m o d e l W^O \in \mathbb{R}^{h d_v \times d_{model}} WO∈Rhdv×dmodel.
In this work we employ h = 8 h=8 h=8 parallel attention layers, or heads. For each of these we use d k = d v = d m o d e l / h = 64 d_k = d_v = d_{model}/h = 64 dk=dv=dmodel/h=64. Due to the reduced dimension of each head, the total computational cost is similar to that of single-head attention with full dimensionality.
在本研究中,我们采用了 h = 8 h=8 h=8个并行的注意力层(即头)。对于每个头,我们设置 d k = d v = d m o d e l / h = 64 d_k = d_v = d_{model}/h = 64 dk=dv=dmodel/h=64。由于每个头的维度降低,总计算成本与使用全维度的单头注意力相近。
3.2.3 Applications of Attention in our Model
The Transformer uses multi-head attention in three different ways:
Transformer通过三种不同方式使用多头注意力:
-
In “encoder-decoder attention” layers, the queries come from the previous decoder layer, and the memory keys and values come from the output of the encoder. This allows every position in the decoder to attend over all positions in the input sequence. This mimics the typical encoder-decoder attention mechanisms in sequence-to-sequence models such as [38, 2, 9].
- 在“编码器-解码器注意力”层中,查询来自前一个解码器层,而记忆的键和值来自编码器的输出。这使得解码器中的每个位置都能关注输入序列中的所有位置。这与[38, 2, 9]等序列到序列模型中典型的编码器-解码器注意力机制类似。
-
The encoder contains self-attention layers. In a self-attention layer all of the keys, values and queries come from the same place, in this case, the output of the previous layer in the encoder. Each position in the encoder can attend to all positions in the previous layer of the encoder.
- 编码器包含自注意力层。在自注意力层中,所有的键、值和查询都来自同一处,在这种情况下,即来自编码器中前一层的输出。编码器中的每个位置都能关注编码器前一层中的所有位置。
-
Similarly, self-attention layers in the decoder allow each position in the decoder to attend to all positions in the decoder up to and including that position. We need to prevent leftward information flow in the decoder to preserve the auto-regressive property. We implement this inside of scaled dot-product attention by masking out (setting to −∞) all values in the input of the softmax which correspond to illegal connections. See Figure 2.
- 类似地,解码器中的自注意力层允许解码器中的每个位置关注解码器中该位置及之前的所有位置。我们需要防止解码器中出现向左的信息流动,以保持自回归特性。我们在缩放点积注意力内部实现了这一点:通过将softmax输入中所有对应非法连接的值屏蔽掉(设为−∞)。见图2。
3.3 Position-wise Feed-Forward Networks
In addition to attention sub-layers, each of the layers in our encoder and decoder contains a fully connected feed-forward network, which is applied to each position separately and identically. This consists of two linear transformations with a ReLU activation in between.
除了注意力子层之外,编码器和解码器中的每个层都包含一个全连接前馈网络,该网络被分别且相同地应用于每个位置。它由两个线性变换组成,中间带有一个ReLU激活函数。
F F N ( x ) = m a x ( 0 , x W 1 + b 1 ) W 2 + b 2 FFN(x) = max\left(0, x W_1 + b_1\right) W_2 + b_2 FFN(x)=max(0,xW1+b1)W2+b2
While the linear transformations are the same across different positions, they use different parameters from layer to layer. Another way of describing this is as two convolutions with kernel size 1. The dimensionality of input and output is d m o d e l = 512 d_{model}=512 dmodel=512, and the inner-layer has dimensionality d f f = 2048 d_{ff}=2048 dff=2048.
虽然不同位置上的线性变换是相同的,但层与层之间使用的参数不同。另一种描述方式是,这相当于两个核大小为1的卷积。输入和输出的维度为 d m o d e l = 512 d_{model}=512 dmodel=512,而内层的维度为 d f f = 2048 d_{ff}=2048 dff=2048。
3.4 Embeddings and Softmax
Similarly to other sequence transduction models, we use learned embeddings to convert the input tokens and output tokens to vectors of dimension d m o d e l d_{model} dmodel. We also use the usual learned linear transformation and softmax function to convert the decoder output to predicted next-token probabilities. In our model, we share the same weight matrix between the two embedding layers and the pre-softmax linear transformation, similar to [30]. In the embedding layers, we multiply those weights by d m o d e l \sqrt{d_{model}} dmodel.
与其他序列转导模型类似,我们使用经过学习的嵌入(embeddings)将输入标记和输出标记转换为 d m o d e l d_{model} dmodel维度的向量。我们还使用常用的经过学习的线性变换和softmax函数,将解码器的输出转换为预测的下一个标记的概率。在我们的模型中,如[30]所述,两个嵌入层和softmax之前的线性变换共享相同的权重矩阵。在嵌入层中,我们将这些权重乘以 d m o d e l \sqrt{d_{model}} dmodel。
Table 1

Table 1: Maximum path lengths, per-layer complexity and minimum number of sequential operations for different layer types. n is the sequence length, d is the representation dimension, k is the kernel size of convolutions and r the size of the neighborhood in restricted self-attention.
表1:不同层类型的最大路径长度、每层复杂度以及最小顺序操作数。其中,n为序列长度,d为表示维度,k为卷积的核大小,r为受限自注意力中的邻域大小。
3.5 Positional Encoding
Since our model contains no recurrence and no convolution, in order for the model to make use of the order of the sequence, we must inject some information about the relative or absolute position of the tokens in the sequence. To this end, we add “positional encodings” to the input embeddings at the bottoms of the encoder and decoder stacks. The positional encodings have the same dimension d m o d e l d_{model} dmodel as the embeddings, so that the two can be summed. There are many choices of positional encodings, learned and fixed [9].
由于我们的模型不包含循环和卷积操作,为了让模型能够利用序列的顺序信息,我们必须注入一些关于序列中标记的相对或绝对位置的信息。为此,我们在编码器和解码器堆叠底部的输入嵌入中添加了“位置编码”。位置编码与嵌入具有相同的维度 d m o d e l d_{model} dmodel,因此两者可以相加。位置编码有多种选择,包括可学习的和固定的[9]。
In this work, we use sine and cosine functions of different frequencies:
在本研究中,我们使用不同频率的正弦和余弦函数:
P
E
(
p
o
s
,
2
i
)
=
sin
(
p
o
s
/
1000
0
2
i
/
d
m
o
d
e
l
)
PE_{(pos, 2i)} = \sin\left(pos / 10000^{2i/d_{model}}\right)
PE(pos,2i)=sin(pos/100002i/dmodel)
P
E
(
p
o
s
,
2
i
+
1
)
=
cos
(
p
o
s
/
1000
0
2
i
/
d
m
o
d
e
l
)
PE_{(pos, 2i+1)} = \cos\left(pos / 10000^{2i/d_{model}}\right)
PE(pos,2i+1)=cos(pos/100002i/dmodel)
where pos is the position and i is the dimension. That is, each dimension of the positional encoding corresponds to a sinusoid. The wavelengths form a geometric progression from
2
π
2\pi
2π to
10000
⋅
2
π
10000 \cdot 2\pi
10000⋅2π. We chose this function because we hypothesized it would allow the model to easily learn to attend by relative positions, since for any fixed offset k,
P
E
p
o
s
+
k
PE_{pos+k}
PEpos+k can be represented as a linear function of
P
E
p
o
s
PE_{pos}
PEpos.
其中,pos表示位置,i表示维度。也就是说,位置编码的每个维度都对应一个正弦曲线。波长从 2 π 2\pi 2π到 10000 ⋅ 2 π 10000 \cdot 2\pi 10000⋅2π形成几何级数。我们选择这个函数是因为我们推测,它能让模型更容易学习通过相对位置进行关注,因为对于任何固定偏移k, P E p o s + k PE_{pos+k} PEpos+k都可以表示为 P E p o s PE_{pos} PEpos的线性函数。
We also experimented with using learned positional embeddings [9] instead, and found that the two versions produced nearly identical results (see Table 3 row (E)). We chose the sinusoidal version because it may allow the model to extrapolate to sequence lengths longer than the ones encountered during training.
我们也尝试过使用可学习的位置嵌入[9],发现这两种方式产生的结果几乎相同(见表3第(E)行)。我们选择正弦曲线版本是因为它可能使模型能够外推到比训练过程中遇到的更长的序列长度。
4. Why Self-Attention
In this section we compare various aspects of self-attention layers to the recurrent and convolutional layers commonly used for mapping one variable-length sequence of symbol representations ( x 1 , . . . , x n ) (x_{1}, ..., x_{n}) (x1,...,xn) to another sequence of equal length ( z 1 , . . . , z n ) (z_{1}, ..., z_{n}) (z1,...,zn), with x i , z i ∈ R d x_{i}, z_{i} \in \mathbb{R}^{d} xi,zi∈Rd, such as a hidden layer in a typical sequence transduction encoder or decoder. Motivating our use of self-attention we consider three desiderata.
在本节中,我们将自注意力层的各个方面与常用于将一个变长符号表示序列 ( x 1 , . . . , x n ) (x_{1}, ..., x_{n}) (x1,...,xn)映射到另一个等长序列 ( z 1 , . . . , z n ) (z_{1}, ..., z_{n}) (z1,...,zn)(其中 x i , z i ∈ R d x_{i}, z_{i} \in \mathbb{R}^{d} xi,zi∈Rd)的循环层和卷积层进行比较,这类映射常见于典型序列转导模型的编码器或解码器中的隐藏层。为说明我们使用自注意力的原因,我们考虑了三个期望目标。
One is the total computational complexity per layer. Another is the amount of computation that can be parallelized, as measured by the minimum number of sequential operations required.
第一个是每层的总计算复杂度。第二个是可并行化的计算量,以所需的最小顺序操作数来衡量。
The third is the path length between long-range dependencies in the network. Learning long-range dependencies is a key challenge in many sequence transduction tasks. One key factor affecting the ability to learn such dependencies is the length of the paths forward and backward signals have to traverse in the network. The shorter these paths between any combination of positions in the input and output sequences, the easier it is to learn long-range dependencies [12]. Hence we also compare the maximum path length between any two input and output positions in networks composed of the different layer types.
第三个是网络中长距离依赖之间的路径长度。学习长距离依赖是许多序列转导任务中的关键挑战。影响学习此类依赖能力的一个关键因素是前向和后向信号在网络中必须经过的路径长度。输入和输出序列中任意位置组合之间的路径越短,就越容易学习长距离依赖[12]。因此,我们还比较了由不同层类型组成的网络中任意两个输入和输出位置之间的最大路径长度。
As noted in Table 1, a self-attention layer connects all positions with a constant number of sequentially executed operations, whereas a recurrent layer requires O ( n ) O(n) O(n) sequential operations. In terms of computational complexity, self-attention layers are faster than recurrent layers when the sequence length n n n is smaller than the representation dimensionality d d d, which is most often the case with sentence representations used by state-of-the-art models in machine translations, such as word-piece [38] and byte-pair [31] representations. To improve computational performance for tasks involving very long sequences, self-attention could be restricted to considering only a neighborhood of size r r r in the input sequence centered around the respective output position. This would increase the maximum path length to O ( n / r ) O(n/r) O(n/r). We plan to investigate this approach further in future work.
如表1所示,自注意力层通过恒定数量的顺序执行操作连接所有位置,而循环层需要 O ( n ) O(n) O(n)次顺序操作。就计算复杂度而言,当序列长度 n n n小于表示维度 d d d时,自注意力层比循环层更快——在机器翻译的最先进模型中,使用词片段[38]和字节对[31]等表示时,情况大多如此。为了提高涉及极长序列任务的计算性能,自注意力可被限制为仅考虑输入序列中以相应输出位置为中心、大小为 r r r的邻域。这会将最大路径长度增加到 O ( n / r ) O(n/r) O(n/r)。我们计划在未来的工作中进一步研究这种方法。
A single convolutional layer with kernel width k < n k < n k<n does not connect all pairs of input and output positions. Doing so requires a stack of O ( n / k ) O(n/k) O(n/k) convolutional layers in the case of contiguous kernels, or O ( l o g k ( n ) ) O(log_{k}(n)) O(logk(n)) in the case of dilated convolutions [18], increasing the length of the longest paths between any two positions in the network. Convolutional layers are generally more expensive than recurrent layers, by a factor of k k k. Separable convolutions [6], however, decrease the complexity considerably, to O ( k ⋅ n ⋅ d + n ⋅ d 2 ) O(k \cdot n \cdot d + n \cdot d^{2}) O(k⋅n⋅d+n⋅d2). Even with k = n k = n k=n, however, the complexity of a separable convolution is equal to the combination of a self-attention layer and a point-wise feed-forward layer, the approach we take in our model.
核宽为 k < n k < n k<n的单个卷积层无法连接所有输入和输出位置对。要实现这一点,对于连续核,需要堆叠 O ( n / k ) O(n/k) O(n/k)个卷积层;对于扩张卷积[18],则需要 O ( l o g k ( n ) ) O(log_{k}(n)) O(logk(n))个,这会增加网络中任意两个位置之间最长路径的长度。卷积层的计算成本通常比循环层高 k k k倍。然而,可分离卷积[6]将复杂度显著降低至 O ( k ⋅ n ⋅ d + n ⋅ d 2 ) O(k \cdot n \cdot d + n \cdot d^{2}) O(k⋅n⋅d+n⋅d2)。但即使 k = n k = n k=n,可分离卷积的复杂度也与自注意力层和逐点前馈层的组合(即我们模型中采用的方法)相当。
As a side benefit, self-attention could yield more interpretable models. We inspect attention distributions from our models and present and discuss examples in the appendix. Not only do individual attention heads clearly learn to perform different tasks, many appear to exhibit behavior related to the syntactic and semantic structure of the sentences.
作为附加优势,自注意力可能产生更具可解释性的模型。我们检查了模型的注意力分布,并在附录中展示和讨论了示例。各个注意力头不仅明显学会了执行不同的任务,许多还表现出与句子的句法和语义结构相关的行为。
5. Training
This section describes the training regime for our models.
本节介绍我们模型的训练方案。
5.1 Training Data and Batching
We trained on the standard WMT 2014 English-German dataset consisting of about 4.5 million sentence pairs. Sentences were encoded using byte-pair encoding [3], which has a shared source-target vocabulary of about 37000 tokens. For English-French, we used the significantly larger WMT 2014 English-French dataset consisting of 36M sentences and split tokens into a 32000 word-piece vocabulary [38]. Sentence pairs were batched together by approximate sequence length. Each training batch contained a set of sentence pairs containing approximately 25000 source tokens and 25000 target tokens.
我们在标准的WMT 2014英德数据集上训练模型,该数据集包含约450万句对。句子采用字节对编码(byte-pair encoding)[3]进行编码,源语言和目标语言共享一个约37000个标记的词汇表。对于英法翻译任务,我们使用了规模大得多的WMT 2014英法数据集,该数据集包含3600万句对,并将标记拆分为32000个词片段(word-piece)词汇表[38]。句子对按近似序列长度进行批处理,每个训练批次包含的句对集中,源语言标记和目标语言标记各约25000个。
5.2 Hardware and Schedule
We trained our models on one machine with 8 NVIDIA P100 GPUs. For our base models using the hyperparameters described throughout the paper, each training step took about 0.4 seconds. We trained the base models for a total of 100,000 steps or 12 hours. For our big models, (described on the bottom line of table 3), step time was 1.0 seconds. The big models were trained for 300,000 steps (3.5 days).
我们在一台配备8块NVIDIA P100 GPU的机器上训练模型。对于使用本文所述超参数的基础模型,每个训练步骤约耗时0.4秒,基础模型共训练100,000步(即12小时)。对于大型模型(如表3最后一行所述),每个步骤耗时1.0秒,共训练300,000步(即3.5天)。
5.3 Optimizer
We used the Adam optimizer [20] with
β
1
=
0.9
\beta_{1}=0.9
β1=0.9,
β
2
=
0.98
\beta_{2}=0.98
β2=0.98 and
ϵ
=
1
0
−
9
\epsilon=10^{-9}
ϵ=10−9. We varied the learning rate over the course of training, according to the formula:
l
r
a
t
e
=
d
m
o
d
e
l
−
0.5
⋅
m
i
n
(
s
t
e
p
_
n
u
m
−
0.5
,
s
t
e
p
_
n
u
m
⋅
w
a
r
m
u
p
_
s
t
e
p
s
−
1.5
)
(
3
)
lrate = d_{model}^{-0.5} \cdot min\left(step\_num^{-0.5}, step\_num \cdot warmup\_steps^{-1.5}\right) \quad (3)
lrate=dmodel−0.5⋅min(step_num−0.5,step_num⋅warmup_steps−1.5)(3)
我们使用Adam优化器[20],参数设置为
β
1
=
0.9
\beta_{1}=0.9
β1=0.9、
β
2
=
0.98
\beta_{2}=0.98
β2=0.98和
ϵ
=
1
0
−
9
\epsilon=10^{-9}
ϵ=10−9。在训练过程中,我们根据以下公式调整学习率:
l
r
a
t
e
=
d
m
o
d
e
l
−
0.5
⋅
m
i
n
(
s
t
e
p
_
n
u
m
−
0.5
,
s
t
e
p
_
n
u
m
⋅
w
a
r
m
u
p
_
s
t
e
p
s
−
1.5
)
(
3
)
lrate = d_{model}^{-0.5} \cdot min\left(step\_num^{-0.5}, step\_num \cdot warmup\_steps^{-1.5}\right) \quad (3)
lrate=dmodel−0.5⋅min(step_num−0.5,step_num⋅warmup_steps−1.5)(3)
This corresponds to increasing the learning rate linearly for the first warmup_steps training steps, and decreasing it thereafter proportionally to the inverse square root of the step number. We used warmup_steps = 4000.
这意味着在最初的warmup_steps训练步骤中,学习率线性增长;之后,学习率与步骤数的平方根成反比下降。我们设置warmup_steps = 4000。
5.4 Regularization
We employ three types of regularization during training:
Residual Dropout We apply dropout [33] to the output of each sub-layer, before it is added to the sub-layer input and normalized. In addition, we apply dropout to the sums of the embeddings and the positional encodings in both the encoder and decoder stacks. For the base model, we use a rate of
P
d
r
o
p
=
0.1
P_{drop}=0.1
Pdrop=0.1.
我们在训练过程中采用了三种正则化方法:
残差 dropout:在每个子层的输出与子层输入相加并进行归一化之前,我们对该输出应用 dropout 操作[33]。此外,我们还对编码器和解码器堆叠中嵌入与位置编码的总和应用 dropout。对于基础模型,我们使用的 dropout 率为
P
d
r
o
p
=
0.1
P_{drop}=0.1
Pdrop=0.1。
Label Smoothing During training, we employed label smoothing of value ϵ l s = 0.1 \epsilon_{ls}=0.1 ϵls=0.1 [36]. This hurts perplexity, as the model learns to be more unsure, but improves accuracy and BLEU score.
标签平滑:训练过程中,我们采用了值为 ϵ l s = 0.1 \epsilon_{ls}=0.1 ϵls=0.1的标签平滑[36]。这会降低困惑度(因为模型会学得更不确定),但能提高准确率和 BLEU 分数。
6. Results
6.1 Machine Translation
On the WMT 2014 English-to-German translation task, the big transformer model (Transformer (big) in Table 2) outperforms the best previously reported models (including ensembles) by more than 2.0 BLEU, establishing a new state-of-the-art BLEU score of 28.4. The configuration of this model is listed in the bottom line of Table 3. Training took 3.5 days on 8 P100 GPUs. Even our base model surpasses all previously published models and ensembles, at a fraction of the training cost of any of the competitive models.
在WMT 2014英德翻译任务中,大型Transformer模型(表2中的Transformer (big))的表现超过了所有此前报道的最佳模型(包括集成模型),BLEU得分提升超过2.0,创下28.4的新纪录。该模型的配置详见表3最后一行。其训练在8块P100 GPU上进行,耗时3.5天。即便我们的基础模型,也超越了所有已发表的模型及集成模型,且训练成本仅为其他竞争模型的一小部分。
On the WMT 2014 English-to-French translation task, our big model achieves a BLEU score of 41.0, outperforming all of the previously published single models, at less than 1/4 the training cost of the previous state-of-the-art model. The Transformer (big) model trained for English-to-French used dropout rate P d r o p = 0.1 P_{drop }=0.1 Pdrop=0.1 , instead of 0.3.
在WMT 2014英法翻译任务中,我们的大型模型取得了41.0的BLEU得分,超越了所有已发表的单一模型,而训练成本不到此前最先进模型的1/4。用于英法翻译训练的Transformer(big)模型采用的dropout率为 P d r o p = 0.1 P_{drop}=0.1 Pdrop=0.1,而非0.3。
For the base models, we used a single model obtained by averaging the last 5 checkpoints, which were written at 10-minute intervals. For the big models, we averaged the last 20 checkpoints. We used beam search with a beam size of 4 and length penalty α = 0.6 \alpha=0.6 α=0.6 [38]. These hyperparameters were chosen after experimentation on the development set. We set the maximum output length during inference to input length + 50, but terminate early when possible [38].
对于基础模型,我们通过对最后5个检查点(每隔10分钟保存一次)取平均得到单一模型。对于大型模型,我们对最后20个检查点取平均。我们使用 beam 搜索,beam 大小设为4,长度惩罚系数 α = 0.6 \alpha=0.6 α=0.6 [38]。这些超参数是在开发集上经过实验后选定的。推理时,我们将最大输出长度设为输入长度+50,但在可能的情况下会提前终止生成[38]。
Table 2 summarizes our results and compares our translation quality and training costs to other model architectures from the literature. We estimate the number of floating point operations used to train a model by multiplying the training time, the number of GPUs used, and an estimate of the sustained single-precision floating-point capacity of each G P U 5 GPU ^{5} GPU5 .
表2总结了我们的结果,并将我们的翻译质量和训练成本与文献中其他模型架构进行了对比。我们通过将训练时间、所用GPU数量以及每块GPU的持续单精度浮点运算能力估算值相乘,来估计训练一个模型所需的浮点运算次数⁵。
Table 2

Table 2: The Transformer achieves better BLEU scores than previous state-of-the-art models on the English-to-German and English-to-French newstest2014 tests at a fraction of the training cost.
表2:在newstest2014的英德和英法翻译测试中,Transformer的BLEU得分优于以往的最先进模型,且训练成本仅为其一小部分。
6.2 Model Variations
To evaluate the importance of different components of the Transformer, we varied our base model in different ways, measuring the change in performance on English-to-German translation on the development set, newstest2013. We used beam search as described in the previous section, but no checkpoint averaging. We present these results in Table 3.
为评估Transformer不同组件的重要性,我们以不同方式调整了基础模型,并在开发集newstest2013上的英德翻译任务中衡量性能变化。我们使用了前一节所述的波束搜索,但未进行检查点平均。结果如表3所示。
Table 3

Table 3: Variations on the Transformer architecture. Unlisted values are identical to those of the base model. All metrics are on the English-to-German translation development set, newstest2013. Listed perplexities are per-wordpiece, according to our byte-pair encoding, and should not be compared to per-word perplexities.
表3:Transformer架构的变体。未列出的值与基础模型相同。所有指标均基于英德翻译开发集newstest2013。列出的困惑度是基于我们字节对编码的每个词片段的困惑度,不应与每个单词的困惑度进行比较。
In Table 3 rows (A), we vary the number of attention heads and the attention key and value dimensions, keeping the amount of computation constant, as described in Section 3.2.2. While single-head attention is 0.9 BLEU worse than the best setting, quality also drops off with too many heads.
表3的(A)行中,我们按照3.2.2节所述,在保持计算量不变的情况下,调整了注意力头的数量以及注意力键和值的维度。单头注意力的表现比最佳设置低0.9个BLEU值,而头数过多时,性能同样会下降。
In Table 3 rows (B), we observe that reducing the attention key size d k d_{k} dk hurts model quality. This suggests that determining compatibility is not easy and that a more sophisticated compatibility function than dot product may be beneficial. We further observe in rows © and (D) that, as expected, bigger models are better, and dropout is very helpful in avoiding over-fitting. In row (E) we replace our sinusoidal positional encoding with learned positional embeddings [9], and observe nearly identical results to the base model.
表3的(B)行中,我们发现减小注意力键的维度 d k d_k dk会损害模型性能。这表明确定兼容性并非易事,或许采用比点积更复杂的兼容性函数会更有利。我们在(C)行和(D)行中进一步观察到,正如预期的那样,更大的模型性能更优,且dropout在避免过拟合方面作用显著。在(E)行中,我们用可学习的位置嵌入[9]替代了正弦位置编码,发现其结果与基础模型几乎一致。
6.3 English Constituency Parsing
原文:
To evaluate if the Transformer can generalize to other tasks we performed experiments on English constituency parsing. This task presents specific challenges: the output is subject to strong structural constraints and is significantly longer than the input. Furthermore, RNN sequence - to - sequence models have not been able to attain state - of - the - art results in small - data regimes [37].
为了评估Transformer是否能够泛化到其他任务,我们在英语成分句法分析任务上进行了实验。这项任务具有特定的挑战性:其输出受到强烈的结构约束,并且输出长度明显长于输入。此外,循环神经网络(RNN)的序列到序列模型在小数据情况下无法取得最先进的结果。
We performed only a small number of experiments to select the dropout, both attention and residual (section 5.4), learning rates and beam size on the Section 22 development set, all other parameters remained unchanged from the English - to - German base translation model. During inference, we increased the maximum output length to input length + 300. We used a beam size of 21 and α = 0.3 \alpha = 0.3 α=0.3 for both WSJ only and the semi - supervised setting.
我们仅进行了少量实验,以在第22节的开发集上选择注意力和残差的 dropout 率(5.4节)、学习率和束宽,其他所有参数都与英德基础翻译模型保持不变。在推理过程中,我们将最大输出长度增加到输入长度加300。对于仅使用《华尔街日报》数据和半监督这两种设置,我们都使用了束宽为21和 α = 0.3 \alpha = 0.3 α=0.3。
Our results in Table 4 show that despite the lack of task - specific tuning our model performs surprisingly well, yielding better results than all previously reported models with the exception of the Recurrent Neural Network Grammar [8].
Table 4

Table 4: The Transformer generalizes well to English constituency parsing (Results are on Section 23 of WSJ)
我们在表4中的结果表明,尽管缺乏针对特定任务的调优,我们的模型表现得却出奇地好,除了递归神经网络语法(Recurrent Neural Network Grammar)之外,其结果比之前所有报道过的模型都要好。
We trained a 4 - layer transformer with d m o d e l = 1024 d_{model }=1024 dmodel=1024 on the Wall Street Journal (WSJ) portion of the Penn Treebank [25], about 40K training sentences. We also trained it in a semi - supervised setting, using the larger high - confidence and BerkleyParser corpora from with approximately 17M sentences [37]. We used a vocabulary of 16K tokens for the WSJ only setting and a vocabulary of 32K tokens for the semi - supervised setting.
我们在宾州树库(Penn Treebank)的《华尔街日报》(WSJ)部分数据上训练了一个4层的Transformer,其 d m o d e l = 1024 d_{model }=1024 dmodel=1024,大约有4万个训练句子。我们还在半监督设置下对其进行了训练,使用了更大的高可信度语料库和伯克利解析器(BerkleyParser)语料库,其中包含约1700万个句子。对于仅使用《华尔街日报》数据的设置,我们使用了1.6万个词元的词汇表,而对于半监督设置,我们使用了3.2万个词元的词汇表。
In contrast to RNN sequence - to - sequence models [37], the Transformer outperforms the BerkeleyParser [29] even when training only on the WSJ training set of 40K sentences.
与RNN序列到序列模型相比,即使仅在4万个句子的《华尔街日报》训练集上进行训练,Transformer的表现也优于伯克利解析器(BerkeleyParser)。
7. Conclusion
In this work, we presented the Transformer, the first sequence transduction model based entirely on attention, replacing the recurrent layers most commonly used in encoder-decoder architectures with multi-headed self-attention.
在本研究中,我们提出了Transformer,这是首个完全基于注意力机制的序列转导模型,它用多头自注意力取代了编码器-解码器架构中最常用的循环层。
For translation tasks, the Transformer can be trained significantly faster than architectures based on recurrent or convolutional layers. On both WMT 2014 English-to-German and WMT 2014 English-to-French translation tasks, we achieve a new state of the art. In the former task our best model outperforms even all previously reported ensembles.
在翻译任务中,Transformer的训练速度明显快于基于循环层或卷积层的架构。在WMT 2014英德和WMT 2014英法翻译任务中,我们都达到了新的最先进水平。在前者任务中,我们的最佳模型甚至超越了所有此前报道的集成模型。
We are excited about the future of attention-based models and plan to apply them to other tasks. We plan to extend the Transformer to problems involving input and output modalities other than text and to investigate local, restricted attention mechanisms to efficiently handle large inputs and outputs such as images, audio and video. Making generation less sequential is another research goals of ours. The code we used to train and evaluate our models is available at https://github.com/tensorflow/tensor2tensor.
我们对基于注意力机制的模型的未来充满期待,并计划将其应用于其他任务。我们计划将Transformer扩展到涉及文本之外的输入和输出模态的问题中,并研究局部、受限的注意力机制,以高效处理大型输入和输出(如图像、音频和视频)。降低生成过程的序列性是我们的另一项研究目标。我们用于训练和评估模型的代码可在https://github.com/tensorflow/tensor2tensor获取。
Acknowledgements
We are grateful to Nal Kalchbrenner and Stephan Gouws for their fruitful comments, corrections and inspiration.
致谢: 我们感谢Nal Kalchbrenner和Stephan Gouws富有成效的评论、修正和启发。
Figure 4 Attention Visualizations Input-Input Layer5

Figure 3: An example of the attention mechanism following long-distance dependencies in the encoder self-attention in layer 5 of 6. Many of the attention heads attend to a distant dependency of the verb ‘making’, completing the phrase ‘making…more difficult’. Attentions here shown only for the word ‘making’. Different colors represent different heads. Best viewed in color.
图3:在6层编码器的第5层自注意力中,注意力机制捕捉长距离依赖的示例。多个注意力头关注动词“making”的远距离依赖,以补全短语“making…more difficult”。此处仅展示“making”一词的注意力分布。不同颜色代表不同的注意力头。建议以彩色模式查看。
References
- [1] Jimmy Lei Ba, Jamie Ryan Kiros, and Geoffrey E Hinton. 《Layer normalization》(层归一化). arXiv preprint arXiv:1607.06450, 2016.
- [2] Dzmitry Bahdanau, Kyunghyun Cho, and Yoshua Bengio. 《Neural machine translation by jointly learning to align and translate》(通过联合学习对齐和翻译实现神经机器翻译). CoRR, abs/1409.0473, 2014.
- [3] Denny Britz, Anna Goldie, Minh-Thang Luong, and Quoc V. Le. 《Massive exploration of neural machine translation architectures》(神经机器翻译架构的大规模探索). CoRR, abs/1703.03906, 2017.
- [4] Jianpeng Cheng, Li Dong, and Mirella Lapata. 《Long short-term memory-networks for machine reading》(用于机器阅读的长短期记忆网络). arXiv preprint arXiv:1601.06733, 2016.
- [5] Kyunghyun Cho, Bart van Merrienboer, Caglar Gulcehre, Fethi Bougares, Holger Schwenk, and Yoshua Bengio. 《Learning phrase representations using rnn encoder-decoder for statistical machine translation》(使用RNN编码器-解码器学习短语表示用于统计机器翻译). CoRR, abs/1406.1078, 2014.
- [6] Francois Chollet. 《Xception: Deep learning with depthwise separable convolutions》(Xception:基于深度可分离卷积的深度学习). arXiv preprint arXiv:1610.02357, 2016.
- [7] Junyoung Chung, Çaglar Gülçehre, Kyunghyun Cho, and Yoshua Bengio. 《Empirical evaluation of gated recurrent neural networks on sequence modeling》(门控循环神经网络在序列建模上的实证评估). CoRR, abs/1412.3555, 2014.
- [8] Chris Dyer, Adhiguna Kuncoro, Miguel Ballesteros, and Noah A. Smith. 《Recurrent neural network grammars》(循环神经网络语法). In Proc. of NAACL, 2016.
- [9] Jonas Gehring, Michael Auli, David Grangier, Denis Yarats, and Yann N. Dauphin. 《Convolutional sequence to sequence learning》(卷积序列到序列学习). arXiv preprint arXiv:1705.03122v2, 2017.
- [10] Alex Graves. 《Generating sequences with recurrent neural networks》(使用循环神经网络生成序列). arXiv preprint arXiv:1308.0850, 2013.
- [11] Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. 《Deep residual learning for image recognition》(用于图像识别的深度残差学习). In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 770–778, 2016.
- [12] Sepp Hochreiter, Yoshua Bengio, Paolo Frasconi, and Jürgen Schmidhuber. 《Gradient flow in recurrent nets: the difficulty of learning long-term dependencies》(循环网络中的梯度流:学习长程依赖的难点), 2001.
- [13] Sepp Hochreiter and Jürgen Schmidhuber. 《Long short-term memory》(长短期记忆). Neural computation, 9(8):1735–1780, 1997.
- [14] Zhongqiang Huang and Mary Harper. 《Self-training PCFG grammars with latent annotations across languages》(跨语言带潜在标注的PCFG语法自训练). In Proceedings of the 2009 Conference on Empirical Methods in Natural Language Processing, pages 832–841. ACL, August 2009.
- [15] Rafal Jozefowicz, Oriol Vinyals, Mike Schuster, Noam Shazeer, and Yonghui Wu. 《Exploring the limits of language modeling》(探索语言建模的极限). arXiv preprint arXiv:1602.02410, 2016.
- [16] Łukasz Kaiser and Samy Bengio. 《Can active memory replace attention?》(主动记忆能否替代注意力?). In Advances in Neural Information Processing Systems, (NIPS), 2016.
- [17] Łukasz Kaiser and Ilya Sutskever. 《Neural GPUs learn algorithms》(神经GPU学习算法). In International Conference on Learning Representations (ICLR), 2016.
- [18] Nal Kalchbrenner, Lasse Espeholt, Karen Simonyan, Aaron van den Oord, Alex Graves, and Koray Kavukcuoglu. 《Neural machine translation in linear time》(线性时间的神经机器翻译). arXiv preprint arXiv:1610.10099v2, 2017.
- [19] Yoon Kim, Carl Denton, Luong Hoang, and Alexander M. Rush. 《Structured attention networks》(结构化注意力网络). In International Conference on Learning Representations, 2017.
- [20] Diederik Kingma and Jimmy Ba. 《Adam: A method for stochastic optimization》(Adam:一种随机优化方法). In ICLR, 2015.
- [21] Oleksii Kuchaiev and Boris Ginsburg. 《Factorization tricks for LSTM networks》(LSTM网络的因式分解技巧). arXiv preprint arXiv:1703.10722, 2017.
- [22] Zhouhan Lin, Minwei Feng, Cicero Nogueira dos Santos, Mo Yu, Bing Xiang, Bowen Zhou, and Yoshua Bengio. 《A structured self-attentive sentence embedding》(一种结构化自注意力句子嵌入). arXiv preprint arXiv:1703.03130, 2017.
- [23] Minh-Thang Luong, Quoc V. Le, Ilya Sutskever, Oriol Vinyals, and Lukasz Kaiser. 《Multi-task sequence to sequence learning》(多任务序列到序列学习). arXiv preprint arXiv:1511.06114, 2015.
- [24] Minh-Thang Luong, Hieu Pham, and Christopher D Manning. 《Effective approaches to attention-based neural machine translation》(基于注意力的神经机器翻译的有效方法). arXiv preprint arXiv:1508.04025, 2015.
- [25] Mitchell P Marcus, Mary Ann Marcinkiewicz, and Beatrice Santorini. 《Building a large annotated corpus of english: The penn treebank》(构建大型英语标注语料库:宾州树库). Computational linguistics, 19(2):313–330, 1993.
- [26] David McClosky, Eugene Charniak, and Mark Johnson. 《Effective self-training for parsing》(用于句法分析的有效自训练). In Proceedings of the Human Language Technology Conference of the NAACL, Main Conference, pages 152–159. ACL, June 2006.
- [27] Ankur Parikh, Oscar Täckström, Dipanjan Das, and Jakob Uszkoreit. 《A decomposable attention model》(一种可分解的注意力模型). In Empirical Methods in Natural Language Processing, 2016.
- [28] Romain Paulus, Caiming Xiong, and Richard Socher. 《A deep reinforced model for abstractive summarization》(用于抽象式摘要的深度强化模型). arXiv preprint arXiv:1705.04304, 2017.
- [29] Slav Petrov, Leon Barrett, Romain Thibaux, and Dan Klein. 《Learning accurate, compact, and interpretable tree annotation》(学习准确、紧凑且可解释的树标注). In Proceedings of the 21st International Conference on Computational Linguistics and 44th Annual Meeting of the ACL, pages 433–440. ACL, July 2006.
- [30] Ofir Press and Lior Wolf. 《Using the output embedding to improve language models》(使用输出嵌入改进语言模型). arXiv preprint arXiv:1608.05859, 2016.
- [31] Rico Sennrich, Barry Haddow, and Alexandra Birch. 《Neural machine translation of rare words with subword units》(使用子词单元的稀有词神经机器翻译). arXiv preprint arXiv:1508.07909, 2015.
- [32] Noam Shazeer, Azalia Mirhoseini, Krzysztof Maziarz, Andy Davis, Quoc Le, Geoffrey Hinton, and Jeff Dean. 《Outrageously large neural networks: The sparsely-gated mixture-of-experts layer》(超大神经网络:稀疏门控混合专家层). arXiv preprint arXiv:1701.06538, 2017.
- [33] Nitish Srivastava, Geoffrey E Hinton, Alex Krizhevsky, Ilya Sutskever, and Ruslan Salakhutdinov. 《Dropout: a simple way to prevent neural networks from overfitting》(Dropout:一种防止神经网络过拟合的简单方法). Journal of Machine Learning Research, 15(1):1929–1958, 2014.
- [34] Sainbayar Sukhbaatar, Arthur Szlam, Jason Weston, and Rob Fergus. 《End-to-end memory networks》(端到端记忆网络). In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors, Advances in Neural Information Processing Systems 28, pages 2440–2448. Curran Associates, Inc., 2015.
- [35] Ilya Sutskever, Oriol Vinyals, and Quoc VV Le. 《Sequence to sequence learning with neural networks》(基于神经网络的序列到序列学习). In Advances in Neural Information Processing Systems, pages 3104–3112, 2014.
- [36] Christian Szegedy, Vincent Vanhoucke, Sergey Ioffe, Jonathon Shlens, and Zbigniew Wojna. 《Rethinking the inception architecture for computer vision》(重新思考计算机视觉中的Inception架构). CoRR, abs/1512.00567, 2015.
- [37] Vinyals & Kaiser, Koo, Petrov, Sutskever, and Hinton. 《Grammar as a foreign language》(语法作为一门外语). In Advances in Neural Information Processing Systems, 2015.
- [38] Yonghui Wu, Mike Schuster, Zhifeng Chen, Quoc V Le, Mohammad Norouzi, Wolfgang Macherey, Maxim Krikun, Yuan Cao, Qin Gao, Klaus Macherey, et al. 《Google’s neural machine translation system: Bridging the gap between human and machine translation》(谷歌神经机器翻译系统:弥合人机翻译差距). arXiv preprint arXiv:1609.08144, 2016.
- [39] Jie Zhou, Ying Cao, Xuguang Wang, Peng Li, and Wei Xu. 《Deep recurrent models with fast-forward connections for neural machine translation》(带快进连接的深度循环模型用于神经机器翻译). CoRR, abs/1606.04199, 2016.
- [40] Muhua Zhu, Yue Zhang, Wenliang Chen, Min Zhang, and Jingbo Zhu. 《Fast and accurate shift-reduce constituent parsing》(快速准确的移进-归约成分句法分析). In Proceedings of the 51st Annual Meeting of the ACL (Volume 1: Long Papers), pages 434–443. ACL, August 2013.

2338

被折叠的 条评论
为什么被折叠?



