Adding Interpretable Attention to Neural Translation Models Improves Word Alignment

TL;DR

Introduces an interpretable attention extension with SGD optimization, achieving near Giza++ accuracy in neural machine translation word alignment.

cs.CL πŸ”΄ Advanced 2019-01-31 53 views
Thomas Zenkel Joern Wuebker John DeNero
NMT Attention Word Alignment Transformer Model Interpretability

Key Findings

Methodology

The paper extends the Transformer by adding an alignment layer that solely attends to encoder outputs. It employs unsupervised training combined with stochastic gradient descent to optimize attention weights, maximizing target word likelihood. Multiple encoder representations (embeddings, encoder outputs, their average) are tested. During inference, attention weights are fine-tuned via gradient updates, leading to improved alignments. Experiments on German-English, French-English, Romanian-English datasets show significant reductions in AER, approaching Giza++ performance.

Key Results

  • On German-English, the naive average attention yields 50.9% AER, while the proposed method reduces it to 27.1%, close to Giza++'s 21.4%. In French-English, AER drops from 55.4% to 23.8%, outperforming FastAlign and comparable to Giza++. Romanian-English results show similar improvements, with AER decreasing from 45.7% to 32.3%. These results demonstrate the method's robustness across language pairs and datasets.
  • Optimization of attention weights via SGD, initialized with forward attention, consistently improves alignment quality. The approach effectively captures source-target word relations, especially in complex cases with subword units and non-literal translations.
  • The method's unsupervised nature and integration into existing translation models make it highly practical, reducing reliance on external alignment tools and enabling end-to-end training.

Significance

This work advances the interpretability of neural translation models by providing a high-accuracy, unsupervised word alignment mechanism. It bridges the gap between traditional statistical aligners and modern deep models, offering a transparent way to understand and improve translation systems. The approach enhances the usability of attention as an explanation tool, fostering trust and facilitating downstream tasks like lexicon injection and annotation projection. Its efficiency and simplicity promote wider adoption in multilingual NLP applications, especially for low-resource languages where annotated data is scarce.

Technical Contribution

The core technical innovation is the addition of an alignment layer without skip connections, which focuses attention solely on encoder outputs. The novel use of attention weight optimization via gradient descent to maximize target word likelihood is a significant departure from previous methods that treat attention as a static interpretability tool. This approach allows direct control over attention distributions, yielding alignments comparable to Giza++ without supervision. The framework is modular, easy to implement, and compatible with standard Transformer architectures, enabling seamless integration into existing translation pipelines.

Novelty

This is the first work to combine unsupervised attention matrix optimization with Transformer-based neural translation for high-quality word alignment. Unlike prior neural approaches requiring supervised signals or external tools, this method leverages the translation objective itself to refine attention weights, resulting in alignments that rival traditional statistical models. Its unique focus on attention weight tuning during inference sets it apart, providing a new paradigm for interpretable neural models.

Limitations

  • The method's effectiveness diminishes with longer, more complex sentences, especially in cases with high ambiguity or multiple valid alignments, due to limited context modeling. The reliance on initial attention from the forward pass means poor initializations can hinder convergence. Computationally, multiple gradient updates per sentence increase inference time, limiting real-time applicability. Additionally, the approach primarily targets source-to-target alignments, and extending it to bidirectional or multi-source scenarios remains challenging.

Future Work

Future research could explore integrating this attention optimization into joint translation and alignment training, reducing inference overhead. Extending the framework to multi-source or multi-lingual settings, and incorporating external lexical resources, could further improve accuracy. Developing more efficient optimization algorithms or approximations would make the approach scalable for large datasets and real-time applications. Additionally, applying similar techniques to other sequence tasks like summarization or question answering could broaden its impact.

AI Executive Summary

Neural machine translation has seen remarkable progress with Transformer models, which utilize multi-head self-attention to capture complex dependencies. Despite their success, the interpretability of these attention distributions remains limited, especially for extracting meaningful word alignments. Traditional tools like Giza++ and FastAlign, based on statistical models, still dominate in alignment tasks due to their transparency and accuracy. This paper bridges this gap by proposing a novel extension to the Transformer architecture, introducing a dedicated alignment layer that attends exclusively to encoder outputs. Unlike conventional attention, this layer is trained in an unsupervised manner, with attention weights refined through stochastic gradient descent to maximize the likelihood of target words. This approach allows the model to produce high-quality alignments without external supervision, achieving results comparable to Giza++ on multiple language pairs.

The core technical innovation lies in the direct optimization of attention weights during inference, a process inspired by feature visualization techniques in computer vision. By initializing attention matrices either randomly or based on forward pass attention, and then fine-tuning via gradient updates, the model learns source-target word correspondences more accurately. Extensive experiments on German-English, French-English, and Romanian-English datasets demonstrate substantial improvements in alignment error rate, with reductions from over 50% to below 30%. These results highlight the method's robustness and practical potential for enhancing translation interpretability and downstream NLP tasks.

This work significantly impacts both academia and industry by providing a scalable, unsupervised, and interpretable solution for word alignment within neural translation systems. It opens new avenues for integrating alignment insights into end-to-end models, facilitating better error analysis, lexicon injection, and annotation transfer. While promising, the approach faces challenges in handling long sentences, computational efficiency, and multi-source scenarios. Future directions include optimizing the inference process, extending to multi-lingual settings, and combining with external resources to further improve accuracy and applicability, ultimately advancing the transparency and effectiveness of neural language models.

Deep Dive

Abstract

Multi-layer models with multiple attention heads per layer provide superior translation quality compared to simpler and shallower models, but determining what source context is most relevant to each target word is more challenging as a result. Therefore, deriving high-accuracy word alignments from the activations of a state-of-the-art neural machine translation model is an open challenge. We propose a simple model extension to the Transformer architecture that makes use of its hidden representations and is restricted to attend solely on encoder information to predict the next word. It can be trained on bilingual data without word-alignment information. We further introduce a novel alignment inference procedure which applies stochastic gradient descent to directly optimize the attention activations towards a given target word. The resulting alignments dramatically outperform the naive approach to interpreting Transformer attention activations, and are comparable to Giza++ on two publicly available data sets.

cs.CL