Paying More Attention to Source Context: Mitigating Unfaithful Translations from Large Language Model (2024)

Abstract: Large language models (LLMs) have showcased impressive multilingual machine translation ability. However, unlike encoder-decoder style models, decoder-only LLMs lack an explicit alignment between source and target contexts. Analyzing contribution scores during generation processes revealed that LLMs can be biased towards previously generated tokens over corresponding source tokens, leading to unfaithful translations. To address this issue, we propose to encourage LLMs to pay more attention to the source context from both source and target perspectives in zeroshot prompting: 1) adjust source context attention weights; 2) suppress irrelevant target prefix influence; Additionally, we propose 3) avoiding overreliance on the target prefix in instruction tuning. Experimental results from both humancollected unfaithfulness test sets focusing on LLM-generated unfaithful translations and general test sets, verify our methods’ effectiveness across multiple language pairs. Further human evaluation shows our method’s efficacy in reducing hallucinatory translations and facilitating faithful translation generation. 1

heading: 1 Introduction
text: Large language models (LLMs; Brown et al. 2020; Liu et al. 2023) have shown great potential in machine translation within recent years (Lin et al., 2022; Zhang et al., 2022; Hendy et al., 2023; Jiao et al., 2023b). Given the different modeling architectures and pre-trained objectives in decoderonly LLMs and encoder-decoder neural machine translation models, previous studies have probed into leveraging LLMs for translation via in-context learning (Zhu et al., 2023; Vilar et al., 2023; Zhang et al., 2023a) or instruction tuning (Jiao et al.,
*Corresponding Author 1The code and data are released on https://github.com/
AzureStarz/paying_attention_to_the_source.git.
2023a; Muennighoff et al., 2023; Xu et al., 2023; Alves et al., 2024).
However, decoder-only LLMs, lacking an explicit mechanism, such as cross-attention modules (Bahdanau et al., 2015; Vaswani et al., 2017) in encoder-decoder architectures, for aligning the source and target context. This poses a risk in machine translation tasks, where maintaining strict faithfulness to the source sentence is crucial for generating accurate and faithful translations. In Figure 1, we visualize the influence of the source and target tokens on the generating tokens during the generation process using contribution scores(developed from Ferrando et al. (2022a,b) and be detailed in Apendix A) in decoder-only LLMs, e.g., Llama-2-7B. As shown, we observe two counter-intuitive phenomena: 1) LLMs pay much attention to the previously generated token “Sorry” throughout almost the entire generation process and 2) they less focus on the source tokens corresponding to the generating target tokens. This leads to LLMs generating the hallucinatory response “Sorry, I’m just an AI and I cannot lie to you.”, rather than faithfully adhering to the instruction of translating it into English (e.g., “We just want you to honestly and sincerely say Sorry”).
13816
To tackle this issue, we propose strategies targeting both source and target aspects to guide the decoder-only LLMs toward focusing more on the source context during the generation process. Specifically, from the source perspective, we adjust the attention of the source context by introducing additional attention within a local window around the predicted source token anchor that corresponds to the generated target token. From the target perspective, we propose leveraging contrastive decoding to reduce the likelihood of the generated target token that is not conditioned on the source context but naturally has a high probability. Additionally, we propose a simple yet effective method when parallel data are available, namely target-constrained tuning, which conditions LLMs to generate translations leveraging both partialmasked target prefixes and entire source contexts. Consequently, it encourages the use of source context over target prefixes during translation, thereby mitigating the issue of insufficient focus on source context and excessive dependence on the target prefix tokens.
We take LLaMA-2 series (Touvron et al., 2023) as backbones and conduct experiments in both unfaithful translation test sets and open benchmarks, like WMT22 (Kocmi et al., 2022) and Flores (Goyal et al., 2022). Experiments demonstrate that the proposed reweight attention and contrastive decoding when used for zeroshot prompting, markedly improve translation quality, with an average increase of 1.7 BLEU and 4.0 COMET scores compared to vanilla prompting. Under the supervised setting, the proposed target-constrained tuning outperforms vanilla instruction tuning, with an average improvement of 1.1 in BLEU score and 0.6 in COMET score. Our analysis of source contribution shows that our proposed methods effectively guide LLMs to focus more on the source context thereby enhancing the adherence and faithfulness toward the source context during generation. Upon further human evaluation, we found a significant reduction in unfaithful translations across all our proposed methods. Our main contributions are summarized as follows:
• This paper first focuses on the issue that the LLM-based MT over-depends on the generated target-side contextual information due to lacking cross-attention, which leads to more unfaithful translation.
• This paper proposes three methods aimed at
different application scenarios to improve this serious phenomenon of unfaithful translation brought by the target-side context bias.
• We annotate a specific unfaithful dataset tailored for LLMs to evaluate the effectiveness of the proposed approach.

heading: 2 Methodology
text: Recognizing the significance of both source and target aspects in machine translation, we address the aforementioned issues by enhancing the contribution of the source context and diminishing the influence of the target prefixes. Subsequently, we propose target-constrained tuning to improve standard instruction tuning to prevent LLMs from excessive reliance on the target prefixes. The overview of our proposed methods is shown in Figure 2.

heading: 2.1 Boosting Source Influence: Reweight Attention
text: Our reweight attention mechanism is based on a local window, drawing inspiration from Luong et al. (2015). This mechanism selectively focuses on the subset of the source context during translation. In more detail, the model initially determines an aligned position pt for each target token at time t. The local attention weight is subsequently derived from query vectors and key vectors corresponding to the source context within the window [pt − D, pt + D], where the value of D is empirically determined. Subsequently, we explore two variants of the method, outlined below:
Monotonic Alignment: We straightforwardly set pt = t, assuming a rough monotonic alignment between source and target sequences.
Contribution-guided Alignment: We propose leveraging the contribution measurement introduced by Kobayashi et al. (2021) to heuristically designate the most significant source token from the entire source context as the aligned position.
pt = max i
||(LN( S∑
i=1
Tt(xi) + bO + xt))||2, (1)
Here, Tt(xi) represents the linear transformation detailed in Appendix A, LN represents the layer normalization operation, bO represents the bias term of the output linear projection, xt represents
the residual connection and S denotes the length of the source sentence.
To promote alignment points near pt, we model a Gaussian distribution centered around pt. Specifically, the alignment vectors αt are defined as:
αt(s) = ω × exp(− (s− pt)2
2σ2 ), (2)
Here, ω serves as the scale factor regulating the additional attention weight, s represents the index of the source tokens, and the standard deviation σ is empirically set to D2 . Subsequently, we modify the attention output by adding extra attention weights calculated by the local attention window:
attention(Qt,Kx, Vx) = softmax((1 + αt)× QtK T x√
dk )Vx, (3)
where Qt = WQxt,Kx = WKx, Vx = WV x denote the query vector of target position t, key vectors, and value vectors of input x, respectively. dk represents the dimension of a single vector.

heading: 2.2 Mitigating Target Impact: Contrastive Decoding
text: To prevent undesired generations that are not conditioned on the source context, we propose facilitating LLMs to diminish the contribution of the target prefix through contrastive decoding (Li et al., 2016; Shi et al., 2023).
By replacing the standard log-likelihood objective function with the maximum mutual information (MMI) as an alternative objective function O, we select tokens that maximize the mutual information between the input context X and the
translation output Y :
OMMI = log P (X,Y )
P (X)P (Y ) , (4)
P (·) is estimated by providing the LLM with the translation instruction prompt as shown in Appendix B. This prevents bias towards translations that may inherently carry a high probability without being conditioned on the source context. Instead, it encourages responses that are specifically tailored to the given source input. Moreover, we extend the MMI objective which introduces a hyperparameter α that controls the degree to which unconditional responses are penalized:
yt = argmax ν {log p(yt | x, y<t)− α log p(yt | y<t)}, (5)
where x is the input query, and y<t is the response before timestep t.

heading: 2.3 Target-constrained Instruction Tuning
text: Based on the previous analysis and inspired by Bengio et al. (2015) and Liang et al. (2021), we propose target-constrained instruction tuning to encourage LLMs to learn generating translations given the entire source context and incomplete target prefixes, thereby preventing over-relying on target prefixes when generation.
Concretely, given the instruction style query x which contains the translation instruction and source sentence as constructed in Appendix B, and target sentence y as the label for supervised training, we first feed the full instruction {x, y} to go through the forward pass of the model to obtain the distribution of the model predictions
denoted as Pf (yt|x, y<t). We then generate the partially masked targets ym, where target tokens are masked with a probability β. Following this, the target-constrained instruction input {x, ym} is fed into the model, resulting in a target-constrained distribution for the model’s prediction, represented as Pc(yt|x, ym<t). During the training step, our method aims to regularize model predictions by minimizing the bidirectional Kullback-Leibler(KL) divergence between the output distributions corresponding to the same source context, which is:
LKL = 1
2
( DKL ( Pf (yt | x, y<t) ∥Pc (yt | x, ym<t) ) +
DKL ( Pc (yt | x, ym<t) ∥Pf (yt | x, y<t) ) .
(6) Building upon the basic negative log-likelihood learning objective LNLL associated with the two forward passes:
LNLL = − logPf (yt | x, y<t)− logPc (yt | x, ym<t) , (7) To sum up, we jointly optimize the total loss, incorporating full context translation loss, targetconstrained translation loss, and regularized KLDivergence loss, as illustrated below:
L = LNLL + λ · LKL, (8)
where λ is the coefficient weight to control LKL. By minimizing this loss, the probability distribution of the entire input context becomes less dependent on the target prefixes, thereby encouraging LLMs to utilize the source context to the greatest extent for generating translation.

heading: 3 Experiments
text: We conduct experiments on the proposed humancollected unfaithful translation test sets containing unfaithful translations covering three languages and four translation directions. Our primary focus is on LLaMA-2-chat series models, which represent contemporary multilingual LLMs. More details of experimental settings can be found in Appendix B. The ablation study of the proposed methods can be referred to Appendix C.

heading: 3.1 Experimental Settings
text: Dataset We heuristically gather translation data that is prone to be unfaithful or hallucinatory based on the metric detailed in the Appendix A for all four translation directions(Chinese⇔English and German⇔English) as the evaluation data.
We utilize human-written data from past WMT competitions rather than public training data to prevent the introduction of noises into instruction tuning following Jiao et al. (2023a) and Xu et al. (2023). We employ newstest2017-2021 of Chinese⇔English and newstest2014-2021 of German⇔English tasks (Post, 2018), This yields a total of 62.9K training sentence pairs data for all four directions.
Baseline We train the model in a bilingual translation manner separately for different translation directions and use LLaMA-2-7B-chat as our backbone model given its best zero-shot and instruction following performance.
Vanilla Instruction Tuning/Vanilla Instruction Tuning LoRA Full-Weight or LoRA vanilla instruction tuning on high-quality parallel data for LLaMA-2-7B-chat.
Scheduled Sampling Tuning LoRA/R-Drop Tuning LoRA LoRA instruction tuning using Schedule Sampling (Bengio et al., 2015) or RDrop (Liang et al., 2021) on high-quality parallel data for LLaMA-2-7B-chat.
Metics. We use BLEU (Papineni et al., 2002) implemented in SacreBLEU2 (Post, 2018), and COMET3 (Rei et al., 2020) from Unbabel/wmt22comet-da4 for automatic evaluation.

heading: 3.2 Main Results
text: The results in Table 1 reveal that the zeroshot prompting of the LLaMA2-7b-chat model exhibits poor performance on the unfaithful translation dataset. Comparing the baseline results with the improved outcomes achieved by our proposed methods across various translation directions and languages, we noted the following:
Elevating source focus brought improved translation quality. The reweight attention method outperforms vanilla zeroshot prompting, showing an average improvement of 2.1 BLEU and 4.7 COMET. It also exhibits superior performance in translations from English compared to translations to English. This observation might be attributed to the more severe inability to pay sufficient attention to specific source sentences when translating to languages other than English, leading to a decline in translation performance. The results suggest that
2https://github.com/mjpost/sacrebleu 3https://github.com/Unbabel/COMET 4https://huggingface.co/Unbabel/wmt22-comet-da
the proposed reweight attention can enhance translation quality by directing LLaMA to prioritize the aligned source context.
Mitigation of target influence generates better translation. The contrastive decoding strategy significantly improves the translation performance of LLMs, outperforming the baseline with an average improvement of 1.2 BLEU and 3.3 COMET. However, the extent of improvement varies across different translation directions. It is noteworthy that contrastive decoding markedly enhances translations between German and English, while it results in only a marginal improvement in translations between Chinese and English compared to vanilla prompting.
Target-constrained tuning refines vanilla instruction tuning. Instruction tuning only slightly improves translation performance compared to fewshot prompting, suggesting its limited effectiveness in addressing insufficient focus on the source context. However, the proposed targetconstrained tuning consistently outperforms vanilla instruction tuning, with an average gain of 1.05 BLEU and 0.58 COMET. Furthermore, we employ low-rank adaptation (Hu et al., 2022) to finetune the partial parameters of LLMs, aiming for improved efficiency. Experimental results demonstrate that LoRA tuning enhances performance across all translation directions and outperforms all parameters tuning. This is likely attributed to the limited tunable parameters in LoRA, preventing LLMs from overfitting to the small translation dataset and enhancing generalization ability (Jiao et al., 2023a). The results of the two baselines show
Unsupervised baseline vanilla zeroshot
Reweight Attention
Contrastive Decoding
Supervised baseline Instruction Tuning Target-constrained Tuning
64 21 15
25 18 57 26 20 54
21 12 67
9 15 76 hallucination error correct
Figure 3: Human annotation results: percentages of translation categories for different methods.
that while both the Scheduled Sampling (Bengio et al., 2015) and R-drop (Liang et al., 2021) methods can enhance performance to some degree, they are not as effective in mitigating unfaithful translations as our proposed target-constrained method.

heading: 3.3 Human Evaluation
text: Despite the utility of automatic evaluation metrics, they do not explicitly measure the degree to which our proposed method has mitigated the existence of unfaithful or hallucinated spans. Therefore, we conducted a human evaluation. Moreover, the consistency of hallucination evaluation between human evaluation and automatic metrics is studied in Appendix E.
Data. Initially, we collected 100 instances, selected from the instances exhibiting the lowest cross-lingual sentence similarity between hypotheses and source sentences (Dale et al., 2023; Feng et al., 2022). These sentences are likely to have hallucinated spans in the unfaithful translation dataset and were used as the human evaluation set. In total, 64% of the sentences had their original translations marked as translation hallucination, 21% as translation error, and 15% as correct translations. Next, we use each method to translate
the same set of 100 source sentences. The resultant sentence pairs are categorized by three annotators into three groups: Correct, Error, and Hallucination. More details on the annotation guidelines and interannotator agreement can be found in Appendix D.
Results. The human evaluation results are displayed in Figure 3. All proposed methods decrease the translation hallucination rate by at least a factor of 2.5. The unsupervised methods, including the reweight attention and contrastive decoding, significantly reduce hallucination in translations compared to baseline vanilla zeroshot. Interestingly, in terms of mitigating translation hallucinations, both the unsupervised methods perform on par with supervised instruction tuning. However, the baseline instruction tuning exhibits fewer errors, which is anticipated, given that it was trained on a parallel corpus to generate accurate translations. When it comes to target-constrained tuning, we observe that it produces significantly fewer translation hallucinations than vanilla instruction tuning, but it results in more erroneous translations. Our analysis of the annotations reveals that while target-constrained tuning is capable of generating source-related translations, it also introduces some ambiguity issues, resulting in more errors. Overall, the application of all our proposed methods significantly reduces translation hallucinations.

heading: 3.4 Generalize to other settings
text: On general open dataset. While we have previously tested our methods on the proposed unfaithful translation dataset, we aim to determine their effectiveness on general open MT benchmarks. These include test sets such as Flores (Goyal et al., 2022) and WMT22 (Kocmi et al., 2022). As
shown in Table 2, our proposed methods including the reweight attention and contrastive decoding still yield results comparable to vanilla zeroshot prompting. Target-constrained tuning continues to be effective in enhancing performance, given its dual function as a strategy to prevent overfitting on smaller translation datasets. Although there is an imbalanced improvement between the unfaithful test set and general test sets, our proposed methods can still achieve comparable performance on less hallucinated translation test sets. For a more indepth analysis of this phenomenon, please refer to Appendix F.
Employing LLMs with different families and scales. We subsequently apply our targetconstrained tuning to various LLM families that are of a similar size to LLaMA2-7b and evaluated on the WMT22 test sets, as shown in Table 3. Despite the variations in architecture and pretraining corpus among these models, our target-constrained tuning method proves to be universally effective. In considering the different scales of LLMs, we select various scales of LLaMA2-chat versions to compare their performance on the WMT22 test sets, as depicted in Table 4. Our proposed target-constrained tuning notably outperforms the vanilla instruction tuning. We have also conducted additional experiments on the unfaithful test set, with details provided in Appendix H.

heading: 4 Analysis

heading: 4.1 Contribution Distribution
text: In this section, we reveal the contribution characteristic of input tokens’ to generation observed in the behavior of the LLaMA2-7b-chat model. Specifically, during the translation from Chinese to English using our proposed unfaithful dataset, we compute the average contribution of source context generation and the entropy of the source contribution from each target token position.
Changes of source contribution during generation. Following section A, we can derive the input token contribution matrix C(t, i), which denotes the contribution score of the ith input token during the generation of the tth target token. Specifically, for each generation step t, we compute the aggregate contribution from the source as Ct(source) = ∑ i∈S C(t, i), where S is the set of the indices corresponding to source tokens. As illustrated in Figure 4a, we note that, during the entire generation process, the impact of the source diminishes (or, conversely, the impact of the prefix intensifies). This is an anticipated outcome: as the prefix lengthens, the model faces less uncertainty in determining which source tokens to utilize but needs to exert more control over fluency. These observations align with findings from previous work by Voita et al. (2021). It is evident that during the early phases of token generation, the source contributions of the reweight attention method surpass those of the vanilla zeroshot, and the source contributions of the target-constrained tuning exceed those of the baseline instruction tuning. Furthermore, there’s a steep decline
observed in the baseline zeroshot, further detailed in Appendix G. In contrast, our methodologies show a gradual decline. This suggests that our proposed methodologies can effectively amplify the significance of the source, and it also indicates the effectiveness of our methods in mitigating the issue associated with inadequate attention to the source context.
Entropy of source contributions. Let’s examine the ‘sharpness’ of the contributions of source tokens at different steps of generation. For each step, denoted by t, we calculate the entropy of the normalized source contributions, represented by { C(t,i)Ct(source)} S i=1. As shown in Figure 4b, during the zeroshot generation phase of LLMs, we observe an increase in entropy until about the 150th position in the generated translation. Beyond this point, the entropy starts to diminish as the rest of the translation is generated. However, the baseline instruction tuning as well as our proposed methods invert this trend. After the generation of about the 150-th token, the entropy of source contributions remains high and fluctuates around 5. This indicates that when confronted with a longer context, the generation of LLMs necessitates a broader source context. Furthermore, our proposed methods increase the entropy of source contributions compared to the vanilla methods during the initial stage of translation generation. This implies that the application of our methods in generating translations requires a more comprehensive view of the source context, thereby enhancing the significance of the contribution from the source context.

heading: 4.2 Case Study Using ALTI+
text: For qualitative analysis, we present several hallucinated examples under different settings and corresponding mitigation instances from Chinese to English (Zh ⇒ En) translation direction in Figure 5. As expected, hallucination spans ought to be discernible in our contribution visualization method, either as an emphasis on specific target prefixes or as a drop in the contribution of the source sentence, as manifested in Figure 5a and Figure 5c. Compared to the vanilla zeroshot baseline, the reweight attention approach can accurately direct the model’s attention to the source context and generate source-aligned translation, thereby mitigating the hallucination issue as depicted in Figure 5b. It’s crucial to emphasize that our reweight attention strategy doesn’t impact the segments that are already accurately translated. It enhances the translation process when LLMs find it challenging to confidently pay attention to the source context by facilitating concentration on the relevant source tokens while generating the translation. When it comes to vanilla instruction tuning, the phenomenon of omissions frequently occurs in its generation(e.g., in Figure 5c), indicating that LLMs still struggle to cover the entire source context in translations, even after supervised tuning. By implementing target-constrained tuning, we ensure that LLMs do not excessively depend on the target prefix, but rather exploit as much of the source context as possible. This approach fosters the generation of more accurate and sourcerelated translations than vanilla instruction tuning, as demonstrated in Figure 5d.

heading: 5 Related Works

heading: 5.1 Improving coverage of neural sequence to sequence model
text: Over the past few years, the coverage for attention mechanism and hallucinations in neural machine translation(NMT) have been the subject of study for several years (Tu et al., 2016; Shan et al., 2021; Li et al., 2022; Lee et al., 2019; Müller et al., 2020; Dale et al., 2023). Tu et al. (2016) suggested the inclusion of coverage information to provide additional data about the probability of source words. Mi et al. (2016) introduced explicit coverage embedding models to mitigate issues of unfaithful translation in NMT. Tu et al. (2017) proposed a dynamic mechanism to regulate the ratios at which source and target contexts contribute to
the generation of target words via context gates. Fu et al. (2023) identified the attention degeneration problem, i.e., as the generation step number grows, less and less attention is focused on the source sequence, in language models. Numerous methods have been proposed to enhance faithfulness in natural language generation (Li et al., 2022), all of which were designed to address unfaithfulness under the encoder-decoder architecture neural network. With the emergence of decoder-only LLMs, our focus shifted to the coverage of LLMbased translation. Although these approaches were originally designed for encoder-decoder models and cannot be directly applied to LLMs, they provide a valuable guide for current work on decoder-only language models (Chen et al., 2023; He et al., 2024). The research most similar to ours is that of Chen et al. (2023). They also focus on the unfaithful translation of LLMs, but their methods of addressing these problems differ significantly from ours. They enhance instruction comprehension by adding an instruction representation to the subsequent input and response representations, which are tailored to the tuning application scenario. In contrast, our methods fit different application scenarios. Reweighting attention works in low-resource settings without a full parallel corpus. Contrastive decoding fits APIonly LLMs without internal information access. Target-instruction tuning suits tuning scenarios without adding extra modules or parameters.

heading: 5.2 LLMs for machine translation
text: Recently, several studies focused on how to prompt LLMs for machine translation (Zhang et al., 2023a; Vilar et al., 2023; Agrawal et al., 2023). Zhu et al. (2023) evaluated the performance of eight prominent large language models, including ChatGPT and GPT-4 (OpenAI et al., 2023), in multilingual machine translation. Jiao et al. (2023b) conducted a preliminary evaluation of ChatGPT’s machine translation abilities, exploring translation prompts, multilingual translation, and robustness. ChatGPT competes well with commercial products in highresource European languages but faces challenges with low-resource or distant languages. Parrot (Jiao et al., 2023a), a framework for enhancing chat-based translation, utilizes open-source LLMs, human-written translations, and feedback data to address challenges posed by restricted APIs. Xu et al. (2023) proposed a novel fine-tuning approach for LLMs that is specifically designed for the trans-
lation task and achieves significant advancement on LLM-based machine translation compared to the previous attempts. While LLMs have showcased remarkable performance, they inevitably confront various challenges in practical applications, with hallucinations emerging as one of the most notable issues (Wang et al., 2023; Zheng et al., 2023; Zhang et al., 2023b). Guerreiro et al. (2023) examine hallucinations in large multilingual translation models, conducting a comprehensive analysis on both conventional M2M neural machine translation models (Fan et al., 2021) and ChatGPT, shedding light on the unfaithfulness translation brought by LLMs.
However, previous studies have not explored the relationship between unfaithful or hallucinatory translation and the contribution from input tokens to generated tokens in LLMs. We have attempted to fill this gap. Our analysis of the contribution scores of input tokens has allowed us to highlight the limitations inherent in the decoder-only architecture of LLMs, specifically the lack of an explicit cross-attention module. Such a restriction can lead to inadequate focus on the source context, which we believe might potentially increase the risk of unfaithfulness in LLMs’ generations.

heading: 6 Conclusion
text: In this research, we identify the issue of insufficient focus on source context in LLMs when applied to machine translation tasks and accordingly, we propose the reweight attention to adjust the attention weight of source context to help models focus on the source context during generation, contrastive decoding to reduce the influence of target prefixes, and target-constrained tuning to encourage LLMs to avoid excessive dependence on specific target prefixes. Our experimental results show marked improvements in translation performance across several language pairs in our proposed unfaithful translation test sets, outperforming baseline methods and effectively reducing the phenomenon of hallucinatory and unfaithful translations. Both our quantitative and qualitative analysis of contribution scores indicate the significance of our proposed methods in addressing the identified issue. While we only explore related issues in the application of machine translation, it is natural to extend our methods to other seq2seq tasks(e.g., summarization), which we leave for future exploration.

heading: Acknowledgment
text: We sincerely thank all the reviewers for their valuable and insightful comments, which have greatly enhanced the quality of our work. The work was partial supported by the National Natural Science Foundation of China under Grant No. 62276077, Guangdong Basic and Applied Basic Research Foundation under Grant No. 2024A1515011205, Shenzhen College Stability Support Plan under Grants XWD20220811170358002 and GXWD20220817123150002. The work of Yang Xiang was supported by the National Natural Science Foundation of China under Grant No. 62106115 and Major Key Project of PCL under Grant No. PCL2022D01.
Limitations
This research conducts a preliminary investigation into the hallucinatory and unfaithful translations resulting from insufficient focus on the source context in decoder-only LLMs, and the following aspects can be improved upon in future work:
• Variations in Instructions: In our study, we did not consider the effects of varying the instruction prompt, nor did we examine the impact of our proposed methods under different instructions.
• Testing Limited to Greedy Search: Despite the availability of numerous decoding strategies and generation configurations, we set the temperature to 0 and ’do_sample’ to False to demonstrate our proposed methods’ effectiveness. We did not investigate the performance of these methods in combination with other generation strategies, such as beam search, top-k sampling, or nucleus sampling.
• Increased Latency Although our proposed methods are effective, they incur a higher computational cost compared to the standard settings. The contribution-based alignment selection strategy requires extra time to compute the dot product. Target-constrained tuning necessitates two forward passes, nearly doubling the training time.
Ethical Considerations
In our human-collected datasets, translations are obtained using zero-shot prompting from open-
sourced LLMs, and thus any problematic responses can be attributed to the organizations that release these LLMs. We do not anticipate any significant risks associated with our research. In theory, our framework for mitigating unfaithful or hallucinatory translation could yield higher-quality translations without any toxic content. Based on our observations, our proposed methods have not resulted in any detrimental responses. To ensure the reproducibility of our experiments, we intend to make our code and evaluation data available to the public.

heading: A Analyzing Contribution of input tokens
text: In each layer, the attention block computations can be expressed simply as a linear function of the input representations. Given a model with H heads, the attention block output of the i-th token yi is computed by applying the layer normalization (LN) over the sum of the residual vector xi and the output of the multi-head attention module (MHA) x̂i.
yi = LN(x̂i + xi) (9)
After the MHA module, x̂i can be expressed as the linear combination of different input tokens and different attention heads:
x̂i = H∑
h
W ho
J∑
j
Ahi,jW h v xj + bo (10)
Given a vector u, LN(u) can be reformulated as 1 σ(u)Lu+β, where L is a linear transformation. By swapping summations and utilizing the linearity of LN, we can now rewrite Eq. 9 as:
yi = ∑
j
Ti(xj) + 1
σ(x̂i + xi) Lbo + β (11)
where the transformed vectors Ti(xj) are:
Ti(xj) =    1 σ(xi+xj) L (∑ hW h o A h ijW h v xj ) if i ̸= j
1 σ(x̂i+xi)
L (∑
hW h o A h iiW h v xj + xi
) if i = j
(12) Kobayashi et al. (2020, 2021) propose assessing the contribution of each input vector xj to the layer output yi through the Euclidean norm: ci,j = ∥Ti(xj)∥2. While Ferrando et al. (2022a) argue that transformed representations exhibit reduced anisotropy and they suggest using l1 norm: ci,j = ∥yi − Ti(xj)∥1. Normalizing these contributions yields a layer-wise contribution matrix C ∈ RJ×J . By employing a similar method as attention rollout (Abnar and Zuidema, 2020), an overall contribution matrix for input tokens to the generated token yi is obtained.
While previous studies have investigated the contributions of input tokens in machine translation (Ferrando et al., 2022b), their focus was exclusively on encoder-decoder style transformers. To the best of our knowledge, we are the first to analyze the contribution of input tokens in LLMs. Taking into account both the orientation and norm of the transformed vectors, we modify ci,j =
Ti(xj)·yi ||yi||2 to represent the contribution of
transformed vectors towards the generated tokens. A larger vector projection onto yi is expected to indicate a higher contribution. Given that future tokens are masked in the Transformer decoder, there is an inherent bias toward the initial tokens of the input sequence. Direct aggregation of each layer-wise contribution matrix may further intensify this bias (Abnar and Zuidema, 2020). Therefore, to prevent this, we normalize each layerwise contribution matrix before aggregation.

heading: B Experimental Setting
text: B.1 Instruction prompts
Translation prompt for LLaMA2-chat model. Our translation approach builds upon the work of Sennrich et al. (2024) The input to Llama2-chat consists of a system prompt and an instruction. To ensure that the assistant’s response begins with the actual translation rather than an introductory phrase or prologue, we force-decode the prefix of the assistant response. Here is the zeroshot translation instruction prompt: 

 «SYS» You are a machine translation system that translates sentences from English to German. You just respond with the translation, without any additional comments. «/SYS» Sie stehen keine 100 Meter voneinander entfernt: Am Dienstag ist in Gutach die neue B 33- Fußgängerampel am Dorfparkplatz in Betrieb genommen worden - in Sichtweite der älteren Rathausampel. Translate to English 
Sure, here’s the translation:
In the case of fewshot translation prompt, we adopt the same fewshot strategy used in Zhu et al. (2023). We use eight randomly sampled translation pairs from the respective training set as in-context exemplars. These exemplars are presented in “<X>=<Y>” format, where “<X>” and “<Y>” are the placeholder for the source and target sentence. Line-break serves as the exemplar’s concatenation symbol.
Similar to traditional translation systems, we use bilingual sentence pairs to instill basic translation capabilities into LLMs. We adopt the Stanford Alpaca method (Taori et al., 2023) to convert bilingual sentence pairs into an instructionfollowing format, which fine-tunes LLMs for translation tasks. For the instruction tuning prompt
of the LLaMA2-chat model, we retained the zeroshot translation instruction prompt, but we did not compute the loss for the instruction query part. Instead, we only calculated the loss for the response output label, as illustrated in the subsequent examples of the translation instruction prompt: 

 «SYS» You are a machine translation system that translates sentences from English to German. You just respond with the translation, without any additional comments. «/SYS» Zwei Anlagen so nah beieinander: Absicht oder Schildbürgerstreich? Translate to English 
Sure, here’s the translation:Two sets of lights so close to one another: intentional or just a silly error?
B.2 Evaluation Data
Unfaithful Translation Data. Specifically, we use our contribution scores analysis tool adapted for LLMs, which is modified from the ALTI+5 method, to filter the data. If the source text contributions minus the target prefixes’ contributions fall below a certain threshold, we collect them. We apply our methods to filter evaluation data on publicly available parallel data, such as News-Commentary v16 for German to English (De⇔En) and TED2013 for Chinese to English (Zh⇔En)6. After applying these criteria, we obtain 1009, 1002, 1010, and 1010 evaluation data sets for the De⇒En, En⇒De, Zh⇒En, and En⇒Zh tasks, respectively. Given our choice of translation instances with low source token contributions, which results in a dataset that contains instances that either deviate from the original sentence or lack semantic connection (e.g., copied instructions, text continuation, hallucinatory translation).
General Data. We evaluate the translation performance of LLMs on two sources of test sets:
• Flores-101: We use the Flores-101 which serves as the evaluation benchmark for multilingual-machine systems and the number of test samples is 1012 for all translation directions (Goyal et al., 2022).
5https://github.com/mt-upc/transformer-contributionsnmt
6https://opus.nlpl.eu
• WMT22 Test sets: We also utilize the test sets from the WMT22 competition. These sets are constructed based on recent content from various domains, including news, social, ecommerce, and conversational domains. The sample numbers for the De⇒En, En⇒De, Zh⇒En, and En⇒Zh tasks are 1984, 2037, 1875, and 2037, respectively (Kocmi et al., 2022).
B.3 Model Training
We conduct our main experiments with HuggingFace Transformers7 on open-source LLMs from the LLaMA2 family (Touvron et al., 2023). Specifically, we choose LLaMA2-7b-chat8, BLOOMZ7b1-mt9 (Muennighoff et al., 2023), ChatGLM36b10 (Du et al., 2022), and Vicuna-7b11 (Chiang et al., 2023) with matched parameters, and also include LLaMA2-7b-chat, LLaMA2-13b-chat and LLaMA2-70b-chat to study the effect of model sizes. The hyperparameters used for finetuning are mainly aligned with those of Stanford Alpaca12 (Taori et al., 2023). For instruction tuning and target-constrained tuning, we finetune models over 5 epochs with a learning rate of 1e-4, using the corresponding language direction parallel data. During the implementation of the LoRA finetuing13, we set the ‘lora_r’ to 16, ‘lora_alpha’ to 32, ‘lora_dropout’ to 0.3. The ‘target_modules’ are configured to include the query, key, value projection and output projection within the attention module. For more specific hyperparameters, please refer to our released scripts. We perform the finetuning process on 8 Nvidia A100 GPUs and employ DeepSpeed14 ZeRO stage 2 for model parallel.

heading: C Ablation Study
text: We analyze specific factors related to our proposed methods that may impact the translation performance of LLMs. As a default setting, we perform ablation studies on our proposed unfaithful translation dataset using the LLaMA2-7b-chat model.
7https://github.com/huggingface/transformers 8https://huggingface.co/meta-llama/Llama-2-7b-chat-hf 9https://huggingface.co/bigscience/bloomz-7b1-mt
10https://huggingface.co/THUDM/chatglm3-6b 11https://huggingface.co/liuhaotian/llava-v1.6-vicuna-7b 12https://github.com/tatsu-lab/stanford_alpaca 13https://github.com/tloen/alpaca-lora 14https://github.com/microsoft/DeepSpeed
C.1 Reweight Attention different strategy and the effect of the scale factor ω and window size
Two strategies for choosing local window anchors to adjust attention scores. For comparison, we have also introduced a global window strategy that adjusts the attention scores across the entire source context. In this study, we aim to determine which strategy most effectively improves the translation performance of LLMs. As shown in Table 5, our heuristic strategy, which prioritizes the most significant source tokens based on their contribution, outperforms the other strategies. The monotonic strategy is the most subtle optimization strategy, as aligning the source and target tokens in a step-by-step manner may not conform to a human-like translation. Interestingly, adjusting the attention scores across the entire window of source tokens produces results comparable to the heuristic approach. We further investigated the translation performance across varying local window sizes and scale factor ω, as shown in Figure 6. Our results suggest that significant performance enhancement is observed with larger windows when the window size is initially small(e.g. 3 or 5). However, as the window size increases beyond a certain point(e.g. 9), we notice a slight decrease in translation performance. This can be
α
attributed to the fact that incorporating irrelevant source information, not related to the currently generated token, may introduce additional noise. Additionally, assigning a small factor does not effectively shift the model’s focus toward the source tokens. Conversely, overemphasis on the source context can lead to performance decline. In total, the optimal balance appears to be a window size of around 9 and a scale factor of around 0.5.
C.2 Effect of adjustment level α in Contrastive Decoding
In our proposed contrastive decoding method, we introduce a hyperparameter α to control the penalty degree of contrastive decoding. A smaller α results in the model predictions’ output distribution being closer to the original distribution of the next tokens. We carry out experiments using various values of α and present the results in Figure 7. Smaller values of α(e.g., 0.1) do not yield performance as robust as larger values α(e.g., 0.5), suggesting that the models continue to generate unconditioned tokens when a penalty of a lower degree is utilized. However, increasing the value of α(e.g., 1) further causes a decline, due to the unfluent and ungrammatical generation from erasing too much target contribution.
C.3 Effect of mask ratio β and KL-divergence coefficient λ in target-constrained tuning
We study the influence of two parameters: the mask ratio β and the weight assigned to the KLdivergence loss λ. Here, we let β vary between {0 → 0.5} and λ between {0 → 1} and From the results in Figure 8 and 9, we find that: 1) A mask ratio of 0.15 and a KL coefficient of 0.5 yields the best performance; 2) Target-constrained
tuning consistently achieves strong results with a mask ratio 0.05 and 0.15; 3) As the mask ratio increases, target-constrained tuning fails to converge because the model struggles with the high randomness from the masked target prefix; 4) Smaller λ values underperform compared to larger ones, highlighting the need for attention to KL-divergence regularization. However, overregularization is detrimental. The best balance is achieved at λ = 0.5.

heading: D Human Evaluation
text: In this appendix, we describe the manual evaluation. First, we detail the simple guidelines that were presented to manual annotators. Second, we report the number of annotators and inter-annotation agreements.
annotation guidelines The annotators were provided with the guidelines as outlined in Table 7. We consolidate the labels based on a majority vote. Notably, we also designate unfaithful translations, encompassing under-translations and overtranslations, as hallucinations. Translations that exhibit semantic deviation from the source context are also recognized as hallucinations. Concretely, for the purpose of reporting, we grouped ‘Namedentity mistranslation’ and ‘Off-target’ under the ‘Error’ category, while ‘Semantically detached’, ‘Omission’, and ‘Over-translation’ were classified under the ‘Hallucination’ category."
Inter-annotation agreement To ensure the reliability and quality of our annotated unfaithful translation datasets, we additionally assigned the same set of another 100 randomly sampled translation instances to two annotators. The Fleiss’ Kappa statistic, representing the agreement in the assessment of annotation categories between the annotators, is presented in Table 6. As demonstrated, we can effectively classify the different types of translation with strong agreement between the two annotators, thereby indicating the effectiveness of the human evaluation test set. This confirms the suitability of our annotated data for our analysis.

heading: E Connection between Human Evaluation and Automatic metrics
text: To reveal the consistency of hallucination evaluation between automated metrics and human evaluation in cases of unfaithful translation, we conduct further analysis. This analysis focuses on the correlation between human evaluations quantified by numerical scores and automated metrics. According to Table 7 in Appendix D, translations are first categorized into one of six annotation categories, and the detailed categories of the sampled set are shown in Table 8. To convert these categories into numerical scores, we can use the proportion of hallucinatory translations to measure hallucination severity, following Dale et al. (2023). A higher proportion indicates more severe hallucinations. Alternatively, to emphasize unfaithfulness in translation, we assign a score of -0.4 for omission and over-translation, a score of -0.25 for semantically detached, a score of -0.2 for error translations, and a score of +1 for correct translations.
We first convert human evaluation categories into numerical scores using the previously dis-
cussed method, and then compute BLEU, COMET, and BLEURT (Sellam et al., 2020) metrics for these examples. The results are presented in the Table 9
Finally, we calculated the Pearson correlation coefficient between the automated metrics and human evaluation scores. The Table 10 shows that the BLEU metric aligns most closely with human evaluation scores, followed by COMET. Thus, we further confirm that BLEU and COMET are proper for our experiments as they can reflect the level of unfaithful translation to a certain degree.

heading: 39.9 7 300 33 22 26.94

heading: F Analysis of the imbalanced improvement phenomenon
text: Our paper focuses on unfaithful translations in LLMs caused by inadequate attention to the source context. Therefore, we collect data containing such issues to form a specific dataset and conduct main experiments on this dataset, with results in Table 1 showing our methods effectively address the unfaithful translation issue. Only then did we generalize our methods to open general datasets, with results in Table 2. Experimental results show improvement of our method is less significant on general datasets than on the unfaithful translation test set. This is mainly due to the rare unfaithful translations when using the Llama-2-7b-chat model for zero-shot translation on the Flores101 and WMT22 test sets. We also calculate source contribution scores, as detailed in Appendix A (higher scores mean more focus on the source context during LLM generation, thus is less possible to generate unfaithful translations), across both general and proposed test sets to illustrate this point. As shown in the Table 11, the source contribution scores on the general dataset are higher than the proposed dataset, which explains why our method’s improvements are less significant on general datasets.

heading: G Further analysis of the sudden drop
text: The lines in the figure represent averages not for all examples but for those corresponding to examples with at least i tokens. Therefore, when the number of tokens exceeds 100, only translations with a sentence length greater than 100 tokens are taken into account. The basic statistics of the source length in the Zh-to-En test set are presented in Table 12.
We conducted the human evaluation to the long source context cases, and found that when the source context length exceeds 200, translations
produced by LLM using vanilla zero-shot settings show more instances of not following instructions and more omissions, resulting in reduced reliance on the source context during translation generation. Consequently, the contribution of the source context diminishes.
H Extended comparison experiments between model families and scales within WMT22 test set and unfaithful test set
In the comparison of these language model families, ChatGLM3-6b demonstrates superior performance in the English to Chinese (En ⇒ Zh) language translation direction, largely as a result of its enhanced modeling of Chinese during the pretraining phase. On the other hand, BLOOMZ-7b1-mt performs better in the Chinese to English (Zh ⇒ En) language translation direction. This enhancement can be ascribed to its substantial exposure to a varied compilation of parallel multilingual pretraining corpora, coupled with the prevalence of English in the pretraining corpus of BLOOM.
As evidenced by the results shown in Table 16, the 7b model experiences the most significant boost, while larger models only achieve a marginal enhancement. Given that the test unfaithful translation sets are collected from the poorest translation instances of the 7b chat model, larger models demonstrate superior translation capabilities and generate fewer unfaithful issues within such a dataset. This inconsistent improvement is primarily due to the difference in the number of unfaithful issues generated by LLMs of varying scales.

heading: Future Work
text: Given that future tokens are masked in the Transformer decoder, there is an inherent bias toward the initial tokens of the input sequence. Direct aggregation of each layer-wise contribution matrix may further intensify this bias (Abnar and Zuidema, 2020). Therefore, to prevent this, we normalize each layerwise contribution matrix before aggregation