Fastformer: Additive Attention Can Be All You Need

Chuhan Wu, Fangzhao Wu, Tao Qi, Yongfeng Huang, Xing Xie
8/20/2021
cs.CL

Official code: wuch15/Fastformer (192 stars, last commit 2022-09-22).

Abstract

Transformer is a powerful model for text understanding. However, it is inefficient due to its quadratic complexity to input sequence length. Although there are many methods on Transformer acceleration, they are still either inefficient on long sequences or not effective enough. In this paper, we propose Fastformer, which is an efficient Transformer model based on additive attention. In Fastformer, instead of modeling the pair-wise interactions between tokens, we first use additive attention mechanism to model global contexts, and then further transform each token representation based on its interaction with global context representations. In this way, Fastformer can achieve effective context modeling with linear complexity. Extensive experiments on five datasets show that Fastformer is much more efficient than many existing Transformer models and can meanwhile achieve comparable or even better long text modeling performance.

View on arXivView PDF

Code Implementations(1)

wuch15/FastformerOfficial100%

A pytorch &keras implementation and demo of Fastformer.

19229Jupyter NotebookAug 31, 20214 years ago

Similar Papers

Cite this paper

@article{wu2021fastformer,
  title  = {Fastformer: Additive Attention Can Be All You Need},
  author = {Chuhan Wu and Fangzhao Wu and Tao Qi and Yongfeng Huang and Xing Xie},
  year   = {2021},
  eprint = {2108.09084},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2108.09084}
}

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

Discussion