Hallucinations of Large Language Models in Cross-Language Code Translation: Phenomena and Mitigation
Not on the map. Why?
Abstract (arXiv)
Code translation converts source code from one programming language to another while preserving its functionality. Although Large Language Models (LLMs) have improved code translation, their outputs still contain hallucinations: generated code that conflicts with the source program, violates target-language facts, or introduces contextually inconsistent dependencies. These failures are especially harmful in translation because small semantic deviations can silently change program behavior. Existing hallucination studies mainly focus on natural-language generation or code generation, leaving the forms, distribution, and mitigation of hallucinations in cross-language code translation insufficiently characterized. This paper presents a systematic empirical study of LLM hallucinations in code translation. Across three benchmark datasets, six language pairs, and seven LLMs, we construct a taxonomy with three major categories: Semantic Consistency Conflicts, Factual Knowledge Conflicts, and Project Context Deviations. We manually annotate 13,919 hallucination cases and analyze how hallucination types vary across models, datasets, and language directions. Guided by the taxonomy, we further propose HaluCodeTran, a mitigation framework that combines BM25-based retrieval of relevant translation examples with taxonomy-aware reflective refinement. The study provides an execution-tested characterization of code-translation hallucinations and a practical baseline for building more reliable LLM-based code migration tools.
Key facts. No citing papers in the map yet (data through 26 Nov 2026). Builds on 35 of its 58 references that are in the map. Submitted 20 Oct 2026.
Builds on
35 of 58 references.
References · 35
- 2024The Llama 3 Herd of Modelscited by 16,114
- 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,845
- 2024Qwen2.5 Technical Reportcited by 5,527
- 2023Code Llama: Open Foundation Models for Codecited by 2,242
- 2024Gemma 2: Improving Open Language Models at a Practical Sizecited by 2,225
- 2024Qwen2.5-Coder Technical Reportcited by 1,301
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,241
- 2024StarCoder 2 and The Stack v2: The Next Generationcited by 544
- 2024DeepSeek-Coder-V2: Breaking the Barrier of Closed-Source Models in Code Intelligencecited by 354
- 2020Unsupervised Translation of Programming Languagescited by 270
- 2021CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Taskscited by 208
- 2024CodeGemma: Open Code Models Based on Gemmacited by 160
23 more
- 2024LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigationcited by 98
- 2023FELM: Benchmarking Factuality Evaluation of Large Language Modelscited by 70
- 2021AVATAR: A Parallel Corpus for Java-Python Program Translationcited by 61
- 2024CodeUltraFeedback: An LLM-as-a-Judge Dataset for Aligning Large Language Models to Coding Preferencescited by 59
- 2024Exploring and Unleashing the Power of Large Language Models in Automated Code Translationcited by 59
- 2024Calibration and Correctness of Language Models for Codecited by 54
- 2023On the Effectiveness of Large Language Models in Domain-Specific Code Generationcited by 47
- 2023DelucionQA: Detecting Hallucinations in Domain-specific Question Answeringcited by 46
- 2024CodeHalu: Investigating Code Hallucinations in LLMs via Execution-based Verificationcited by 37
- 2024LLMs Meet Library Evolution: Evaluating Deprecated API Usage in LLM-based Code Completioncited by 36
- 2023ChatGPT vs SBST: A Comparative Assessment of Unit Test Suite Generationcited by 35
- 2024Knowledge Graphs, Large Language Models, and Hallucinations: An NLP Perspectivecited by 34
- 2023CoTran: An LLM-based Code Translator using Reinforcement Learning with Feedback from Compiler and Symbolic Executioncited by 25
- 2024Unraveling the Potential of Large Language Models in Code Translation: How Far Are We?cited by 19
- 2024InterTrans: Leveraging Transitive Intermediate Translations to Enhance LLM-based Code Translationcited by 18
- 2024ROCODE: Integrating Backtracking Mechanism and Program Analysis in Large Language Models for Code Generationcited by 15
- 2024The Impact of Prompt Programming on Function-Level Code Generationcited by 15
- 2025Hallucination by Code Generation LLMs: Taxonomy, Benchmarks, Mitigation, and Challengescited by 14
- 2024Leveraging Large Language Models for Code Translation and Software Development in Scientific Computingcited by 11
- 2024Output Format Biases in the Evaluation of Large Language Models for Code Translationcited by 10
- 2023Hallucination Reduction in Long Input Text Summarizationcited by 7
- 2024Specification-Driven Code Translation Powered by Large Language Models: How Far Are We?cited by 6
- 2024A Joint Learning Model with Variational Interaction for Multilingual Program Translationcited by 5
Built on by
Not cited yet.