arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2504.20799cs.SEcs.AI

代码生成大语言模型的幻觉:分类、基准、缓解与挑战

Hallucination by Code Generation LLMs: Taxonomy, Benchmarks, Mitigation, and Challenges

UNIST(蔚山科学技术院);Handong Global University(韩东国际大学);Korea University(高丽大学);Seoul National University of Science and Technology(首尔科学技术院)

Yunseo Lee, John Youngeun Song, Dongsun Kim, Jindae Kim, Mijung Kim, Jaechang Nam

AI总结:

本文综述 CodeLLM 代码生成中的幻觉问题,系统梳理幻觉类型、现有基准、缓解策略与开放挑战,并提出检测和消除幻觉的未来研究方向。

摘要:

大语言模型(LLM)近期的技术突破使其能够流畅地生成源代码。软件开发人员经常利用通用型和代码专用型 LLM 来修改现有代码,甚至从头生成整个函数。这些能力在无代码或低代码场景中也很有价值,因为在这些场景中,没有技术背景的人也可以编写程序。然而,由于其内部设计,LLM 容易产生幻觉,即不正确、无意义且无法证明其合理性的信息,而且其存在难以识别。在生成源代码时也会出现这一问题。一旦产生幻觉代码,用户往往很难识别和修复它,尤其是当这类幻觉只能在特定执行路径下被发现时。因此,幻觉代码可能会在代码库中一直不被察觉。本综述调研了与 CodeLLM 生成的幻觉相关的最新研究和技术。我们对 CodeLLM 所生成代码中的幻觉类型进行分类,回顾现有基准和缓解策略,并指出尚未解决的挑战。基于这些发现,本综述概述了在检测和消除 CodeLLM 产生的幻觉方面的进一步研究方向。

英文摘要:

Recent technical breakthroughs in large language models (LLMs) have enabled them to fluently generate source code. Software developers often leverage both general-purpose and code-specialized LLMs to revise existing code or even generate a whole function from scratch. These capabilities are also beneficial in no-code or low-code contexts, in which one can write programs without a technical background. However, due to their internal design, LLMs are prone to generating hallucinations, which are incorrect, nonsensical, and not justifiable information but difficult to identify its presence. This problem also occurs when generating source code. Once hallucinated code is produced, it is often challenging for users to identify and fix it, especially when such hallucinations can be identified under specific execution paths. As a result, the hallucinated code may remain unnoticed within the codebase. This survey investigates recent studies and techniques relevant to hallucinations generated by CodeLLMs. We categorize the types of hallucinations in the code generated by CodeLLMs, review existing benchmarks and mitigation strategies, and identify open challenges. Based on these findings, this survey outlines further research directions in the detection and removal of hallucinations produced by CodeLLMs.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑