Analyzing Context Contributions in LLM-based Machine Translation
Using ALTI, this study analyzes layer-wise token contributions in LLM-based MT, revealing source dominance and positional biases.
Key Findings
Methodology
The study employs ALTI (Layer-Wise Token-to-Token Interactions), an attribution method that tracks information flow across transformer layers. It constructs contribution matrices at each layer, quantifying how input tokens—such as few-shot examples, source text, and prefixes—influence generated translations. By aggregating token contributions at the part level, the analysis reveals how different context components impact output. The approach incorporates positional bias analysis, comparing contribution patterns across example positions and content relevance, and identifies anomalous contributions linked to hallucinations.
Key Results
- Across translation directions, source tokens in few-shot examples contribute more than target tokens, with source contribution ratios exceeding 60%. Early examples consistently dominate contributions, indicating a strong positional bias. Fine-tuning reduces but does not eliminate this bias. Anomalous cases with low source contributions often correspond to hallucinations, where the model copies previous translations. During generation, source influence diminishes while target prefix influence increases, aligning with classical MT dynamics. These insights enable detection of pathological outputs and improve interpretability.
- Model comparisons show that LLaMA-2 and unadapted TOWER exhibit similar positional biases, while task-specific fine-tuning lessens this effect. Adding task descriptions or copying test samples as last examples can mitigate bias, but not fully. The contribution evolution analysis confirms that source information is most influential at early stages, decreasing as the translation progresses. These findings demonstrate that the models rely heavily on initial context, which can be exploited to identify hallucinations and improve robustness.
- Overall, the attribution-based analysis provides a detailed view of how different context parts shape translation outputs. It highlights the importance of source tokens, the impact of example order, and the potential for bias detection. The methodology offers a pathway for developing safer, more transparent LLMs, with applications extending to model debugging, bias mitigation, and trustworthiness enhancement in multilingual NLP tasks.
Significance
This work advances understanding of how LLMs utilize contextual information during machine translation, moving beyond performance metrics to interpret internal mechanisms. By quantifying contributions at the token and layer levels, it uncovers biases and potential failure modes, such as hallucinations. These insights are crucial for designing more transparent and controllable models, especially as LLMs are increasingly deployed in real-world multilingual applications. The attribution framework also opens avenues for bias mitigation, model safety, and explainability, addressing long-standing challenges in neural MT and large-scale NLP.
Technical Contribution
The paper introduces ALTI as a novel attribution method tailored for autoregressive transformers, enabling layer-wise, token-level contribution analysis. It extends traditional attention-based interpretability by providing a more detailed, causal view of information flow. The combination of part-level aggregation and positional bias analysis offers a comprehensive toolkit for understanding and diagnosing model behavior. This approach facilitates the detection of hallucinations and biases, providing both theoretical insights and practical tools for model debugging and safety enhancement. The methodology is adaptable to various models and multilingual settings, broadening its impact.
Novelty
This is the first systematic study applying ALTI to multi-language LLMs in the context of machine translation, revealing persistent positional biases and contribution patterns. Unlike prior work focusing on performance metrics or attention weights, this research emphasizes interpretability through explicit contribution matrices. It uniquely combines contribution attribution with bias detection, offering a new perspective on model internal dynamics. The findings about source dominance and bias mitigation strategies represent significant advances in explainability and safety in large language models.
Limitations
- The analysis relies on computationally intensive ALTI calculations, limiting sample size and scalability. Results are primarily based on WMT22 datasets and specific models (LLaMA-2, TOWER), which may affect generalization. The attribution method captures correlations but cannot fully disentangle causality or model-specific biases. The study does not propose explicit bias mitigation techniques, leaving room for future work to develop targeted interventions. Additionally, the detection of hallucinations is based on contribution anomalies, which may not cover all failure modes.
Future Work
Future research should focus on integrating attribution insights into training procedures to actively reduce biases and hallucinations. Extending the analysis to larger models and diverse datasets will test the robustness of findings. Developing real-time bias detection and correction tools can enhance deployment safety. Exploring causal attribution methods and incorporating multi-modal data could further improve interpretability. Ultimately, combining attribution with model editing and fine-tuning strategies promises to create more reliable and transparent multilingual LLMs.
AI Executive Summary
Large language models (LLMs) have revolutionized machine translation, demonstrating remarkable zero-shot and few-shot capabilities. However, understanding how these models leverage different parts of the input context remains an open challenge. This study employs ALTI (Layer-Wise Token-to-Token Interactions), a novel attribution method, to dissect the internal information flow within transformer-based LLMs during translation tasks. By analyzing models like LLaMA-2 and TOWER across multiple language pairs on WMT22 datasets, the research reveals consistent patterns: source tokens in few-shot examples contribute more than targets, early examples exert disproportionate influence, and positional biases persist even after fine-tuning.
The analysis uncovers that models heavily rely on initial context, with source contributions diminishing as translation progresses. Interestingly, introducing task descriptions or copying test samples at the end of context can reduce positional biases, but not eliminate them entirely. Crucially, the attribution framework enables detection of hallucinations—cases where the model produces inaccurate or repetitive translations—by identifying anomalous low-source contributions.
These insights deepen our understanding of the internal dynamics of LLM-based MT, highlighting both strengths and vulnerabilities. The findings suggest that bias mitigation and interpretability can be achieved through targeted attribution analysis, guiding future model training and safety strategies. While the approach offers powerful diagnostics, computational costs and dataset limitations remain challenges. Overall, this work paves the way toward more transparent, reliable, and controllable multilingual LLMs, with broad implications for AI safety, fairness, and practical deployment in real-world translation systems.
Deep Analysis
Background
The evolution of neural machine translation (NMT) has been driven by the advent of transformer architectures (Vaswani et al., 2017), which replaced traditional RNN-based models with attention mechanisms. Early models like Transformer-based NMT achieved significant improvements in translation quality, especially on large datasets such as WMT. Subsequent developments introduced pretraining strategies (e.g., BERT, GPT) and large-scale multilingual models (e.g., mBERT, mT5), enabling zero-shot and few-shot learning capabilities. Despite these advances, interpretability remains limited; most analyses focus on attention weights or output metrics, which do not fully explain internal decision processes. Recent efforts have explored attribution methods, but their application to multi-language LLMs in MT is still nascent. This context underscores the need for detailed, layer-wise interpretability tools to understand how models utilize context, especially in complex scenarios involving multiple examples and languages.
Core Problem
While LLMs demonstrate impressive translation performance, their internal mechanisms—particularly how they leverage different parts of the input context—are poorly understood. Key issues include the dominance of source tokens, positional biases favoring early examples, and the emergence of hallucinations. These problems hinder model transparency and safety, especially when models generate inaccurate or biased outputs. Existing interpretability methods lack the granularity to dissect token-level contributions across layers, limiting insights into how information flows and biases form. Addressing these gaps is crucial for developing trustworthy, controllable translation systems that can reliably handle diverse languages and contexts.
Innovation
This work introduces ALTI, a layer-wise attribution technique that quantifies token contributions across transformer layers, providing a fine-grained view of information flow. It extends beyond attention weights, capturing causal influence and enabling part-level aggregation of contributions from source text, few-shot examples, and prefixes. The approach reveals persistent positional biases, with early examples exerting disproportionate influence, and identifies anomalous contribution patterns associated with hallucinations. By integrating bias detection with contribution analysis, the method offers a novel diagnostic tool for model interpretability and safety. This comprehensive framework surpasses prior attention-based explanations, offering actionable insights for bias mitigation and model debugging in multilingual MT.
Methodology
- �� Implement ALTI to compute token-to-token contribution matrices at each transformer layer, capturing the influence of input tokens on outputs. • Aggregate token contributions into part-level scores, separating source text, few-shot examples (source and target sides), and prefixes. • Analyze contribution patterns across different example positions, comparing models before and after fine-tuning, to identify positional biases. • Conduct experiments on WMT22 datasets across multiple language pairs, with 5-shot prompts, shuffling examples to eliminate relevance bias. • Detect anomalies by identifying samples with unusually low source contributions, correlating these with hallucination cases. • Track contribution evolution during translation, dividing generated sequences into bins, to observe how reliance on context shifts over time.
Experiments
The experiments utilize WMT22 test sets for en-de, de-en, en-ru, and ru-en, employing LLaMA-2, TOWER, and TOWERINSTRUCT models. Five-shot prompts are used, with examples shuffled randomly. ALTI computes contribution matrices at each layer, which are then aggregated to part-level scores. The analysis compares contribution ratios across example positions, evaluates the impact of task descriptions, and tests the effect of copying test samples at the end of context. Anomalous samples with low source contributions are examined to identify hallucinations. The study also investigates how contributions evolve during the translation process by dividing generated tokens into ten segments, revealing consistent source dominance early on and decreasing influence later.
Results
The results confirm that source tokens in few-shot examples dominate contributions, especially at early positions, with source contribution ratios exceeding 60%. Positional bias is robust across models and languages, but fine-tuning reduces its strength. Introducing task descriptions or copying test samples at the end diminishes positional bias, yet does not eliminate it. Anomalous cases with low source contributions often correspond to hallucinations, where the model copies previous translations. During generation, source influence decreases while target prefix influence increases, aligning with classical MT dynamics. These findings demonstrate the effectiveness of attribution-based diagnostics in understanding and mitigating biases.
Applications
The attribution framework can be integrated into model debugging pipelines, enabling real-time bias detection and correction. It supports development of safer translation systems by identifying and addressing hallucinations and biases. The methodology can guide training strategies to reduce positional biases and improve interpretability, fostering trust in multilingual NLP applications. Additionally, the insights can inform model architecture design, promoting more balanced and content-aware information flow, ultimately enhancing translation quality and safety in industry deployments.
Limitations & Outlook
The computational cost of ALTI limits scalability, restricting analysis to smaller datasets and models. Results are primarily validated on WMT22 and specific models, raising questions about generalization. The attribution method captures correlation rather than causation, and may not fully disentangle complex biases. The detection of hallucinations relies on contribution anomalies, which may not cover all failure modes. Further research is needed to develop bias mitigation strategies and extend the approach to larger models and diverse tasks.
Plain Language Accessible to non-experts
想象你在厨房做饭,每次加入不同的食材(输入信息),厨师(模型)会根据已有的食材决定下一步做什么。早放的食材(示例)对最终菜肴(翻译)影响最大,就像你放入的调料越早,味道越重。研究发现,厨师更重视最开始放的食材,后面加入的影响较小。如果厨房里放的食材有误或少,做出来的菜可能会怪怪的,甚至出现“幻觉”——比如菜里出现奇怪的味道或重复的内容。通过观察厨师的反应,可以知道哪些食材影响最大,从而改进做菜的方法,让菜更好吃、更靠谱。
ELI14 Explained like you're 14
想象你在学校做一个项目,你有很多资料(输入),老师让你用这些资料写报告(翻译)。你会发现,最早给你的资料对写报告帮助最大,后面加的资料影响就小很多。这就像模型在翻译时,更看重最开始的示例内容,而不是后面新加入的内容。有时候,资料里夹杂一些错误信息(幻觉),模型可能会照着错误的内容写,导致报告出现问题。通过观察哪些资料对结果影响大,可以帮我们找到模型出错的原因,改进它的学习方式,让它写的报告更靠谱、更准确。
Abstract
Large language models (LLMs) have achieved state-of-the-art performance in machine translation (MT) and demonstrated the ability to leverage in-context learning through few-shot examples. However, the mechanisms by which LLMs use different parts of the input context remain largely unexplored. In this work, we provide a comprehensive analysis of context utilization in MT, studying how LLMs use various context parts, such as few-shot examples and the source text, when generating translations. We highlight several key findings: (1) the source part of few-shot examples appears to contribute more than its corresponding targets, irrespective of translation direction; (2) finetuning LLMs with parallel data alters the contribution patterns of different context parts; and (3) there is a positional bias where earlier few-shot examples have higher contributions to the translated sequence. Finally, we demonstrate that inspecting anomalous context contributions can potentially uncover pathological translations, such as hallucinations. Our findings shed light on the internal workings of LLM-based MT which go beyond those known for standard encoder-decoder MT models.