Constraining the Transformer NMT Model with Heuristic Grid Beam Search

Longyue Wang, Guodong Xie, Andy WayAmta 2020

TL;DR

This paper introduces a "Heuristic Grid Beam Search" (HGBS) method to improve domain adaptation for Transformer-based Neural Machine Translation (NMT). By leveraging multi-head attention to guide constraint placement, HGBS significantly speeds up decoding and prunes hypotheses while maintaining translation quality, making it more practical for low-resource domain adaptation.

What Problem Does This Paper Address?

Neural Machine Translation (NMT) models, particularly the Transformer architecture, have achieved state-of-the-art performance. However, adapting these models to specific domains (e.g., legal, medical) often requires ensuring that certain domain-specific terms or phrases appear in the translated output. This is known as constrained decoding. While methods like Grid Beam Search (GBS) exist for this, they can be computationally expensive and slow, especially with many constraints. Existing approaches primarily rely on the constraints themselves and discard valuable source-side information. This paper addresses the challenge of efficiently and effectively performing constrained decoding within the Transformer architecture for domain adaptation, specifically by better utilizing source-side information to guide the process.

Methods

The authors first reimplement the Grid Beam Search (GBS) method for the Transformer model, which they call GBS-T. They then propose a novel approach called "Heuristic Grid Beam Search" (HGBS). HGBS enhances GBS by incorporating source-side information derived from the Transformer's multi-head attention mechanism.

Here's how it works:

  • Leveraging Multi-Head Attention: The core idea is to use the attention weights from the Transformer's decoder (specifically, the last layer) to understand how target words align with source words.
  • Source-Informed Filtering: When considering a target constraint, HGBS uses the attention weights to identify the most relevant source word positions for that constraint.
  • Heuristic Guidance: This source-side alignment information acts as a filter, guiding the decoder to place constraints in more probable and correct positions. This helps prune unnecessary hypotheses and reduces the search space.
  • Algorithm: The HGBS algorithm modifies the standard GBS by adding a step to retrieve attention weights and calculate a probability score (PA) indicating the likelihood of a constraint being relevant at the current decoding step. If this score exceeds a threshold (pth), the constraint is considered for expansion.

Datasets

The experiments were conducted on two domain adaptation tasks:

  • English-German (EN-DE):
    • Training Corpus: 4.4 million segments from Europarl and CommonCrawl.
  • Target Domain Data: Autodesk Post-Editing corpus (100,000 training, 1,000 test sentences) for software localization. Constraints were extracted using Pointwise Mutual Information (PMI).
  • Chinese-English (ZH-EN):
    • Training Corpus: 1.25 million segments from LDC corpora (primarily News domain).
  • Target Domain Data: Autodesk Post-Editing corpus (159,816 training, 1,000 test sentences). Constraints were extracted using PMI.

The paper notes that the Autodesk Post-Editing corpus is significantly different from the general domain corpora, making it a challenging testbed for domain adaptation.

Key Insights and Ideas

  • Source-Side Information is Crucial: The paper strongly suggests that simply using target-side constraints is insufficient. Incorporating source-side alignment information from the Transformer's attention mechanism is key to improving efficiency and accuracy in constrained decoding.
  • Attention as a Constraint Placement Guide: The multi-head attention mechanism, which is fundamental to the Transformer, naturally provides alignment information. This information can be effectively repurposed to guide the placement of constraints, preventing them from being forced into incorrect positions.
  • Pruning for Efficiency: By using attention to filter out less likely constraint placements, HGBS significantly prunes the search space, leading to faster decoding times without sacrificing translation quality.
  • Domain Adaptation Feasibility: The work demonstrates that constrained decoding, particularly with the proposed HGBS method, is a viable and effective strategy for domain adaptation, especially in low-resource scenarios where domain-specific terminology is critical.

Key Results

  • Translation Quality: HGBS-T achieved comparable BLEU and METEOR scores to GBS-T on both EN-DE and ZH-EN tasks. On EN-DE, it was slightly lower than GBS-T in BLEU but matched its METEOR score. On ZH-EN, it was slightly better in BLEU and similar in METEOR. Both GBS-T and HGBS-T significantly outperformed the baseline NMT model.
  • Decoding Speed: HGBS-T significantly reduced decoding time compared to GBS-T. It pruned up to 30% of hypotheses and saved up to 20% of decoding time, especially noticeable with an increasing number of constraints.
  • Threshold Impact: The alignment threshold (pth) plays a role. Small values of pth maintained performance, while larger values led to a decrease in translation quality, suggesting a trade-off between filtering strictness and accuracy. The authors settled on pth = 0.1.
  • Alignment Quality Correlation: The study found a strong negative correlation between alignment error (MSE) and BLEU score, indicating that better word alignment quality leads to better translation quality.

Limitations and Future Work

  • Limitations:
    • The paper acknowledges that while HGBS-T performs comparably to GBS-T, it slightly underperforms GBS-T in BLEU on the EN-DE task when using unrefined models.
  • The effectiveness of the method relies on the quality of the multi-head attention alignment. If the alignment is incorrect, constraints might be placed in the wrong position.
  • Future Work:
    • Further optimization of HGBS to improve translation quality, reduce decoding time, and decrease complexity by better exploiting multi-head alignment information.
  • The paper also mentions refining the Transformer model using Guided Alignment Training to further improve the quality of multi-head attention, which showed promising results in Table 5.

Summary updated

BibTeX
@inproceedings{wang2020constraining,
  author = {Longyue Wang and Guodong Xie and Andy Way},
  title = {{Constraining the Transformer NMT Model with Heuristic Grid Beam Search}},
  booktitle = {Amta},
  year = {2020},
}
Figure