Abstract LieRE (Lie Relative Encodings) generalizes the popular Rotary Position Encoding (RoPE) by using Lie group theory to learn high-dimensional, dense rotation matrices. This approach significantly boosts the performance of Transformers on 2D and 3D vision tasks while requiring minimal extra parameters and offering a nearly 4x speedup in training convergence compared to standard methods.
Introduction: The Bottleneck of Standard RoPE
Transformers are inherently "permutation invariant," meaning they treat a sequence of tokens like an unordered bag of words unless explicitly told where each token is located. To resolve this, researchers rely on positional encodings.
In Large Language Models (LLMs), Rotary Position Encoding (RoPE) has become the gold standard. It works by "rotating" token representations in 2D planes based on their position, allowing the model to naturally understand relative distances. However, RoPE was designed primarily for 1D text. When applied to high-dimensional data like images (2D) or videos (3D), its fixed, sparse, 2D rotations become a bottleneck. It struggles to capture complex spatial relationships and often fails to generalize when the input resolution changes (e.g., moving from a $224\times224$ image to a $448\times448$ one).
Methodology: Lie Relative Encodings (LieRE)
To address these limitations, the authors introduce LieRE, a principled generalization of RoPE based on Lie group theory.
Instead of using fixed, handcrafted 2D rotation formulas, LieRE learns a basis of skew-symmetric matrices (elements of a Lie algebra). These matrices are then transformed into high-dimensional rotation matrices (elements of a Lie group) using the matrix exponential function: $$R(p) = \exp\left(\sum_{i=0}^{n} p_i A_i\right)$$ where $p$ is the position vector and $A_i$ are the learned matrices.
This formulation introduces several key advantages:
- Learnability: Unlike standard RoPE, which is fixed, LieRE's rotations are learned during training, allowing the model to adapt its spatial map to the specific data modality.
- Density: It moves beyond simple 2D rotations to dense, high-dimensional rotations that can capture more intricate spatial dependencies.
- Continuous Encodings: Because it uses a continuous mathematical framework, it handles varying resolutions much more gracefully than absolute positional embeddings.
- Optimization Stability: It is mathematically difficult to learn rotation matrices directly because they must stay orthogonal. By learning in the space of skew-symmetric matrices (the Lie algebra) and then mapping to the rotation group, LieRE sidesteps these optimization hurdles.
Experiments and Key Results
The researchers evaluated LieRE across several benchmarks, including 2D Vision (CIFAR-100, ImageNet-1k), 3D Vision (UCF101 for spatio-temporal video classification), and a newly designed Synthetic Spatial Reasoning task.
Superior Accuracy and 3D Gains On CIFAR-100, LieRE achieved a 10.0% relative improvement over absolute encodings and a 2.2% improvement over the previous state-of-the-art "RoPE-Mixed." In video classification (UCF101), LieRE showed a 15.1% relative improvement over absolute embeddings.
Solving Spatial Reasoning and Resolution Invariance The synthetic "Arrow" task requires a model to identify the direction of an arrow pointed to by a specific token amidst distractors, testing its grasp of relative spatial coordinates. LieRE maintained 100% accuracy across all tested resolutions, while RoPE-Mixed dropped to 88.6% and absolute encodings hovered around 40-45%. This demonstrates LieRE's ability to maintain near-perfect accuracy even when the test resolution is much higher than the training resolution.
Compute Efficiency LieRE adds only about 0.68% more parameters to a standard ViT-Base model. Despite this tiny footprint, it enables the model to converge to baseline accuracy levels 3.9x faster than using absolute position embeddings. Furthermore, the authors found a "sweet spot" of capacity: using $8\times8$ block-diagonal matrices provided the best balance between representational capacity and regularization, outperforming both simpler $2\times2$ blocks and fully dense matrices.
Limitations and Future Work
While highly effective for multi-dimensional data, LieRE mathematically reduces to RoPE with learnable phases in 1D settings (like standard text). Additionally, the method relies on the matrix_exp function in PyTorch; future work could explore more efficient or robust numerical approximations for this operation. Finally, adapting these Lie group principles to other architectures like Convolutional Neural Networks (CNNs) or State Space Models (SSMs), or expanding the formulation to encode full poses in $SE(3)$ for robotics, remain exciting open challenges.
Summary updated