Skip to main content
QUICK REVIEW

[Paper Review] An Analysis of Attention Mechanisms: The Case of Word Sense Disambiguation in Neural Machine Translation

Gongbo Tang, Rico Sennrich|arXiv (Cornell University)|Oct 17, 2018
Natural Language Processing Techniques13 references4 citations
TL;DR

This paper investigates how encoder-decoder attention mechanisms in neural machine translation (NMT) handle word sense disambiguation (WSD) for ambiguous nouns. Contrary to expectations, it finds that attention mechanisms prioritize the ambiguous word itself over contextual tokens, indicating that contextual information for WSD is primarily encoded in hidden states rather than attention distributions. The study reveals that Transformer models learn alignment in early layers and feature extraction from unaligned context in later layers.

ABSTRACT

Recent work has shown that the encoder-decoder attention mechanisms in neural machine translation (NMT) are different from the word alignment in statistical machine translation. In this paper, we focus on analyzing encoder-decoder attention mechanisms, in the case of word sense disambiguation (WSD) in NMT models. We hypothesize that attention mechanisms pay more attention to context tokens when translating ambiguous words. We explore the attention distribution patterns when translating ambiguous nouns. Counter-intuitively, we find that attention mechanisms are likely to distribute more attention to the ambiguous noun itself rather than context tokens, in comparison to other nouns. We conclude that attention mechanism is not the main mechanism used by NMT models to incorporate contextual information for WSD. The experimental results suggest that NMT models learn to encode contextual information necessary for WSD in the encoder hidden states. For the attention mechanism in Transformer models, we reveal that the first few layers gradually learn to "align" source and target tokens and the last few layers learn to extract features from the related but unaligned context tokens.

Motivation & Objective

  • To investigate whether attention mechanisms in NMT models distribute more attention to context tokens when translating ambiguous words.
  • To compare the behavior of vanilla one-layer attention and multi-head self-attention in Transformers during WSD.
  • To evaluate the actual translation quality of ambiguous nouns using a real test set, avoiding contrastive scoring.
  • To determine whether attention weights correlate with WSD accuracy and how data sparsity affects errors.
  • To understand the role of encoder hidden states versus attention mechanisms in encoding contextual information for disambiguation.

Proposed method

  • The study evaluates WSD performance on the ContraWSD test set, directly assessing translations of ambiguous nouns rather than contrastive pairs.
  • It compares two NMT architectures: a standard RNN-based model with one-layer attention and a Transformer model with multi-head attention.
  • Attention distributions are analyzed layer-by-layer to track how attention evolves from alignment to unaligned context token attention.
  • The paper examines the correlation between attention weights on ambiguous words and WSD accuracy across different attention ranges.
  • Error distributions are analyzed by absolute and relative frequency of word senses in the training data to assess data sparsity effects.
  • The analysis includes visualizations of attention patterns across layers, particularly in the Transformer, to trace the learning progression of alignment and context feature extraction.

Experimental results

Research questions

  • RQ1Do attention mechanisms in NMT models pay more attention to context tokens when translating ambiguous nouns compared to non-ambiguous words?
  • RQ2How do the attention distributions in vanilla one-layer attention and Transformer models differ during WSD?
  • RQ3Is there a correlation between higher attention weights on ambiguous words and improved WSD accuracy?
  • RQ4To what extent do data sparsity and low-frequency senses contribute to incorrect translations in NMT?
  • RQ5Do the encoder hidden states or the attention mechanism primarily encode contextual information necessary for WSD?

Key findings

  • WSD accuracy in NMT models is around 80.2% for RNN and 85.5% for Transformer, with data sparsity being a major cause of errors.
  • Attention mechanisms consistently assign higher weights to the ambiguous noun itself rather than to context tokens, contradicting the hypothesis that context is prioritized.
  • The first few layers of the Transformer attention mechanism learn to align source and target tokens, while later layers attend to related but unaligned context tokens.
  • Higher attention weights on ambiguous words correlate with higher WSD accuracy, suggesting that attention weight magnitude reflects disambiguation confidence.
  • Despite high attention to low-frequency senses, models still produce incorrect translations, confirming that data sparsity severely impacts performance.
  • The encoder hidden states, not the attention mechanism, are the primary carrier of contextual information for WSD in NMT models.

Better researchstarts right now

From reading papers to final review, dramatically reduce your research time.

No credit card · Free plan available

This review was created by AI and reviewed by human editors.