This post is a deep technical exploration of CARE (Clifford Algebra Rotary Embeddings), a positional encoding framework that extends RoPE using Clifford (geometric) algebra.
Key points
1. RoPE's elegance and its dimensional limits
- RoPE encodes position as rotation in the 2D complex plane: each pair of embedding dimensions is rotated by an angle proportional to position \(m\), with frequencies $ heta_j = 10000^{-2j/d}$. Multi-frequency rotation lets low-frequency dimensions capture long-range dependencies and high-frequency ones capture local detail.
- RoPE naturally satisfies shift-equivariance: attention depends only on relative position, thanks to the commutative group structure of 2D rotations.
- When data is intrinsically higher-dimensional (3D point clouds, RGBA, spacetime), RoPE's 2D rotations become a fundamental mismatch — rotations in \(n\)D form \(SO(n)\), with rich algebra RoPE cannot express.
- Spherical RoPE, an extension to \(S^2\), fails because 3D rotations are non-commutative (the gimbal lock / Euler-angle ordering problem), undermining shift-equivariance.
- Quaternions, discovered by Hamilton in 1843, give a singularity-free representation of 3D rotations (no gimbal lock, SLERP interpolation).
- Crucially, quaternions are the even subalgebra of \(Cl(3,0,0)\): identifying \(i=e_2e_3, j=e_3e_1, k=e_1e_2\) recovers \(i^2=j^2=k^2=ijk=-1\).
- QuatRo parameterizes arbitrary (learnable) rotation axes via quaternions for 4D inputs. It unifies prior methods:
- QuatRo's limits: rigid 4D blocks, vector-only (grade-1) operations, use of only the even subalgebra.
- Clifford algebra unifies the inner and wedge products through the geometric product \(\mathbf{ab} = \mathbf{a}\cdot\mathbf{b} + \mathbf{a}\wedge\mathbf{b}\), producing multivectors with graded parts: scalars (grade 0), vectors (grade 1), bivectors (grade 2), trivectors/pseudoscalars (grade 3).
- Signature flexibility \(Cl(p,q,r)\) covers Euclidean, Minkowski, degenerate, and conformal geometries.
- Rotors \(R = e^{\theta B/2} = \cos(\theta/2) + \sin(\theta/2)B\) act via the sandwich product \(M' = RMR̃\), which preserves norms, grade parity, and the geometric product structure.
- CARE in \(Cl(3,0,0)\): an embedding becomes an 8D multivector \((s, v_1, v_2, v_3, b_1, b_2, b_3, p)\); position is encoded by rotating it with composite rotors built from learnable bivector axes, inheriting RoPE's frequency schedule. Example for 2D positions:
- The sandwich product's two-sided structure is what keeps transforms pure rotations (norm-preserving) and controls which grades are affected; non-commutativity of composition is handled by fixed ordering plus learnable axes.
- Rotor dimension grows as \(2^{n-1}\) and geometric product cost as \(O(4^n)\); CARE is acknowledged to be significantly slower than baselines (roughly 2–10× slowdown at \(n=3\), unoptimized).
- On CIFAR-100 with ViT-B, CARE reaches 74.8% top-1, tied with Mixed RoPE (Clifford framework) and about 0.5–0.6% above quaternion-framework variants; the author cautions that conclusions from single runs are weak.
- The theory-practice gap likely reflects task simplicity, data scale, and unexplored hyperparameters rather than a fundamental flaw.
- Natural fits: 3D vision (point clouds, voxels, NeRF), spacetime/video modeling via \(Cl(3,1,0)\), scientific computing (electromagnetic fields as multivectors, molecular structure).
- Multimodal learning: different modalities can occupy different grades of a shared multivector space, giving interpretable, unified cross-modal alignment.
- Open questions: automatic selection of the optimal Clifford algebra signature, efficient implementations (sparsity, low-rank rotors, dedicated CUDA kernels, or geometric algebra processing units), and validation at LLM/multimodal scale.
2. Quaternions as a bridge: QuatRo
| Method | QuatRo configuration | Geometric meaning | |:---|:---|:---| | Mixed RoPE | Parallel/orthogonal axes | Independent planar rotations | | Spherical RoPE | Orthogonal fixed axes | Euler angles, gimbal lock risk | | General QuatRo | Arbitrary learnable axes | Full \(SO(3)\) exploration |