Skip to main content
QUICK REVIEW

[Paper Review] Mega: Moving Average Equipped Gated Attention

Xuezhe Ma, Chunting Zhou|arXiv (Cornell University)|Sep 21, 2022
Topic ModelingComputer Science36 citations
TL;DR

Mega introduces a moving-average equipped gated attention mechanism that integrates exponential moving average into a single-head gated attention, with a linear-complexity Mega-chunk variant, yielding strong performance on long-range sequence tasks across multiple modalities.

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.

Motivation & Objective

  • Motivate improving long-range sequence modeling by combining strong inductive bias with flexible attention.
  • Develop a single-head gated attention mechanism enhanced by exponential moving average (EMA).
  • Introduce a linear-time Mega-chunk variant for scalable sequence processing.
  • Demonstrate Mega’s effectiveness across diverse modalities and benchmarks.
  • Provide theoretical justification for single-head gated attention’s expressiveness.

Proposed method

  • Introduce multi-dimensional damped EMA to capture local, time-decaying dependencies.
  • Embed EMA into a single-head gated attention framework (GAU-based) with queries, keys, and values derived from EMA-augmented representations.
  • Adopt a Laplace-based attention function as an alternative to softmax for different modalities.
  • Use gated residual connections and a normalization step within Mega blocks to stabilize training.
  • Propose Mega-chunk to achieve linear time/space complexity by processing fixed-length chunks with EMA providing cross-chunk context.
  • Compare attention functions (softmax, relu^2, laplace) across tasks to select suitable options for language, vision, and speech.

Experimental results

Research questions

  • RQ1Does integrating EMA into gated attention improve modeling of local and long-range dependencies compared to standard attention?
  • RQ2Can a single-head gated attention with EMA achieve expressiveness comparable to multi-head attention?
  • RQ3Does the Mega-chunk variant maintain performance while reducing computational costs to linear complexity?
  • RQ4How does Mega perform across diverse modalities (text, image, speech) and tasks (LRA, MT, LM, Vision, Speech)?
  • RQ5What attention functions best facilitate Mega across domains?

Key findings

  • Mega outperforms Transformer and S4 variants on all Long Range Arena tasks and related benchmarks.
  • Mega achieves 88.21 average accuracy on LRA vs. 86.09–86.35 for S4 variants and 59.24 for XFM, demonstrating strong long-range modeling with linear-time variants.
  • Mega-(chunk) provides substantial speed and memory benefits, e.g., 5.5× faster and 13% memory usage relative to vanilla Transformer on LRA Text task.
  • In language tasks, softmax attention within Mega yields strong performance, while laplace attention excels for vision and speech tasks.
  • Mega-base improves WMT’16 English-German BLEU by over 1.1 points compared to Transformer-base.
  • On ImageNet-1k, Mega achieves about 0.5% higher top-1 accuracy than DeiT-B.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.