[Paper Review] Your Transformer May Not be as Powerful as You Expect
This paper reveals that standard Relative Positional Encoding (RPE)-based Transformers are not universal function approximators due to the softmax operation restricting positional information capture. To overcome this, the authors propose Universal RPE-based (URPE) Attention, which satisfies theoretical conditions for universal approximation and achieves state-of-the-art performance across diverse tasks with parameter efficiency.
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.
Motivation & Objective
- To investigate the theoretical expressive power of RPE-based Transformers in approximating continuous sequence-to-sequence functions.
- To identify why widely-used RPE-based Transformers fail to universally approximate certain functions despite their depth and width.
- To derive sufficient theoretical conditions—attentive and position-aware conditions—enabling universal approximation in RPE-based models.
- To design a novel attention mechanism, URPE-based Attention, that satisfies these conditions and enhances model capacity.
- To empirically validate the superiority of URPE-based Transformers across diverse architectures and tasks.
Proposed method
- Theoretical analysis identifies that the softmax operation in standard RPE attention produces right stochastic matrices, which limits the model's ability to capture positional information from RPE.
- The authors derive two sufficient conditions—attentive and position-aware conditions—for RPE-based Transformers to achieve universal function approximation.
- A new attention module, Universal RPE-based (URPE) Attention, is designed to satisfy these conditions by breaking the right-stochastic-matrix constraint.
- URPE Attention is integrated into standard Transformer architectures, including those for NLP and graph learning, with minimal parameter overhead.
- The method is evaluated on synthetic tasks, language modeling, and graph node classification, using standard benchmarks like OGB-LSC and GLUE.
- Hyperparameters are tuned for fair comparison, with models trained on multiple GPUs using Adam optimizer and linear learning rate decay.
Experimental results
Research questions
- RQ1Can RPE-based Transformers universally approximate any continuous sequence-to-sequence functions?
- RQ2Why do standard RPE-based Transformers fail to achieve universal approximation despite their depth and width?
- RQ3What theoretical conditions are sufficient for RPE-based Transformers to become universal function approximators?
- RQ4Can a new attention mechanism be designed to satisfy these conditions and improve model expressivity?
- RQ5Does the proposed URPE-based Transformer achieve consistent performance gains across diverse tasks and architectures?
Key findings
- Standard RPE-based Transformers are not universal function approximators because the softmax operation restricts the model's ability to utilize positional information encoded in RPE.
- The proposed URPE-based Attention satisfies the necessary theoretical conditions and enables universal approximation in RPE-based Transformers.
- On the MAG240M graph dataset, the URPE-based Graphormer achieved 0.7074 validation accuracy, a 0.06 improvement over the original Graphormer and state-of-the-art performance for a single model.
- In language pre-training, the URPE-based Transformer achieved a masked language modeling loss of 1.87, outperforming RPE-only models (1.94) and matching models using both APE and RPE (1.86).
- The URPE-based model shows consistent performance gains across synthetic tasks, NLP, and graph learning, demonstrating parameter efficiency and broad applicability.
- Theoretical analysis and synthetic experiments confirm that the softmax-induced right-stochastic matrix limitation is a fundamental bottleneck in standard RPE-based attention.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.