[论文解读] Accelerating Neural Transformer via an Average Attention Network
本文提出了一种平均注意力网络(AAN),通过用两层结构替代解码器中的自注意力机制,以加速神经网络Transformer的解码阶段:第一层为累积历史聚合的平均层,第二层为增强表示表达能力的门控层。该方法在训练时通过掩码实现完全并行化,在推理时通过动态规划实现并行计算,从而在12个WMT17翻译任务中实现超过4倍的解码加速,且性能损失可忽略不计。
With parallelizable attention networks, the neural Transformer is very fast to train. However, due to the auto-regressive architecture and self-attention in the decoder, the decoding procedure becomes slow. To alleviate this issue, we propose an average attention network as an alternative to the self-attention network in the decoder of the neural Transformer. The average attention network consists of two layers, with an average layer that models dependencies on previous positions and a gating layer that is stacked over the average layer to enhance the expressiveness of the proposed attention network. We apply this network on the decoder part of the neural Transformer to replace the original target-side self-attention model. With masking tricks and dynamic programming, our model enables the neural Transformer to decode sentences over four times faster than its original version with almost no loss in training time and translation performance. We conduct a series of experiments on WMT17 translation tasks, where on 6 different language pairs, we obtain robust and consistent speed-ups in decoding.
研究动机与目标
- 解决由于解码器中自回归自注意力机制导致的Transformer解码速度缓慢的问题。
- 在显著提升推理速度的同时,保持Transformer的高训练效率和强性能。
- 开发一种轻量级、可并行化的自注意力替代方案,同时保留长距离依赖建模能力。
- 实现类似RNN的高效序列化解码(仅依赖前一隐藏状态),但避免RNN的循环瓶颈。
提出的方法
- 提出一种包含两层的平均注意力网络(AAN):第一层为对先前隐藏状态计算累积平均的平均层,第二层为增强表示表达能力的门控层。
- 在训练过程中使用掩码技术,模拟自注意力的因果注意力模式,从而实现完全并行化。
- 在推理阶段应用动态规划,实现输出的并行计算,避免自回归生成。
- 将Transformer解码器中的目标侧自注意力机制替换为AAN,同时保持编码器不变。
- 在标准Transformer架构中集成AAN,仅进行最小的结构修改。
实验结果
研究问题
- RQ1基于简单平均的注意力机制是否能在不牺牲翻译质量的前提下,替代Transformer解码器中的自注意力机制?
- RQ2AAN在保持训练效率和模型性能的前提下,能够将解码速度提升到何种程度?
- RQ3AAN在不同语言对(包括语言复杂度和训练数据规模各异)上是否具备良好的泛化能力?
- RQ4AAN的加速优势是否在不同序列长度和翻译方向上保持一致?
主要发现
- 在WMT17基准测试的全部12种语言对中,AAN模型的解码速度均比原始Transformer快超过4倍。
- 在En→Tr翻译任务中,该模型每句仅需0.02968秒即可完成解码,约为原始Transformer耗时的1/7。
- 翻译性能几乎保持不变,与Transformer相比在En→Tr方向仅下降0.53个BLEU点。
- 该模型在所有语言对(包括低资源语言对如En→Lv和En→Cs)中均表现出一致的加速效果,表明其具有语言无关的性能优势。
- AAN在长句上也保持了强劲的性能,证明其虽结构简单,但能有效建模长距离依赖关系。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。