Skip to main content
QUICK REVIEW

[Paper Review] Hard-Coded Gaussian Attention for Neural Machine Translation

Weiqiu You, Simeng Sun|arXiv (Cornell University)|May 2, 2020
Natural Language Processing TechniquesComputer Science28 references11 citations
TL;DR

This paper proposes hard-coded Gaussian attention, replacing all learned multi-head attention mechanisms in Transformers with fixed, input-agnostic Gaussian distributions centered on local positions. Surprisingly, models with only hard-coded self-attention in encoder and decoder achieve near-baseline BLEU scores across four language pairs, but replacing cross-attention with hard-coded versions causes significant BLEU drops—recoverable with just one learned cross-attention head, suggesting cross-attention is more critical than self-attention for translation quality.

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. 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.

Motivation & Objective

  • To investigate whether learned multi-head attention is essential for high-quality neural machine translation.
  • To evaluate the impact of replacing all learned attention mechanisms with fixed, parameter-free alternatives.
  • To determine which components of the Transformer (self-attention vs. cross-attention) are most critical for translation performance.
  • To explore minimal learned parameter configurations that maintain competitive BLEU scores.
  • To improve model efficiency through parameter-free attention while preserving translation quality.

Proposed method

  • Replace all encoder and decoder self-attention heads with fixed Gaussian distributions centered on specific positions within a local window, using no learned parameters.
  • Maintain fully learned multi-head cross-attention as a baseline for comparison.
  • Replace cross-attention with hard-coded Gaussian distributions to assess its impact on translation quality.
  • Introduce a single learned cross-attention head into an otherwise hard-coded model to recover performance.
  • Implement alternative variants, including indexing-based attention with binary kernels, to further simplify attention mechanisms.
  • Evaluate models on four language pairs using BLEU scores, decoding speed, and memory efficiency.

Experimental results

Research questions

  • RQ1Can self-attention in the encoder and decoder be entirely replaced with fixed, non-learned Gaussian distributions without significantly degrading translation quality?
  • RQ2How critical is cross-attention compared to self-attention for maintaining high BLEU scores in neural machine translation?
  • RQ3What is the minimal number of learned attention parameters needed to recover performance after hard-coding all attention mechanisms?
  • RQ4Can efficiency gains be achieved through parameter-free attention without sacrificing translation quality?
  • RQ5How do hard-coded attention mechanisms compare to learned ones in modeling linguistic phenomena like long-distance dependencies?

Key findings

  • Replacing all self-attention in the encoder and decoder with hard-coded Gaussian distributions results in minimal BLEU degradation across four language pairs, indicating self-attention is less critical than previously assumed.
  • Hard-coding cross-attention leads to a substantial BLEU drop of 5–10 points, demonstrating that cross-attention is more important than self-attention for translation quality.
  • Adding just one learned cross-attention head to an otherwise hard-coded Transformer recovers most of the performance loss, with only a 1–3 BLEU point drop compared to the full baseline.
  • The hard-coded model achieves 26.4% higher memory efficiency (tokens per batch) and 30.2% faster decoding speed than the baseline, despite being parameter-free in attention.
  • Analysis shows that learned attention heads in a standard Transformer primarily focus on local windows, supporting the design choice of localized hard-coded Gaussians.
  • Indexing-based attention with binary kernels achieves less than 1 BLEU drop on two datasets, suggesting further efficiency improvements are possible with minimal performance loss.

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.