Fine- and Coarse-Granularity Hybrid Self-Attention for Efficient BERT

Jing Zhao, Yifan Wang, Junwei Bao, Youzheng Wu, Xiaodong He
3/17/2022
cs.CL
transformer-attention

Official code: pierre-zhao/FCA-BERT (4 stars, Python, last commit 2022-11-22).

Abstract

Transformer-based pre-trained models, such as BERT, have shown extraordinary success in achieving state-of-the-art results in many natural language processing applications. However, deploying these models can be prohibitively costly, as the standard self-attention mechanism of the Transformer suffers from quadratic computational cost in the input sequence length.

Show full abstract

To confront this, we propose FCA, a fine- and coarse-granularity hybrid self-attention that reduces the computation cost through progressively shortening the computational sequence length in self-attention. Specifically, FCA conducts an attention-based scoring strategy to determine the informativeness of tokens at each layer. Then, the informative tokens serve as the fine-granularity computing units in self-attention and the uninformative tokens are replaced with one or several clusters as the coarse-granularity computing units in self-attention. Experiments on GLUE and RACE datasets show that BERT with FCA achieves 2x reduction in FLOPs over original BERT with <1% loss in accuracy. We show that FCA offers a significantly better trade-off between accuracy and FLOPs compared to prior methods.

View on arXivView PDF

Code Implementations(1)

40Python, ShellMar 15, 20224 years ago

Similar Papers

Cite this paper

@article{zhao2022fine,
  title  = {Fine- and Coarse-Granularity Hybrid Self-Attention for Efficient BERT},
  author = {Jing Zhao and Yifan Wang and Junwei Bao and Youzheng Wu and Xiaodong He},
  year   = {2022},
  eprint = {2203.09055},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2203.09055}
}

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

Discussion