Skip to main content
QUICK REVIEW

[Paper Review] Token Statistics Transformer: Linear-Time Attention via Variational Rate Reduction

Ziyang Wu, Tianjiao Ding|arXiv (Cornell University)|Dec 23, 2024
Anomaly Detection Techniques and ApplicationsComputer Science3 citations
TL;DR

This paper proposes Token Statistics Transformer (ToST), a novel self-attention mechanism called Token Statistics Self-Attention (TSSA) that achieves linear computational and memory complexity by replacing pairwise token similarity computations with second-order statistics of projected features. Derived via algorithmic unrolling of a variational form of the Maximum Coding Rate Reduction (MCR²) objective, ToST matches standard transformer performance on vision, language, and long-sequence tasks while being significantly more efficient and interpretable, challenging the necessity of pairwise attention for transformer success.

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.

Motivation & Objective

  • To address the quadratic computational and memory complexity of standard self-attention in transformers, which limits scalability on long sequences.
  • To investigate whether pairwise token similarity computation is essential for transformer performance, challenging a core assumption in attention mechanism design.
  • To develop a new attention mechanism grounded in principled optimization theory, specifically via unrolled gradient descent on a novel variational MCR² objective.
  • To design a model that maintains competitive performance while drastically reducing inference time and memory usage, especially for long-context and vision tasks.
  • To demonstrate that attention can be reimagined not as a similarity-based aggregation, but as a statistic-based transformation of input features.

Proposed method

  • The method derives a novel variational form of the MCR² objective, enabling a principled, differentiable architecture design via algorithmic unrolling.
  • TSSA computes attention by aggregating statistics (specifically, second-order moments) of projected token features, avoiding explicit pairwise similarity computation.
  • The architecture is constructed by unrolling gradient updates of the variational MCR² objective, resulting in a layer-wise transformation that is both efficient and interpretable.
  • The resulting model, ToST, replaces standard self-attention with TSSA across all layers, preserving the transformer’s residual and feed-forward structure.
  • A causal variant of TSSA is introduced for autoregressive language modeling, enabling efficient next-token prediction.
  • The method is trained end-to-end using standard optimization, with no architectural or loss function modifications beyond the attention mechanism replacement.

Experimental results

Research questions

  • RQ1Can a self-attention mechanism be designed without computing pairwise similarities between tokens while still achieving competitive performance on vision and language tasks?
  • RQ2Does replacing standard attention with a statistic-based mechanism like TSSA fundamentally alter the inductive bias of transformers, and if so, how does it affect performance and generalization?
  • RQ3Is the quadratic complexity of self-attention truly necessary for long-range modeling, or can linear-time alternatives like TSSA achieve comparable long-context performance?
  • RQ4Can a principled, optimization-theoretic derivation of attention lead to a model that is both more efficient and more interpretable than standard attention?
  • RQ5Does the success of transformers rely on the specific structure of pairwise attention, or is it possible to achieve similar performance through alternative, more efficient attention mechanisms?

Key findings

  • ToST achieves competitive performance on image classification benchmarks, with visualizations showing that it autonomously learns meaningful segmentation and clustering without supervision.
  • On the Long-Range Arena benchmark, ToST outperforms other transformer-based models on average, achieving a mean score of 59.90 compared to 59.24 for standard transformers.
  • For causal language modeling, ToST with 655M parameters achieves a test loss of 4.02 on the average of four datasets, comparable to GPT2-Base (4.26), despite using fewer parameters and less compute.
  • ToST reduces inference time by up to 60% and memory usage by up to 76% compared to standard transformers, with the causal variant showing 54% less memory usage at 8k sequence length.
  • The model's attention maps reveal that TSSA learns to group semantically coherent patches or tokens, suggesting that statistical aggregation can replace similarity-based attention for meaningful representation learning.
  • The results challenge the conventional belief that pairwise similarity computation is essential for attention, suggesting that alternative inductive biases can yield strong performance with greater efficiency.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.