Nyströmformer: A Nyström-Based Algorithm for Approximating Self-Attention

Yunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan, Glenn Fung +2 more
2/7/2021
cs.CLcs.LG

Official code: mlpen/Nystromformer (390 stars, Apache-2.0, last commit 2023-10-18). 1 more implementation below.

Abstract

Transformers have emerged as a powerful tool for a broad range of natural language processing tasks. A key component that drives the impressive performance of Transformers is the self-attention mechanism that encodes the influence or dependence of other tokens on each specific token. While beneficial, the quadratic complexity of self-attention on the input sequence length has limited its application to longer sequences -- a topic being actively studied in the community. To address this limitation, we propose Nyströmformer -- a model that exhibits favorable scalability as a function of sequence length. Our idea is based on adapting the Nyström method to approximate standard self-attention with $O(n)$ complexity. The scalability of Nyströmformer enables application to longer sequences with thousands of tokens. We perform evaluations on multiple downstream tasks on the GLUE benchmark and IMDB reviews with standard sequence length, and find that our Nyströmformer performs comparably, or in a few cases, even slightly better, than standard self-attention. On longer sequence tasks in the Long Range Arena (LRA) benchmark, Nyströmformer performs favorably relative to other efficient self-attention methods. Our code is available at https://github.com/mlpen/Nystromformer.

View on arXivView PDF

Code Implementations(2)

Apache-2.0
39045Shell, PythonDec 11, 20203 years agoApache-2.0
MIT

Implementation of Nyström Self-attention, from the paper Nyströmformer

14518PythonFeb 11, 20211 years agoMIT
artificial-intelligenceattention-mechanism

Cite this paper

@article{xiong2021nystrmformer,
  title  = {Nyströmformer: A Nyström-Based Algorithm for Approximating Self-Attention},
  author = {Yunyang Xiong and Zhanpeng Zeng and Rudrasis Chakraborty and Mingxing Tan and Glenn Fung and Yin Li and Vikas Singh},
  year   = {2021},
  eprint = {2102.03902},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2102.03902}
}

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/2102.03902.svg)](https://codeofpaper.com/paper/2102.03902)

Discussion