Hard-Coded Gaussian Attention for Neural Machine Translation

Weiqiu You, Simeng Sun, Mohit Iyyer
5/2/2020
cs.CL
transformer-attention

Official code: fallcat/stupidNMT (36 stars, Python, BSD-3-Clause, last commit 2023-05-22).

Abstract

Recent work has questioned the importance of the Transformer's multi-headed attention for achieving high translation quality. We push further in this direction by developing a "hard-coded" attention variant without any learned parameters.

Show full abstract

Surprisingly, replacing all learned self-attention heads in the encoder and decoder with fixed, input-agnostic Gaussian distributions minimally impacts BLEU scores across four different language pairs. However, additionally hard-coding cross attention (which connects the decoder to the encoder) significantly lowers BLEU, suggesting that it is more important than self-attention. Much of this BLEU drop can be recovered by adding just a single learned cross attention head to an otherwise hard-coded Transformer. Taken as a whole, our results offer insight into which components of the Transformer are actually important, which we hope will guide future work into the development of simpler and more efficient attention-based models.

View on arXivView PDF

Code Implementations(1)

fallcat/stupidNMTOfficial100%
BSD-3-Clause

Hard-Coded Gaussian Attention for Neural Machine Translation

366Python, ShellApr 30, 20203 years agoBSD-3-Clause

Similar Papers

Cite this paper

@article{you2020hardcoded,
  title  = {Hard-Coded Gaussian Attention for Neural Machine Translation},
  author = {Weiqiu You and Simeng Sun and Mohit Iyyer},
  year   = {2020},
  eprint = {2005.00742},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2005.00742}
}

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

Discussion