Skip to main content
QUICK REVIEW

[论文解读] Transformer Dissection: A Unified Understanding of Transformer's Attention via the Lens of Kernel

Yao-Hung Hubert Tsai, Shaojie Bai|arXiv (Cornell University)|Aug 30, 2019
Natural Language Processing Techniques被引用 5
一句话总结

本文提出了一种基于核函数的注意力机制重构方法,将注意力机制重新表述为一种利用输入间相似性得分的核平滑器。通过建模对称核函数的乘积,该方法实现了对注意力组件的统一理解,减少了参数量,并在神经机器翻译和序列预测任务中实现了具有竞争力的性能,同时提升了可解释性和设计灵活性。

ABSTRACT

Transformer is a powerful architecture that achieves superior performance on various sequence learning tasks, including neural machine translation, language understanding, and sequence prediction. At the core of the Transformer is the attention mechanism, which concurrently processes all inputs in the streams. In this paper, we present a new formulation of attention via the lens of the kernel. To be more precise, we realize that the attention can be seen as applying kernel smoother over the inputs with the kernel scores being the similarities between inputs. This new formulation gives us a better way to understand individual components of the Transformer's attention, such as the better way to integrate the positional embedding. Another important advantage of our kernel-based formulation is that it paves the way to a larger space of composing Transformer's attention. As an example, we propose a new variant of Transformer's attention which models the input as a product of symmetric kernels. This approach achieves competitive performance to the current state of the art model with less computation. In our experiments, we empirically study different kernel construction strategies on two widely used tasks: neural machine translation and sequence prediction.

研究动机与目标

  • 为Transformer中的注意力机制提供一个统一的、基于核函数的理论框架。
  • 识别在注意力机制中最具效果的核函数形式以及位置嵌入的集成策略。
  • 开发一种新型注意力变体,在保持高性能的同时降低计算成本。
  • 通过核学习的视角,实现对注意力机制的系统性分类与设计。

提出的方法

  • 将自注意力机制重构为一种核平滑器,其中注意力权重源自输入标记之间的相似性(核)得分。
  • 提出一种新型注意力变体,将输入建模为对称核函数的乘积,从而在保持性能的同时减少参数量。
  • 通过核构造集成位置嵌入,具体方式为非位置核函数与位置核函数的乘积。
  • 采用指数核和RBF核——已知具有无限维特征映射——作为关键核函数形式,以评估性能表现。
  • 将核函数公式应用于分析和分类现有注意力变体,如Vaswani等人(2017)提出的模型、Shaw等人(2018)提出的模型以及Dai等人(2019)提出的模型。
  • 对位置嵌入的放置位置(查询、键、值或核函数)进行消融实验,以确定最优集成方式。

实验结果

研究问题

  • RQ1如何通过核方法的视角重新诠释Transformer注意力机制?
  • RQ2哪些核函数形式(如RBF、指数核)在注意力机制中表现最佳?
  • RQ3在基于核函数的注意力机制中,位置嵌入应集成在何处以实现最优性能?
  • RQ4能否通过对称核函数构建的注意力变体,在参数更少的情况下实现与现有模型相当的性能?
  • RQ5该核函数形式化方法是否能够实现对现有注意力变体的统一分类?

主要发现

  • 使用对称核函数的乘积形式实现注意力机制,可在显著减少参数量的同时保持竞争力的性能,优于或匹配最先进模型。
  • RBF核与指数核——两者均具有无限维特征映射——在神经机器翻译和序列预测任务中均表现出最佳性能。
  • 通过核函数集成位置嵌入(即与非位置核函数相乘)可获得最佳性能,优于在查询、键或值头中集成位置嵌入的方式。
  • 在值函数中集成位置嵌入并未带来显著的性能提升,表明其对注意力输出计算并非必要。
  • 从解码器自注意力中移除位置嵌入会导致神经机器翻译性能轻微下降(BLEU从34.71降至34.49),但若全局移除则性能急剧下降(降至14.47 BLEU),表明位置嵌入在整体建模中具有关键作用。
  • 基于核函数的公式化方法实现了对先前注意力变体的系统性理解与分类,揭示了在统一框架下共享的结构组件。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。