Detecting and Mitigating Hallucinations in Machine Translation: Model Internal Workings Alone Do Well, Sentence Similarity E ven Better (2023)

Abstract: While the problem of hallucinations in neural machine translation has long been recognized, so far the progress on its alleviation is very little. Indeed, recently it turned out that without artificially encouraging models to hallucinate, previously existing methods fall short and even the standard sequence log-probability is more informative. It means that internal characteristics of the model can give much more information than we expect, and before using external models and measures, we first need to ask: how far can we go if we use nothing but the translation model itself ? We propose to use a method that evaluates the percentage of the source contribution to a generated translation. Intuitively, hallucinations are translations “detached” from the source, hence they can be identified by low source contribution. This method improves detection accuracy for the most severe hallucinations by a factor of 2 and is able to alleviate hallucinations at test time on par with the previous best approach that relies on external models. Next, if we move away from internal model characteristics and allow external tools, we show that using sentence similarity from cross-lingual embeddings further improves these results. We release the code of our experiments.

## introduction hallucinations in machine translation (mt) are cases when the model generates output that is partially or fully unrelated to the source sentence. while generally this phenomenon is not frequent and has low impact on corpus-level automatic metrics, the impact of hallucinations on user experience can be rather dramatic. for example, if a translation system generates the staff were very friendly and helpful in response to an input sentence about e.g. a marvelous view from the window, a user is unlikely to trust this system in future. while the problem of hallucinations is known, addressing it remains challenging. firstly, hallucinations are very rare. this is why previous work mostly resorted to settings where models are encouraged to hallucinate, by e.g. artificially perturbing source sentence @xcite , adding specific types of noise to the training data @xcite , working under domain shift @xcite , among others @xcite . secondly, hallucinations are hard to identify with automatic metrics. often, hallucinations were defined as translations with low quality according to some metric such as adjusted bleu or chrf @xcite @xcite or translations satisfying some heuristic condition @xcite . overall, it is not clear whether proposed methods detect naturally occurring hallucinations well. recently, when revisiting previous work in a relatively clean setting, @xcite found that existing detection methods fall short and the standard sequence log-probability is the most informative. to show this, the authors gathered a large dataset with professional annotations of translations that, according to 10 previously proposed methods, are likely to be hallucinations. this data (hallucinations along with the model that generated them) made it possible to first, evaluate the performance of various detection methods and second, to work on alleviating hallucinations at test time. for the latter, the idea is "detect-then-rewrite": after flagging a translation as likely to be pathological, generate several alternative hypotheses and pick the best one relying on some measure. so far, the best realization of this general framework uses sequence log-probability -seq-logprob -for detection, monte carlo dropout @xcite to generate several alternative translation hypotheses, and comet-qe to pick the final candidate (see @xcite for the details). we use the same test bed and substantially improve previous results. regarding hallucination detection, we view the observation that seq-logprob outperforms previous (specifically targeted to hallucinations) methods as follows: internal model characteristics may contain much more information than we expect. therefore, before developing or using external models and measures, we ask: how far can we go if we use nothing but the translation model itself ? we propose to use a method that evaluates the percentage of the source contribution to a generated translation. intuitively, since hallucinations are translations that are "detached" from the source, low source contribution should be able to identify hallucinations. despite the fact that understanding hallucinations was one of the motivations behind the first method evaluating relative source and target contributions, both existing methods only looked at highly artificial hallucinations @xcite . we propose to use alti+ by @xcite , the method that aggregates layer-wise tokens attributions, for both hallucination detection and reranking in the "detect-then-rewrite" pipeline. for detection of the most severe hallucinations, it is twice more accurate than seq-logprob. for reranking, it performs on par with the previous best comet-qe. all in all, we improve the overall pipeline results by relying on internal model characteristics alone. when allowing external tools, previous work mostly focused on different ways to automatically evaluate quality of a translation example, either with string-based methods or neural quality estimation systems. this idea (the better we estimate translation quality, the better we are at detecting hallucinations) is natural: hallucinations are lowquality translations in the first place. however, implementing this idea in practice is challenging: even state-of-the-art quality estimation system substantially fails @xcite . we hypothesize that instead of targeting quality evaluation, it might be beneficial to use models trained with a rather different objective. indeed, as we show in this paper, similarity between the source and a translation estimated via cross-lingual sentence embeddings outperforms the best internal method. apart from cross-lingual sentence similarity (which is expected to be sensitive to highly incorrect translations), we find that cross-lingual natural language inference models (less anticipated in the context of machine translation) also perform quite well. to the best of our knowledge, we are the first to apply these models for hallucination detection. overall, we show that: ## background and setting in this section, we describe the framework and data we use for evaluation of hallucination detection and mitigation methods. this framework was proposed by @xcite and consists of a large dataset of annotated translations along with the model that produced them. to the best of our knowledge, this is the only released data that can be used to analyze hallucinations in a "clean" setting. ## hallucination detection methods generally, methods for handling hallucinations can be either internal, i.e. using only information coming from the translation model itself, or external, i.e. using auxiliary models. in addition to these, we also consider "oracles" relying on reference translation. note that these cannot be used in preventive settings when references are not available; here we use them only for analysis. ## mitigating hallucinations at test time finally, let us come to the second part of the "detectthen-rewrite" pipeline: for a flagged ## conclusions we start by asking how far we can go at detecting and mitigating hallucinations if we use nothing but the translation model itself. turns out, we can improve the results of the overall "detect-then-rewrite" pipeline by evaluating the percentage of source contribution to a generated translation: translations with low source contribution are likely to be "detached" from the source, i.e. hallucinations. for detecting the most severe type of hallucinations, this method improves previous results twice; for mitigating hallucinations at test time, it matches the hallucination reduction rate of the previous best external method. we believe this can motivate future research on model analysis. when allowing external models, we expand the methods for handling hallucinations from models specialized for quality estimation to a broader set of objectives, e.g. sentence similarity from cross-lingual embeddings. apart from showing that labse improves previous results significantly, we also find that models so far overlooked in the context of machine translation (e.g. natural language inference) can be beneficial. we hope future work will build on this idea.