mlsanityData to 14 Oct 2026

CodeHalu: Investigating Code Hallucinations in LLMs via Execution-based Verification

arXiv 2405.00253 ↗First posted 30 Apr 2024cs.CL cs.SEcited by 34

Not on the map. Why?

Abstract (arXiv)

Large Language Models (LLMs) have made significant progress in code generation, offering developers groundbreaking automated programming support. However, LLMs often generate code that is syntactically correct and even semantically plausible, but may not execute as expected or fulfill specified requirements. This phenomenon of hallucinations in the code domain has not been systematically explored. To advance the community's understanding and research on this issue, we introduce the concept of code hallucinations and propose a classification method for code hallucination based on execution verification. We categorize code hallucinations into four main types: mapping, naming, resource, and logic hallucinations, with each category further divided into different subcategories to understand and address the unique challenges faced by LLMs in code generation with finer granularity. Additionally, we present a dynamic detection algorithm called CodeHalu designed to detect and quantify code hallucinations. We also introduce the CodeHaluEval benchmark, which includes 8,883 samples from 699 tasks, to systematically and quantitatively evaluate code hallucinations. By evaluating 17 popular LLMs using this benchmark, we reveal significant differences in their accuracy and reliability in code generation, offering detailed insights for further improving the code generation capabilities of LLMs. The CodeHalu benchmark and code are publicly available at https://github.com/yuchen814/CodeHalu.

Key facts. Cited by 34 papers in the map (data through 14 Oct 2026). Builds on 19 of its 40 references that are in the map. First posted on arXiv 30 Apr 2024.

Builds on

19 of 40 references.

References · 19

  1. 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 13,028
  2. 2021Evaluating Large Language Models Trained on Codecited by 8,320
  3. 2021Program Synthesis with Large Language Modelscited by 3,637
  4. 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
  5. 2023Qwen Technical Reportcited by 3,344
  6. 2021TruthfulQA: Measuring How Models Mimic Human Falsehoodscited by 2,975
  7. 2023Code Llama: Open Foundation Models for Codecited by 2,139
  8. 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
  9. 2021GLM: General Language Model Pretraining with Autoregressive Blank Infillingcited by 1,031
  10. 2021Measuring Coding Challenge Competence With APPScited by 902
  11. 2023StarCoder: may the source be with you!cited by 799
  12. 2023WizardCoder: Empowering Code Large Language Models with Evol-Instructcited by 733
7 more
  1. 2023Check Your Facts and Try Again: Improving Large Language Models with External Knowledge and Automated Feedbackcited by 353
  2. 2023TACO: Topics in Algorithmic COde generation datasetcited by 160
  3. 2022Learning to Break the Loop: Analyzing and Mitigating Repetitions for Neural Text Generationcited by 94
  4. 2023Large Language Models and Simple, Stupid Bugscited by 45
  5. 2023CodeScope: An Execution-based Multilingual Multitask Multidimensional Benchmark for Evaluating LLMs on Code Understanding and Generationcited by 39
  6. 2022WhyGen: Explaining ML-powered Code Generation by Referring to Training Examplescited by 7
  7. 2020Learning Source Phrase Representations for Neural Machine Translationcited by 4

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2024: 2; 2025: 15; 2026: 17.

34 papers.

Sort:

By area:

  1. 2025A Survey on Test-Time Scaling in Large Language Models: What, How, Where, and How Well?cited by 223
  2. 2024ClinicalLab: Aligning Agents for Multi-Departmental Clinical Diagnostics in the Real Worldcited by 28
  3. 2025Thinking Longer, Not Larger: Enhancing Software Engineering Agents via Scaling Test-Time Computecited by 26
  4. 2026From Storage to Experience: A Survey on the Evolution of LLM Agent Memory Mechanismscited by 21
  5. 2025Robustness in Large Language Models: A Survey of Mitigation Strategies and Evaluation Metricscited by 12
  6. 2025Hallucination by Code Generation LLMs: Taxonomy, Benchmarks, Mitigation, and Challengescited by 11
  7. 2026Human oversight of agentic systems in practice: Examining the oversight work, challenges, and heuristics of developers using software agentscited by 6
  8. 2024Code Hallucinationcited by 5
  9. 2026HalluJudge: A Reference-Free Hallucination Detection for Context Misalignment in Code Review Automationcited by 5
  10. 2025Benchmarking AI Models in Software Engineering: A Review, Search Tool, and Unified Approach for Elevating Benchmark Qualitycited by 4
  11. 2025Hallucinations in Code Change to Natural Language Generation: Prevalence and Evaluation of Detection Metricscited by 4
  12. 2026PairCoder++: Pair Programming as a Universal Paradigm for Verified Code-Driven Multimodal and Structured-Artifact Generationcited by 4
22 more
  1. 2025Integrating Expert Knowledge into Logical Programs via LLMscited by 3
  2. 2026Functional Entropy: Predicting Functional Correctness in LLM-Generated Code with Uncertainty Quantificationcited by 3
  3. 2026Beyond Document Grounding: Span-Level Hallucination Detection over Code, Tool Output, and Documentscited by 3
  4. 2025SRLCG: Self-Rectified Large-Scale Code Generation with Multidimensional Chain-of-Thought and Dynamic Backtrackingcited by 2
  5. 2025Eliminating Hallucination-Induced Errors in LLM Code Generation with Functional Clusteringcited by 2
  6. 2025Hallucination in LLM-Based Code Generation: An Automotive Case Studycited by 2
  7. 2025Review of Hallucination Understanding in Large Language and Vision Modelscited by 2
  8. 2025textttReMind: Understanding Deductive Code Reasoning in LLMscited by 2
  9. 2025Towards Functional Correctness of Large Code Models with Selective Generationcited by 1
  10. 2025Library Hallucinations in LLM-Generated Code: A Risk Analysis Grounded in Developer Queriescited by 1
  11. 2025HFuzzer: Testing Large Language Models for Package Hallucinations via Phrase-based Fuzzingcited by 1
  12. 2026ReFEree: Reference-Free and Fine-Grained Method for Evaluating Factual Consistency in Real-World Code Summarizationcited by 1
  13. 2026Bridging Generation and Training: A Systematic Review of Quality Issues in LLMs for Codecited by 1
  14. 2026When Retrieval Hurts Code Completion: A Diagnostic Study of Stale Repository Contextcited by 1
  15. 2026SOCIA-EVO: Automated Simulator Construction via Dual-Anchored Bi-Level Optimizationcited by 0
  16. 2026Task Abstention for Large Language Models in Code Generationcited by 0
  17. 2026LibEvoBench: Probing Temporal Knowledge Stratification in Code Generation Modelscited by 0
  18. 2026Decode-Time Grammars: Constrained LLM Generation over a Refinement Order of Grammar Fragmentscited by 0
  19. 2026LangChoiceBench: Measuring and Explaining Programming-Language Choice in LLMscited by 0
  20. 2026CodeTD: Topology of Attention Detects Hallucinations in Code LLMscited by 0
  21. 2026MintEval: Do LLMs Implement the Trading Strategy You Asked For? A Behavioural-Equivalence Benchmark for Natural-Language-to-Strategy Codecited by 0
  22. 2026Hallucination Across the Reasoning Lifecycle: Interface Visibility, Causal Evidence, and Release Control in Large Reasoning Modelscited by 0