“Spacetime tells matter how to move; matter tells spacetime how to curve.”
— John Archibald Wheeler
Official implementation of the paper "RiemannFormer: A Framework for Attention in Curved Spaces".
We introduce RiemannFormer, a paradigm shift that reimagines the Transformer through the lens of differential geometry. By rejecting the implicit flat Euclidean assumption of standard Self-Attention, we posit that token embeddings reside on a Curved Riemannian Manifold.
Our framework introduces PaTESO (Parallel Transport of Embeddings via Subspace Orientation), a geometrically principled position encoding derived from the isomorphism
- [2025-06-10] 🏆 SOTA Efficiency: Our metric-gated architecture outperforms standard ViT and RoPE variants on CIFAR benchmarks with high parameter efficiency.
We constructed the foundational parallel transport operator
However, adapting the standard Transformer for higher-dimensional data — such as images or voxels — requires the ability to model curvature and capture complex topological structures. To address this and incorporate richer semantic topology, we introduce an interaction operator
In this formulation, the intermediate term $\mathcal{F}{nm}$ encodes the manifold's intrinsic geometry. To preserve the norm of feature vectors and focus on directional geometric relationships, we specifically instantiate $\mathcal{F}{nm}$ as a rotation operation within the structure group.
As illustrated by the blue arc in the figure, this transformation is generated by an element of the Lie algebra,
Consequently,
This approach not only breaks the assumption of spatial flatness but also enables interactions between tokens to explicitly perceive the intrinsic geometric structure of the manifold.
We model the interaction between tokens
Unlike standard attention where the metric is fixed (
This allows the model to spatially expand salient regions (foreground) and compress noise (background), effectively acting as a "Gravitational Lens" for information flow.
If you find this work helpful or inspiring, please cite us:
@article{2025riemannformer,
title={RiemannFormer: A Framework for Attention in Curved Spaces},
author={Zhongping Ji},
journal={arXiv preprint arXiv:2506.07405},
year={2025}
}We stand on the shoulders of giants. This work draws inspiration from Riemannian geometry,General Relativity, Gauge Theory.
