Attention Is All You Need

Ashish Vaswani 等 · NeurIPS 2017 · arXiv:1706.03762
示例页:仅节选《Attention Is All You Need》的摘要与引言,用于展示版式与标注方式。实际运行 ReadPapers 时会覆盖论文全文的每一个章节。

摘要

The dominant sequence transduction models are based on complex recurrent or convolutional neural networks in an encoder-decoder configuration. 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.

我们提出一种全新而简洁的网络架构:Transformer,它完全建立在注意力机制之上,彻底舍弃了循环与卷积。

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.

在两个机器翻译任务上的实验表明,这类模型的质量更优,同时更易并行、训练时间显著更短。我们的模型在 WMT 2014 英德翻译任务上取得 28.4 BLEU,超过此前最佳结果(包括集成模型)2 BLEU 以上。在 WMT 2014 英法翻译任务上,模型在 8 块 GPU 上训练 3.5 天后,取得 41.8 BLEU 的单模型新纪录,而这只是文献中最佳模型训练成本的一小部分。

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 成功应用于英语成分句法分析,分别使用大规模与有限规模的训练数据,说明它能较好地泛化到其他任务。

引言(节选)

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].

循环神经网络,尤其是长短期记忆网络 [13] 与门控循环神经网络 [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 ht, as a function of the previous hidden state ht−1 and the input for position 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.

循环模型通常沿输入与输出序列的符号位置分解计算。它们把位置对齐到计算时间步,生成一串隐藏状态 ht,其取值取决于上一隐藏状态 ht−1 与位置 t 的输入。这种固有的顺序性使得训练样本内部无法并行,而在序列变长时尤为关键,因为显存限制会制约跨样本的批处理。近期工作通过分解技巧 [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 小时,就能达到翻译质量的新最先进水平。

论证结构总览

1

问题

循环与卷积架构的顺序计算无法在训练样本内并行,长序列时受显存限制,成为效率瓶颈。

2

论点

仅依赖注意力机制的 Transformer 可以完全舍弃循环与卷积,同时提升翻译质量与并行度。

3

方法

以注意力机制直接刻画输入与输出之间的全局依赖,不再借助循环或卷积。

4

证据

WMT14 英德 28.4 BLEU(超此前最佳含集成 2 BLEU 以上);英法 41.8 BLEU;8 GPU 训练 3.5 天;引言称 8 块 P100 上最快 12 小时达到新 SOTA。

5

反驳/让步

承认注意力此前通常与循环网络结合,顺序计算的根本约束仍在;作者以「少数例外」与局部改进界定自己的创新空间。

6

结论

注意力可以独立构成强序列转导模型:质量更高、更易并行、训练成本更低,并可迁移到其他任务。

核心主张(一句话)去掉循环与卷积、只保留注意力的 Transformer,能在翻译质量、并行度和训练成本三方面同时胜出。
论证最强处摘要把主张直接落到可核对的数字上:28.4 / 41.8 BLEU、超过含集成基线 2 BLEU 以上、8 GPU 3.5 天,证据与主张的对应关系清晰。
论证最弱处「generalizes well to other tasks」仅以英语成分句法分析一项任务佐证,节选未给出该任务指标;12 小时与 3.5 天两个训练成本来自不同设定,引用时需核对条件。