articleProceedings of the ACM on software engineering.Jun 22, 2025HYBRID OA

LLM Hallucinations in Practical Code Generation: Phenomena, Mechanism, and Mitigation

ZZZiyao ZhangCWChong WangYWYanlin WangESEnsheng ShiYMYuchi Ma

Sun Yat-sen University · Nanyang Technological University · +1 more institution

Indexed incrossref

Abstract

Code generation aims to automatically generate code from input requirements, significantly enhancing development efficiency. Recent large language models (LLMs) based approaches have shown promising results and revolutionized code generation task. Despite the promising performance, LLMs often generate contents with hallucinations, especially for the code generation scenario requiring the handling of complex contextual dependencies in practical development process. Although previous study has analyzed hallucinations in LLM-powered code generation, the study is limited to standalone function generation. In this paper, we conduct an empirical study to study the phenomena, mechanism, and mitigation of LLM…

Citation impact

53
total citations
FWCI
135.41
Percentile
100%
References
16
Citations per year

Authors

9

Topics & keywords

Keywords
  • Code (set theory)
  • Code generation
  • Computer science
  • Mechanism (biology)
  • Mainstream
  • Process (computing)
  • Risk analysis (engineering)
  • Computer security
No related works found for this paper.