Token Statistics Transformer: Linear-Time Attention via Variational Rate Reduction

Ziyang Wu, Tianjiao Ding, Yifu Lu, Druv Pai, Jingyuan Zhang +4 more
12/23/2024
cs.LG

Official code: RobinWu218/ToST (135 stars, MIT, last commit 2025-02-25).

Abstract

The attention operator is arguably the key distinguishing factor of transformer architectures, which have demonstrated state-of-the-art performance on a variety of tasks. However, transformer attention operators often impose a significant computational burden, with the computational complexity scaling quadratically with the number of tokens. In this work, we propose a novel transformer attention operator whose computational complexity scales linearly with the number of tokens. We derive our network architecture by extending prior work which has shown that a transformer style architecture naturally arises by "white-box" architecture design, where each layer of the network is designed to implement an incremental optimization step of a maximal coding rate reduction objective (MCR$^2$). Specifically, we derive a novel variational form of the MCR$^2$ objective and show that the architecture that results from unrolled gradient descent of this variational objective leads to a new attention module called Token Statistics Self-Attention (TSSA). TSSA has linear computational and memory complexity and radically departs from the typical attention architecture that computes pairwise similarities between tokens. Experiments on vision, language, and long sequence tasks show that simply swapping TSSA for standard self-attention, which we refer to as the Token Statistics Transformer (ToST), achieves competitive performance with conventional transformers while being significantly more computationally efficient and interpretable. Our results also somewhat call into question the conventional wisdom that pairwise similarity style attention mechanisms are critical to the success of transformer architectures. Code will be available at https://github.com/RobinWu218/ToST.

View on arXivView PDF

Code Implementations(1)

RobinWu218/ToSTOfficial100%
MIT

[ICLR 2025 Spotlight] Official Implementation for ToST (Token Statistics Transformer)

1356PythonDec 17, 20241 years agoMIT

Similar Papers

Cite this paper

@article{wu2024token,
  title  = {Token Statistics Transformer: Linear-Time Attention via Variational Rate Reduction},
  author = {Ziyang Wu and Tianjiao Ding and Yifu Lu and Druv Pai and Jingyuan Zhang and Weida Wang and Yaodong Yu and Yi Ma and Benjamin D. Haeffele},
  year   = {2024},
  eprint = {2412.17810},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2412.17810v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2412.17810.svg)](https://codeofpaper.com/paper/2412.17810)

Discussion