RotRNN: Modelling Long Sequences with Rotations

Kai Biegun, Rares Dolga, Jake Cunningham, David Barber

TL;DR

RotRNN is a novel linear recurrent neural network that uses the mathematical properties of rotation matrices to model long-range dependencies in data. By parameterizing the recurrent state as a rotation, the authors achieve a model that is theoretically consistent, easy to normalize, and competitive with state-of-the-art models like State Space Models (SSMs) and Linear Recurrent Units (LRUs).

What Problem Does This Paper Address?

Modeling long sequences is a fundamental challenge in machine learning. Standard Transformers struggle with quadratic computational scaling as sequences grow, while traditional non-linear RNNs suffer from vanishing and exploding gradients.

Recently, State Space Models (SSMs) like S4 and Linear Recurrent Units (LRUs) have emerged as powerful alternatives, offering linear scaling and impressive performance on benchmarks like the Long Range Arena (LRA). However, these models often rely on complex initialization schemes (like HiPPO) or have a "mismatch" between their theoretical motivation and practical implementation. For instance, the LRU motivates its design using complex eigenvalues but often resorts to taking the real part of outputs and using learned normalizers that can be unstable during training. RotRNN aims to bridge this gap with a simpler, more robust, and theoretically "faithful" architecture.

Methods

The core innovation of RotRNN is parameterizing the recurrent state matrix $A$ as a rotation matrix.

  1. Rotation Parameterization: The authors use the fact that the matrix exponential of a skew-symmetric matrix ($S = M - M^\top$) always results in a rotation matrix. This allows the model to learn rotations smoothly during training.
  2. Efficient Recurrence: Recurrent models are often trained in parallel using a convolutional form, which requires computing matrix powers ($A^k$). Rotation matrices can be decomposed into a block-diagonal form consisting of 2D rotation blocks. This structure allows for extremely efficient computation of powers and vector multiplications.
  3. Principled Normalization: Because rotation matrices preserve the norm of a vector (their eigenvalues lie on the unit circle), the authors derive a normalization scheme that keeps the expected hidden state magnitude constant throughout training. This prevents the hidden state from exploding or vanishing without needing complex, hand-tuned initializations.
  4. Multi-Head Architecture: To capture information at different time scales, the model uses multiple "heads," each with its own rotation and a scalar decay factor $\gamma$.
Figure 1: Full neural network architecture of the RotRNN. Here T denotes the length of the input sequence, and Du denotes the number of channels in the input data.

Datasets

The authors evaluated RotRNN on two primary benchmarks:

  • Long Range Arena (LRA): A suite of six tasks (ListOps, Text, Retrieval, Image, Pathfinder, Path-X) designed to test a model's ability to handle sequence lengths ranging from 1,000 to 16,000 tokens across different modalities.
  • Speech Commands: A 35-way classification task involving 1-second audio waveforms sampled at 16kHz (16,000 steps).

Key Insights and Ideas

  • Theoretical Consistency: Unlike the LRU, where the practical implementation (taking the real part of complex numbers) deviates from the theory, RotRNN's implementation is a direct reflection of its mathematical derivation.
  • Robust Normalization: A standout finding is the stability of RotRNN’s hidden states. As shown in the comparison with LRU, RotRNN maintains a near-constant hidden state norm across different layers and throughout the entire training process.
  • LRU as a Special Case: The authors provide a mathematical proof showing that a specific configuration of the LRU (where eigenvalues come in conjugate pairs) is algebraically equivalent to a 2D-head RotRNN. This helps demystify why LRUs work so well.
Figure 3: Average hidden state norm across training on ListOps for the LRU and RotRNN.

Key Results

  • Competitive Performance: RotRNN achieves results comparable to SOTA linear recurrent models. It specifically excelled on discrete data, achieving the highest score among baselines on the IMDB Text classification task (89.6%).
  • Speech Classification: On the Speech Commands dataset, RotRNN performed identically to the LRU (95.2% accuracy) while maintaining a similar parameter count.
  • Stability: The model demonstrated significantly lower variance in hidden state norms compared to the LRU, suggesting it is easier to train and less sensitive to initialization.
Table 1: Test accuracy on the LRA benchmark tasks. We follow the standard training procedures from Gu et al. (2021). Unless otherwise specified, we report the results of baseline methods from their respective citations.

Limitations and Future Work

While RotRNN performed excellently on text and speech, it fell slightly short of the best-performing models (like S5 or Liquid-S4) on pixel-level image tasks like Path-X. The authors also note that their normalization guarantee currently assumes "white-noise" input, and they hope to extend this to more general input types in the future.

Promising future directions include integrating RotRNN into more complex, gated architectures (similar to Mamba or Griffin) and exploring input-dependent rotation transitions to further enhance its expressive power.

Summary updated

BibTeX
@misc{biegun2024rotrnn,
  author = {Kai Biegun and Rares Dolga and Jake Cunningham and David Barber},
  title = {{RotRNN: Modelling Long Sequences with Rotations}},
  year = {2024},
  eprint = {2407.07239},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.07239},
}
Figure