
摘要
Transformer注意力机制在设计上的若干选择,包括较弱的归纳偏置(inductive bias)以及二次方时间复杂度,限制了其在建模长序列任务中的应用。本文提出Mega,一种简洁且具有理论基础的单头门控注意力机制,通过引入(指数)移动平均方法,将位置感知的局部依赖归纳偏置融入原本对位置不敏感的注意力机制中。此外,我们进一步提出Mega的一种变体,通过高效地将整个序列划分为固定长度的多个片段,实现了线性的时间与空间复杂度,同时仅带来微小的性能损失。在广泛的任务基准上进行的大量实验表明,包括长序列基准(Long Range Arena)、神经机器翻译、自回归语言建模以及图像与语音分类任务,Mega在性能上显著优于其他序列建模模型,包括各类Transformer变体以及近期的状态空间模型(state space models)。
代码仓库
facebookresearch/mega
官方
pytorch
GitHub 中提及
ethanbar11/ssm_2d
pytorch
GitHub 中提及
lucidrains/gated-state-spaces-pytorch
pytorch
GitHub 中提及
huggingface/transformers
pytorch
GitHub 中提及
pwc-1/Paper-9/tree/main/2/mega
mindspore
linghao-jin/canmt-challenges
pytorch
GitHub 中提及
ZIZUN/MAFiD
pytorch
GitHub 中提及
基准测试
| 基准 | 方法 | 指标 |
|---|---|---|
| image-classification-on-imagenet | Mega | Number of params: 90M Top 1 Accuracy: 82.4% |
| language-modelling-on-wikitext-103 | Mega | Number of params: 252M Test perplexity: 18.07 |
| machine-translation-on-wmt2014-english-german | Mega | BLEU score: 29.01 Number of Params: 67M SacreBLEU: 27.96 |
| machine-translation-on-wmt2014-german-english | Mega | BLEU score: 33.12 |