论文精读:Attention Is All You Need
论文原名:Attention Is All You Need 作者团队:Google Brain (Ashish Vaswani, Noam Shazeer 等) 发表年份:2017 (NIPS) 地位:深度学习历史上最重要的论文之一,提出的 Transformer 架构开启了如今的大模型时代(GPT, BERT, Claude 等均源于此)。
导读:阅读指南
在 Transformer 出现之前,处理语言任务主要靠 RNN(循环神经网络)或 CNN(卷积神经网络)。
- RNN 像接力赛跑者,必须串行处理,速度慢。
- Transformer 不需要递归和卷积,只需要注意力机制。这好比预制板技术,可以并行组装,速度快且结构稳固。
1. Abstract (摘要)
原文核心: "We propose a new simple network architecture, the Transformer, based solely on attention mechanisms, dispensing with recurrence and convolutions entirely."
解读:
- 抛弃旧皇:不再使用 RNN 和 CNN。
- 拥立新王:提出 Transformer,完全基于 Attention。
- 战绩:在 WMT 2014 英语 - 德语翻译任务上拿到 28.4 BLEU 分(当时历史最高),训练时间仅需 3.5 天。
划重点:
- 并行化:最大的卖点。Transformer 可一次性计算整个句子,无需串行。
- 质量更优:不仅快,翻译准确率也更高。
2. Introduction (引言)
原文核心: "Recurrent models typically factor computation along the symbol positions of the input and output sequences… This inherently precludes parallelization within training examples."
解读: 作者详细分析了 RNN(包括 LSTM 和 GRU)的痛点:
- 无法并行:第 N 个词的处理依赖前一个词的记忆,无法并行计算。
- 长距离遗忘:读到第 1000 个字时,可能已忘记第 1 个字的信息。
Transformer 的方案:
- 不再按顺序读,通过 Attention 直接查看任意位置信息。
- 一眼看全篇(Global Dependency)。无论两个词相隔多远,路径长度均为 O(1)。
3. Model Architecture (模型架构)
原文核心: "The Transformer follows this overall architecture using stacked self-attention and point-wise, fully connected layers for both the encoder and decoder."
解读: Transformer 沿用经典的 Encoder-Decoder 架构。 想象同声传译过程:
- Encoder(编码器):负责'听'和'理解',将输入转换为深层语义向量。
- Decoder(解码器):负责'说',根据语义生成输出序列。


