Mega: Moving Average Equipped Gated Attention

Xuezhe Ma, Chunting Zhou, Xiang Kong, Junxian He, Liangke Gui +3 more
9/21/2022
cs.LG

Official code: facebookresearch/mega (300 stars, MIT, last commit 2023-01-28).

Abstract

The design choices in the Transformer attention mechanism, including weak inductive bias and quadratic computational complexity, have limited its application for modeling long sequences. In this paper, we introduce Mega, a simple, theoretically grounded, single-head gated attention mechanism equipped with (exponential) moving average to incorporate inductive bias of position-aware local dependencies into the position-agnostic attention mechanism. We further propose a variant of Mega that offers linear time and space complexity yet yields only minimal quality loss, by efficiently splitting the whole sequence into multiple chunks with fixed length. Extensive experiments on a wide range of sequence modeling benchmarks, including the Long Range Arena, neural machine translation, auto-regressive language modeling, and image and speech classification, show that Mega achieves significant improvements over other sequence models, including variants of Transformers and recent state space models.

View on arXivView PDF

Code Implementations(1)

MIT

Sequence modeling with Mega.

30031C++, LuaSep 20, 20223 years agoMIT

Similar Papers

Cite this paper

@article{ma2022mega,
  title  = {Mega: Moving Average Equipped Gated Attention},
  author = {Xuezhe Ma and Chunting Zhou and Xiang Kong and Junxian He and Liangke Gui and Graham Neubig and Jonathan May and Luke Zettlemoyer},
  year   = {2022},
  eprint = {2209.10655},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2209.10655}
}

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

Discussion