NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Hybrid Random Features

Krzysztof Marcin Choromanski, Han Lin, Haoxian Chen, Arijit Sehanobish, Yuanzhe Ma, Deepali Jain, Jake Varley, Andy Zeng, Michael S Ryoo, Valerii Likhosherstov, Dmitry Kalashnikov, Vikas Sindhwani, Adrian Weller

Scaling up kernel methods—especially the softmax kernels at the heart of Transformer attention—usually involves a trade-off. You can use Trigonometric Random Features (the classic approach), which are great at approximating large kernel values but struggle with small ones. Or you can use Positive Random Features (like FAVOR+), which nail the small values but falter on the large ones.

In this paper, researchers introduce Hybrid Random Features (HRFs). HRFs dynamically adapt to provide high-accuracy approximations across the entire range of kernel values, offering a "best of both worlds" solution that is both more accurate and computationally cheaper than previous methods.

The Problem with Existing Random Features

Modern "Linear Transformers" (like the Performer architecture) replace the expensive $O(L^2)$ attention matrix with a linear $O(L)$ approximation using Random Features (RFs). This relies on decomposing the softmax kernel into a dot product of feature maps: $K(x, y) \approx \phi(x)^\top \phi(y)$.

3D surface plot illustrating Mean Squared Error (MSE) across different input angles and magnitudes, highlighting the regions where estimators struggle.

However, existing feature maps have a significant "blind spot":

  1. Trigonometric RFs: These exhibit high variance (noise) when the kernel value is near zero. This is a major problem because attention matrices are naturally sparse—most values should be near zero.
  2. Positive RFs (FAVOR+): While these solve the near-zero problem, they introduce high variance for large kernel values. In Transformers, these large values represent the "important" tokens the model is actually attending to.

The core challenge is creating an estimator that is accurate for both the "background noise" (small values) and the "signal" (large values) simultaneously.

The Hybrid Random Feature Approach

The central idea behind HRFs is to use a weighted combination of base estimators.

Imagine having two estimators: one optimized for small values ($\text{SM}^{++}$) and one for large values ($\text{SM}^{\text{trig}}$). An HRF combines them using a "gate" or coefficient function $\lambda(x, y)$: $$\text{SM}^{\text{hyb}} = \lambda(x, y)\text{SM}^{++} + (1 - \lambda(x, y))\text{SM}^{\text{trig}}$$

The breakthrough here is the ability to linearize the gate itself. By leveraging complex analysis and Bochner’s Theorem, the authors ensure that even though the weights depend on the inputs $x$ and $y$, the entire expression can still be written as a single dot product of two vectors.

The paper highlights two main flavors of HRFs:

  • Angular Hybrid: This variant uses the angle between vectors to decide which estimator to trust. It provides zero variance at the extreme ends (perfectly similar or perfectly opposite vectors).
  • Complex Exponential Estimators: A generalized framework using complex numbers to create unbiased estimators tailored to specific regions of interest, such as data clusters.

Key Insights and Advantages

  • The Relative Error Advantage: While most research focuses on absolute error, this paper argues that relative error is crucial for Transformers. If a small attention weight is estimated as a negative number (a common failure of trigonometric features), the softmax normalization breaks down. HRFs are specifically designed to keep relative error low across the board.
  • Computational Efficiency: Surprisingly, HRFs are faster to compute. Standard RFs for $m$ features in $d$ dimensions take $O(mnd)$ time. Due to their decomposition, HRFs can be constructed in $O(nd + md + mn)$ time. For high-dimensional features, this represents a massive speedup.
  • Data-Driven Adaptation: The framework allows for "Clustering-based HRFs." If the data falls into specific clusters (common in robotics or vision tasks), this knowledge can be baked into the feature map to achieve even higher accuracy in those specific regions.

Empirical Results

The authors evaluated HRFs across a diverse set of benchmarks, including pointwise estimation, standard kernel regression (UCI datasets), language modeling (PTB, WikiText2), speech recognition, and robotics.

  • Speech Recognition: On the LibriSpeech ASR corpus using 17-layer Conformer-Performer models, the clustering-based HRF achieved a Word Error Rate (WER) of 1.72%, significantly outperforming standard FAVOR+ (2.65%) and Trigonometric (3.12%) baselines.
  • Robotics Efficiency: In a quadruped locomotion task (using a Unitree Laikago robot), HRFs achieved the same performance as the baseline but required 3x fewer FLOPs to run the policy. This efficiency is critical for deployment on real hardware with limited compute.
  • Mathematical Superiority: The authors proved that the max-relative error of the Angular Hybrid scales as $1/r \exp(2r^2)$ relative to the input length $r$, whereas previous methods scaled as $\exp(2r^2)$. In simpler terms, it maintains accuracy much longer as input vectors grow.

Limitations and Future Directions

  • Length Sensitivity: HRFs can be sensitive to the lengths of the query and key vectors. While addressed using $L_2$ normalization and regularizers, developing a more "length-invariant" hybrid remains an open research area.
  • Hyperparameter Tuning: The "Gaussian Hybrid" variant introduces a smoothness hyperparameter ($\sigma$) and requires choosing the number of clusters, adding complexity to the training pipeline compared to "off-the-shelf" RFs.
  • Vision Transformers: Although tested on robotics and speech, the paper does not explicitly benchmark on large-scale Vision Transformers (ViTs), which are a dominant use case for attention mechanisms today.

Summary updated

BibTeX
@inproceedings{choromanski2022hybrid,
  author = {Krzysztof Marcin Choromanski and Han Lin and Haoxian Chen and Arijit Sehanobish and Yuanzhe Ma and Deepali Jain and Jake Varley and Andy Zeng and Michael S Ryoo and Valerii Likhosherstov and Dmitry Kalashnikov and Vikas Sindhwani and Adrian Weller},
  title = {{Hybrid Random Features}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=EMigfE6ZeS},
}
Figure