Advancing Explainability in Neural Machine Translation: Analytical Metrics for Attention and Alignment Consistency
Anurag Mishra · 2024
Read Advancing Explainability in Neural Machine Translation: Analytical Metrics for Attention and Alignment Consistency by Anurag Mishra (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2412-18669.txt.
Introduction
Anurag Mishra studied how to measure explainability in neural machine translation in twenty twenty-four. Translation models are powerful but opaque; their attention patterns are often offered as a window into decisions, yet rarely checked. Mishra built a framework to test whether attention matches statistical word alignments and how it relates to translation quality.
New metrics include attention entropy, which gauges how focused attention is, and alignment agreement. On an English-German test set from WMT14 with a pre-trained mT5 model, sharper attention lined up with better interpretability. But sharper attention did not always mean better translations. The findings caution against reading attention as proof of quality, while giving builders concrete tools to audit translation systems.
Catalog record
| CREATOR | Anurag Mishra |
|---|---|
| YEAR | 2024 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 12 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2412-18669
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Advancing Explainability in Neural Machine Translation: Analytical Metrics for Attention and Alignment Consistency Anurag Mishra Abstract Neural Machine Translation (NMT) models have shown remarkable performance but remain largely opaque in their decision-making processes. The interpretability of these models, especially their internal attention mechanisms, is critical for building trust and verifying that these systems behave as intended. In this work, we introduce a systematic framework to quantitatively evaluate the explainability of an NMT model’s attention patterns by comparing them against statistical alignments and correlating them with standard machine translation quality metrics. We present a set of metrics—attention entropy and alignment agreement—and validate them on an English-German test subset from WMT14 using a pre-trained mT5 model. 1 Introduction Neural Machine Translation has achieved remarkable gains in translation quality during the last ten years, mainly due to Transformer-based architectures combined with large-scale pretraining. However, these models are complex black boxes, and it is hard to understand how they make their decisions. Attention mechanisms offer one potential interpretability lens by highlighting source tokens that influence each target token. However, recent work calls into question the direct interpretability of these attention distributions, since they are themselves not designed as explicit word alignments. Our goal is to close this gap by introducing quantitative measures and visual analyses relating internal attention patterns to external ground truth alignments and established quality metrics. This enables a far more systematic and trustworthy validation in the process of establishing the trust in NMT systems. Our evaluation examines how these explainability metrics relate to translation performance as measured by BLEU and METEOR. We find that attention patterns which more closely resemble statistical alignments correlate mildly with improved translation quality. Further, the attention entropy-being a measure of focus or diffuseness-correlates negatively with alignment agreement; this means that more peaked-and arguably more interpretable-attention distributions manage to align better with external alignment references. However, low entropy does not ensure good translation quality, and neither does high agreement in alignment, suggesting that interpretability and performance are related but not synonymous. We supplement our quantitative analysis by a suite of visualizations-heatmaps, histograms, scatter plots-providing insight into how and where the model focuses attention. These findings advance our understanding of NMT explainability and guide future efforts toward building more transparent, reliable machine translation systems. 2 Related Works The interpretability of the NMT model, particularly in the use of the attention mechanism, has been an active area of research. Understanding how attention contributes to the translation process is key for building trust and ensuring that model outputs align with human expectations. Early attention-based approaches laid the foundation for this line of work. [ 4 ] introduced global and local attention mechanisms, showing that guiding the model’s attention to relevant source tokens significantly improves translation quality. [ 2 ] further explored alignment by encouraging bidirectional consistency in attention matrices, ultimately refining both alignment and translation outcomes. Subsequent work has focused on the quality of attention weights as estimations of actual word alignment. [ 3 ] show that, while Transformer-based encoder-decoder attention frequently commits alignment errors, these weights still provide valuable information about how models balance the contributions of source and target tokens. Similarly, [ 1 ] show that entropyand distance-regularized attention can improve model interpretability and performance, particularly in low-resource settings. These studies together suggest that attention mechanisms, while imperfect, are nevertheless useful interpretability tools. We build on these results to propose a structured approach for quantitatively assessing the explainability of NMT’s attention patterns, connecting them with statistical alignments and standard translation quality metrics. By doing so, we want to provide a more structured way to assess when and how attention-based explanations can be trusted. 2.1 Explainability Component Building on this insight, our work contributes a systematic framework for evaluating and validating the explainability of NMT models’ attention patterns. We make use of statistical alignment tools, such as FastAlign, as a point of comparison by computing metrics including attention entropy and alignment agreement, which quantify the closeness between the model’s internal representations and intuitive, human-interpretable alignments. By correlating these explainability metrics with established translation quality scores, such as BLEU and METEOR, we aim to identify conditions under which attention serves as a reliable indicator of model decision-making. This structured, data-driven approach advances the field of NMT interpretability, offering a principled way to assess and ultimately improve transparency in machine translation systems. 3 Methodology 3.1 Model and Data Setup We employ a pre-trained mT5 model for English-German translation, fine-tuned on the WMT14 parallel corpus. Let \mathbf{x}=(x_{1},x_{2},\dots,x_{|X|}) be the source sentence and \mathbf{y}=(y_{1},y_{2},\dots,y_{|Y|}) the generated target sentence. The model’s decoder computes a probability distribution over the target vocabulary for each step t , conditioned on the source and previously generated tokens: P(y_{t}\mid\mathbf{x},y_{<t})=\text{softmax}(\mathbf{W}h_{t}), (1) where h_{t} is the decoder hidden state at time t , and \mathbf{W} is a learned projection matrix. 3.2 Attention Extraction and Entropy In Transformer-based NMT, attention is represented as a set of weights \alpha_{t,s} that indicate how much the target token at position t attends to the source token at position s . For a given target token y_{t} , the attention distribution over the source sentence is: \alpha_{t}=(\alpha_{t,1},\alpha_{t,2},\dots,\alpha_{t,|X|}),\quad\text{with}\;\sum_{s=1}^{|X|}\alpha_{t,s}=1. (2) To quantify the concentration or diffuseness of attention, we compute the attention entropy H_{t} : H_{t}=-\sum_{s=1}^{|X|}\alpha_{t,s}\log(\alpha_{t,s}). (3) Lower entropy indicates more focused attention on a smaller number of source tokens. We compute an average attention entropy H_{\text{avg}} over all target tokens in a sentence or corpus. 3.3 Statistical Alignments and Agreement Metric We obtain external alignment references using FastAlign, which provides a set of alignment pairs A=\{(s_{i},t_{j})\} , mapping source indices s_{i} to target indices t_{j} . To measure how well the model’s attention aligns with these references, we define an alignment agreement score. For each aligned pair (s_{i},t_{j})\in A , we retrieve the model’s attention weight \alpha_{t_{j},s_{i}} . The alignment agreement is then: \text{Agreement}=\frac{1}{|A|}\sum_{(s_{i},t_{j})\in A}\alpha_{t_{j},s_{i}}. (4) High agreement suggests that model attention corresponds closely to the external alignment references, thereby providing a more interpretable mapping between source and target tokens. 3.4 Translation Quality Metrics We evaluate translation quality using BLEU and METEOR. BLEU (Papineni et al., 2002) computes an n -gram precision score with a brevity penalty. Let p_{n} be the modified n -gram precision and r,c be the reference and candidate lengths: \text{BLEU}=\exp\left(\min\left(0,1-\frac{r}{c}\right)\right)\prod_{n=1}^{4}p_{n}^{1/4}. (5) METEOR (Banerjee and Lavie, 2005) aligns hypothesis and reference tokens using synonyms and stem variants, computing a harmonic mean of precision and recall with a fragmentation penalty. Although more complex than BLEU, we treat METEOR as: \text{METEOR}(H,R)=f(P,R,\text{matches}), (6) where f(\cdot) is a known scoring function that accounts for exact and semantic matches between the hypothesis H and reference R . 3.5 Correlation Analysis After computing attention entropy, alignment agreement, and quality scores (BLEU, METEOR), we assess their relationships using Pearson’s correlation. Let X and Y be random variables representing different metrics (e.g., X=H_{\text{avg}} and Y=\text{Agreement} ): \rho_{X,Y}=\frac{\text{Cov}(X,Y)}{\sigma_{X}\sigma_{Y}}, (7) where \rho_{X,Y} is Pearson’s correlation coefficient. Through correlation analysis, we identify whether and how strongly interpretability metrics relate to translation quality. 4 Results Table 1 Translation quality and interpretability measures are reported on T5-Small, T5-Base, and T5-Large. BLEU and METEOR quantify the translation quality; average attention entropy measures the degree of attention concentration. In larger models, BLEU and METEOR scores were higher, and entropy