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) 将任何一对象征之间的相对距离编码为代号的相对位置编码( RPE) 是原变异器最成功的修改之一。 据我们所知,对基于 RPE 的变异器的理论理解基本上没有探索。 在这项工作中,我们用数学分析基于 RPE 的变异器的力量,该变异器是否能够接近任何连续序列到序列的功能。 自然可以假定答案是肯定的 -- 以 RPE 为基础的变异器是通用功能相匹配的。 然而,我们通过显示存在连续的序列到序列的变异器应用功能而呈现出一个负面的结果。 以 RPE 为基础的变异器无法估计任何深度和广度神经网络的变异器。 其中一个关键的原因是,大多数变异变器被置于软体的注意中,这总是产生一个正确的随机矩阵。 这限制了网络在RPE/ 变异变异器中获取定位信息的能力。 要克服问题,并使模型更强大,我们首先为基于 RPE 的变异器的变异变异器的变异器提供了足够的条件, 我们为在一个新的变异变异变器的变器的变现机的精确的功能中, 。