Fast Monte-Carlo Approximation of the Attention Mechanism

Abstract

We introduce Monte-Carlo Attention (MCA), a randomized approximation method for reducing the computational cost of self-attention mechanisms in Transformer architectures. MCA exploits the fact that the importance of each token in an input sequence vary with respect to their attention scores; thus, some degree of error can be tolerable when encoding tokens with low attention. Using approximate matrix multiplication, MCA applies different error bounds to encode input tokens such that those with low attention scores are computed with relaxed precision, whereas errors of salient elements are minimized. MCA can operate in parallel with other attention optimization schemes and does not require model modification. We study the theoretical error bounds and demonstrate that MCA reduces attention complexity (in FLOPS) for various Transformer models by up to 11 in GLUE benchmarks without compromising model accuracy. Source code and appendix: https://github.com/eis-lab/monte-carlo-attention

Cite

Text

Kim and Ko. "Fast Monte-Carlo Approximation of the Attention Mechanism." AAAI Conference on Artificial Intelligence, 2022. doi:10.1609/AAAI.V36I7.20679

Markdown

[Kim and Ko. "Fast Monte-Carlo Approximation of the Attention Mechanism." AAAI Conference on Artificial Intelligence, 2022.](https://mlanthology.org/aaai/2022/kim2022aaai-fast/) doi:10.1609/AAAI.V36I7.20679

BibTeX

@inproceedings{kim2022aaai-fast,
  title     = {{Fast Monte-Carlo Approximation of the Attention Mechanism}},
  author    = {Kim, Hyunjun and Ko, JeongGil},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year      = {2022},
  pages     = {7185-7193},
  doi       = {10.1609/AAAI.V36I7.20679},
  url       = {https://mlanthology.org/aaai/2022/kim2022aaai-fast/}
}