Skip to main content
QUICK REVIEW

[论文解读] Your Transformer May Not be as Powerful as You Expect

Shengjie Luo, Shanda Li|arXiv (Cornell University)|May 26, 2022
Advanced Image and Video Retrieval Techniques被引用 11
一句话总结

本文揭示了基于标准相对位置编码(RPE)的Transformer模型并非通用函数逼近器,原因在于softmax操作限制了位置信息的捕捉能力。为克服此问题,作者提出了基于通用RPE(URPE)的注意力机制,该机制满足通用逼近的理论条件,并在多种任务中实现了最先进的性能表现,同时具备参数效率。

ABSTRACT

Relative Positional Encoding (RPE), which encodes the relative distance between any pair of tokens, is one of the most successful modifications to the original Transformer. As far as we know, theoretical understanding of the RPE-based Transformers is largely unexplored. In this work, we mathematically analyze the power of RPE-based Transformers regarding whether the model is capable of approximating any continuous sequence-to-sequence functions. One may naturally assume the answer is in the affirmative -- RPE-based Transformers are universal function approximators. However, we present a negative result by showing there exist continuous sequence-to-sequence functions that RPE-based Transformers cannot approximate no matter how deep and wide the neural network is. One key reason lies in that most RPEs are placed in the softmax attention that always generates a right stochastic matrix. This restricts the network from capturing positional information in the RPEs and limits its capacity. To overcome the problem and make the model more powerful, we first present sufficient conditions for RPE-based Transformers to achieve universal function approximation. With the theoretical guidance, we develop a novel attention module, called Universal RPE-based (URPE) Attention, which satisfies the conditions. Therefore, the corresponding URPE-based Transformers become universal function approximators. Extensive experiments covering typical architectures and tasks demonstrate that our model is parameter-efficient and can achieve superior performance to strong baselines in a wide range of applications. The code will be made publicly available at https://github.com/lsj2408/URPE.

研究动机与目标

  • 研究基于RPE的Transformer在逼近连续序列到序列函数方面的理论表达能力。
  • 揭示为何广泛使用的基于RPE的Transformer尽管深度和宽度足够,仍无法普遍逼近某些函数。
  • 推导出RPE模型实现通用逼近的充分理论条件——即注意力与位置感知条件。
  • 设计一种新型注意力机制——URPE注意力,使其满足上述条件并增强模型容量。
  • 通过实证验证URPE-based Transformer在多种架构和任务中的优越性能。

提出的方法

  • 理论分析表明,标准RPE注意力中的softmax操作会产生右随机矩阵,从而限制模型捕捉RPE中位置信息的能力。
  • 作者推导出两个充分条件——注意力条件与位置感知条件——以确保RPE-based Transformer实现通用函数逼近。
  • 设计了一种新型注意力模块——通用RPE-based(URPE)注意力,通过打破右随机矩阵约束来满足这些条件。
  • 将URPE注意力集成到标准Transformer架构中,涵盖自然语言处理与图学习任务,仅引入极少的参数开销。
  • 在合成任务、语言建模和图节点分类任务上进行评估,使用OGB-LSC和GLUE等标准基准数据集。
  • 通过超参数调优确保公平比较,模型在多张GPU上使用Adam优化器和线性衰减学习率进行训练。

实验结果

研究问题

  • RQ1基于RPE的Transformer能否普遍逼近任意连续序列到序列函数?
  • RQ2为何标准RPE-based Transformer尽管具有深度和宽度,仍无法实现通用逼近?
  • RQ3RPE-based Transformer实现通用函数逼近所需的充分理论条件是什么?
  • RQ4能否设计一种新型注意力机制以满足这些条件并提升模型表达能力?
  • RQ5所提出的URPE-based Transformer是否在多种任务与架构中均实现一致的性能提升?

主要发现

  • 标准RPE-based Transformer并非通用函数逼近器,原因在于softmax操作限制了模型对RPE中编码的位置信息的利用能力。
  • 所提出的URPE-based Attention满足必要的理论条件,使RPE-based Transformer具备通用逼近能力。
  • 在MAG240M图数据集上,URPE-based Graphormer达到0.7074的验证准确率,较原始Graphormer提升0.06,达到单模型的最先进性能。
  • 在语言预训练任务中,URPE-based Transformer的掩码语言建模损失为1.87,优于仅使用RPE的模型(1.94),并匹配同时使用APE和RPE的模型(1.86)。
  • URPE-based模型在合成任务、自然语言处理和图学习任务中均表现出一致的性能提升,展现出参数效率与广泛适用性。
  • 理论分析与合成实验共同证实,由softmax引起的右随机矩阵限制是标准RPE-based注意力中的根本性瓶颈。

更好的研究,从现在开始

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

无需绑定信用卡

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