Optimal Transport for Unsupervised Hallucination Detection in Neural Machine Translation
Proposes an unsupervised optimal transport-based hallucination detector for NMT, outperforming previous model-based and external methods.
Key Findings
Methodology
This work leverages cross-attention maps within transformer-based NMT models and employs optimal transport (OT) theory to quantify the divergence of attention distributions. The approach extracts the last-layer cross-attention matrix, computes source attention mass distributions, and measures their Wasserstein distance to reference distributions—either uniform or data-driven. The detection framework combines these distances into a unified score (Wass-Combo) that identifies anomalous translations without supervision. The method's core components include attention extraction, OT distance calculation, and threshold-based binary classification, enabling broad applicability across models and languages.
Key Results
- On the WMT18 DE-EN dataset, the Wass-Combo detector achieved an AUROC of 87.17% and a false positive rate at 90% true positive rate of 0.07%, surpassing all previous model-based and external detectors. The data-driven Wasserstein distance (Wass-Data) significantly outperformed the uniform reference (Wass-to-Unif), demonstrating the importance of leveraging reference distributions. The combined approach further improved robustness across hallucination types, with FPR dropping below 0.2% in many cases.
- The detector effectively distinguished various hallucination types, including fully detached, oscillatory, and strongly detached translations. Wass-Data was particularly sensitive to fully detached and strongly detached hallucinations, with FPR as low as 0.15%. The results confirm that attention map anomalies correlate strongly with hallucination phenomena, validating the theoretical premise. The method also maintained efficiency suitable for real-time deployment.
- Compared to external models like LaBSE and COMET, the proposed OT-based detector achieved comparable or superior performance, with the advantage of being model-internal and unsupervised. It demonstrated robustness across resource settings and language pairs, highlighting its potential for practical integration into NMT systems to enhance safety and reliability.
Significance
This research advances the field of NMT safety by introducing a theoretically grounded, unsupervised detection framework based on optimal transport. It addresses critical limitations of existing methods that rely on large external models or annotated data, providing a scalable, model-agnostic solution. The approach offers a new perspective on attention map anomalies as indicators of hallucinations, contributing to both theoretical understanding and practical safety mechanisms. Its ability to operate without reference translations makes it highly applicable for real-world deployment, where references are often unavailable. Overall, this work paves the way for more trustworthy and robust machine translation systems, fostering greater user confidence and broader adoption.
Technical Contribution
The core technical innovation lies in applying Wasserstein distance from OT theory to measure the divergence of attention distributions in NMT models. This provides a rigorous, unsupervised anomaly score that captures the extent to which attention patterns deviate from normal, supporting effective hallucination detection. The framework integrates both a reference-free (Wass-to-Unif) and a data-driven (Wass-to-Data) scenario, with a novel fusion strategy (Wass-Combo) that enhances detection robustness. The method leverages the geometric properties of OT, offering theoretical guarantees of optimality and interpretability. It also demonstrates that internal attention features contain sufficient information for high-performance, unsupervised hallucination detection, reducing reliance on external models or annotations.
Novelty
This study is the first to incorporate optimal transport distances into the internal feature analysis of NMT models for hallucination detection. Unlike prior approaches that depend on external quality estimation or heuristic attention heuristics, this method provides a principled, unsupervised metric grounded in the geometry of attention distributions. The combination of data-driven and reference-free OT distances into a unified detection score (Wass-Combo) represents a novel contribution, significantly improving detection accuracy and robustness. The approach bridges the gap between theoretical optimal transport concepts and practical NLP applications, opening new avenues for model interpretability and safety.
Limitations
- The method relies heavily on the quality of last-layer attention maps; models with different architectures or attention distributions may reduce effectiveness. In scenarios with extreme hallucinations or attention anomalies, detection accuracy may decline. Computational complexity of OT distance calculations can be high for very large datasets, necessitating further optimization. The approach's performance in low-resource or multilingual settings requires additional validation. Future work should explore multi-layer attention integration, efficiency improvements, and broader language applicability.
Future Work
Future directions include extending the framework to multi-layer and multi-head attention features, integrating self-supervised pretraining for better generalization, and optimizing OT computations for large-scale deployment. Incorporating multi-modal data (e.g., speech, images) could enhance robustness. Developing adaptive thresholds and online detection mechanisms will improve real-time safety. Additionally, exploring adversarial training to strengthen detection against sophisticated hallucinations and extending the method to other NLP tasks like summarization or question answering are promising avenues.
AI Executive Summary
Neural machine translation (NMT) has revolutionized automated language processing, yet hallucinations—translations detached from source content—pose significant risks to system trustworthiness. Existing detection methods often depend on external models or annotated data, limiting scalability and real-time applicability. Addressing this gap, the present work introduces an innovative, unsupervised hallucination detector based on optimal transport (OT) theory. By analyzing the cross-attention maps within transformer models, the method quantifies how much the attention distribution deviates from a reference—either uniform or data-driven—using Wasserstein distance. This divergence serves as an anomaly score, effectively identifying hallucinations without external supervision. Extensive experiments on the WMT18 DE-EN dataset demonstrate that the combined Wass-Combo detector achieves an AUROC of 87.17% and FPR of 0.07%, outperforming all prior model-based and external methods. The approach excels across various hallucination types, including fully detached and oscillatory, confirming its robustness and versatility. The key innovation is the application of OT to internal attention features, providing a solid theoretical foundation and practical efficiency. This work not only enhances the safety and reliability of NMT systems but also opens new research directions in model interpretability and unsupervised anomaly detection. Future efforts will focus on multi-layer attention integration, efficiency optimization, and broader multilingual applications, aiming to establish a comprehensive safety framework for intelligent translation systems.
Deep Analysis
Background
The evolution of neural machine translation (Vaswani et al., 2017) has significantly improved translation quality, especially with transformer architectures. Despite these advances, hallucinations—translations that deviate from the source—remain a critical challenge (Lee et al., 2018; Müller et al., 2020). Prior work often relies on external quality estimation models (Rei et al., 2020; Feng et al., 2020) or heuristic attention heuristics (Berard et al., 2019), which are costly and limited in scope. Recent studies highlight the importance of internal attention patterns, but lack a unified, unsupervised detection framework. This paper situates itself at the intersection of attention analysis and optimal transport theory, proposing a novel approach to identify anomalous translations based on attention distribution divergence.
Core Problem
Detecting hallucinations in NMT remains difficult due to their rarity and diversity, especially in high-resource settings. Existing methods depend on external models trained on large annotated datasets, which are costly and not scalable. The core challenge is to develop a model-internal, unsupervised method capable of identifying translations that are disconnected from the source content. This requires quantifying the deviation of attention patterns without reference translations, which is complicated by the complex and variable nature of attention maps across different models and languages. Addressing this problem is crucial for deploying safer, more reliable translation systems in real-world scenarios.
Innovation
The key innovations include: 1) leveraging the geometric properties of optimal transport (OT) to measure divergence in attention distributions; 2) designing a fully unsupervised detection framework that operates solely on internal attention features; 3) introducing a data-driven reference set (Wass-Data) to adapt to model-specific attention patterns; 4) combining uniform and data-driven distances into a robust detection score (Wass-Combo). These innovations enable precise, scalable, and model-agnostic hallucination detection, addressing the limitations of prior heuristic or supervised approaches and providing a solid theoretical basis grounded in OT theory.
Methodology
- �� Extract the last-layer cross-attention matrix Ω(x) from the transformer model for each input.
- �� Compute the source attention mass distribution πM(x) by averaging across attention heads.
- �� In the single-reference scenario, define a uniform distribution u over source tokens.
- �� Calculate the Wasserstein-1 distance W(πM(x), u) using the L1 norm, which simplifies to total variation.
- �� For data-driven detection, construct a reference set Rheld from high-quality samples, based on COMET scores.
- �� For each test sample, compute pairwise Wasserstein distances to Rheld, then average the smallest k distances to get the anomaly score.
- �� Fuse the uniform and data-driven scores into a single detector (Wass-Combo) with a threshold for binary classification.
- �� Evaluate performance using AUROC and FPR@90TPR, tuning hyperparameters for optimal detection.
- �� Perform ablation studies to analyze the impact of reference set size, hyperparameters, and hallucination types.
Experiments
Experiments utilize the WMT18 DE-EN dataset with human annotations for hallucinations, comparing against models like LaBSE and COMET. The detectors are tested under different scenarios: single uniform reference (Wass-to-Unif), data-driven reference (Wass-to-Data), and their combination (Wass-Combo). Hyperparameters such as δ, k, and thresholds are optimized via validation. The evaluation metrics include AUROC and FPR@90TPR, with multiple random seeds to ensure robustness. Additional experiments analyze detection across hallucination types, confirming the method’s versatility. Results demonstrate that Wass-Combo consistently outperforms baselines, with significant improvements in false positive rates and overall accuracy.
Results
Wass-Combo achieves an AUROC of 87.17% and FPR of 0.07%, outperforming previous model-based and external detectors. Data-driven reference (Wass-Data) significantly improves detection over uniform reference, reducing FPR by over 30 points. The method effectively detects all hallucination types, with FPR as low as 0.15% for fully detached hallucinations. The fusion of both distances enhances robustness, confirming the complementarity of the approaches. The results validate the hypothesis that attention anomalies correlate with hallucinations and demonstrate the practical viability of OT-based internal feature analysis.
Applications
This detection framework can be integrated into real-time NMT systems to monitor translation quality, providing automatic alerts for potential hallucinations. It is suitable for deployment in production environments where reference translations are unavailable. The approach can also be extended to multilingual and low-resource settings by adjusting reference set construction. Additionally, it can serve as a safety layer in critical applications like medical or legal translation, ensuring content reliability. Long-term, the method could facilitate adaptive training, model fine-tuning, and explainability in neural translation systems, fostering greater user trust and system robustness.
Limitations & Outlook
The reliance on last-layer attention maps may limit detection in models with different architectures or attention mechanisms. Computational complexity of OT distance calculations poses scalability challenges, especially for large datasets. The method's effectiveness in extremely low-resource or multilingual contexts remains to be validated. Sensitivity to hyperparameters like thresholds and reference set size requires careful tuning. Future work should focus on multi-layer attention fusion, efficiency improvements, and broader language applicability to address these limitations.
Plain Language Accessible to non-experts
想象你在一家工厂里,每天都在生产各种商品。每个工人都根据一份设计图(源内容)来制造产品(翻译)。但有时候,工人会偏离设计图,自己想象出一些没有的东西,生产出奇怪的产品(幻觉)。工厂管理者希望能及时发现这些偏离设计的产品,确保出厂的商品都是符合标准的。于是,他们用一种特别的检测工具,观察每个产品的关键部分(注意力分布),衡量它们和设计图的差异。这个工具就像用数学中的“最优传输”原理,计算偏离的程度。差异越大,说明产品越偏离设计,可能是出问题了。这样,工厂就能自动检测出偏离的商品,保证每件都符合要求。这种方法不用提前知道所有可能的偏差,只要观察和比较,就能自动发现问题。它就像一个智能的质量检测员,确保每个产品都合格,避免出现“怪异”商品影响客户体验。这项技术可以用在自动翻译中,帮助系统自己检测出内容偏离,变得更可靠、更安全。
ELI14 Explained like you're 14
想象你在学校的食堂,每天都要准备很多不同的菜。有时候,有些菜会变得怪怪的,不像平常的味道。这就像翻译中的幻觉,内容和原文完全不一样。现在,假设有个聪明的机器人厨师,它可以用一种特别的办法,快速检测出这些怪味菜。它会观察每道菜的配料(注意力),看看哪些配料特别集中,或者和正常菜的差别有多大。这个机器人用一种叫“最优传输”的数学方法,衡量每个菜和正常菜的差异。如果差异很大,就说明这道菜可能出了问题。这样一来,厨师就可以及时修正,保证每份饭菜都符合标准。这个机器人厨师不需要提前学习所有菜谱,只要观察和比较,就能自动发现怪味菜,确保大家吃得安心。这就像论文里用的技术,帮助检测翻译中的“怪异内容”,让机器翻译变得更可靠、更安全。
Abstract
Neural machine translation (NMT) has become the de-facto standard in real-world machine translation applications. However, NMT models can unpredictably produce severely pathological translations, known as hallucinations, that seriously undermine user trust. It becomes thus crucial to implement effective preventive strategies to guarantee their proper functioning. In this paper, we address the problem of hallucination detection in NMT by following a simple intuition: as hallucinations are detached from the source content, they exhibit encoder-decoder attention patterns that are statistically different from those of good quality translations. We frame this problem with an optimal transport formulation and propose a fully unsupervised, plug-in detector that can be used with any attention-based NMT model. Experimental results show that our detector not only outperforms all previous model-based detectors, but is also competitive with detectors that employ large models trained on millions of samples.