English

Spectraformer: A Unified Random Feature Framework for Transformer

Machine Learning 2025-09-24 v5

Abstract

Linearization of attention using various kernel approximation and kernel learning techniques has shown promise. Past methods used a subset of combinations of component functions and weight matrices within the random feature paradigm. We identify the need for a systematic comparison of different combinations of weight matrices and component functions for attention learning in Transformer. Hence, we introduce Spectraformer, a unified framework for approximating and learning the kernel function in the attention mechanism of the Transformer. Our empirical results demonstrate, for the first time, that a random feature-based approach can achieve performance comparable to top-performing sparse and low-rank methods on the challenging Long Range Arena benchmark. Thus, we establish a new state-of-the-art for random feature-based efficient Transformers. The framework also produces many variants that offer different advantages in accuracy, training time, and memory consumption. Our code is available at: https://github.com/cruiseresearchgroup/spectraformer .

Keywords

Cite

@article{arxiv.2405.15310,
  title  = {Spectraformer: A Unified Random Feature Framework for Transformer},
  author = {Duke Nguyen and Du Yin and Aditya Joshi and Flora Salim},
  journal= {arXiv preprint arXiv:2405.15310},
  year   = {2025}
}
R2 v1 2026-06-28T16:38:30.828Z