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

大型语言模型生成代码中的缺陷:一项实证研究

Bugs in Large Language Models Generated Code: An Empirical Study

Polytechnique Montréal(蒙特利尔理工学院)

Florian Tambon, Arghavan Moradi Dakhel, Amin Nikanjam, Foutse Khomh, Michel C. Desmarais, Giuliano Antoniol

AI总结:

本研究通过分析333个来自主流LLM的代码缺陷,识别出10种缺陷模式,并通过调查验证,为提升LLM生成代码质量提供指导。

摘要:

用于代码的大型语言模型(LLMs)近期受到了广泛关注。它们可以根据提供的提示生成不同编程语言的代码,实现了软件工程(SE)领域长久以来的梦想,即自动代码生成。与人类编写的代码类似,LLM生成的代码也容易出现缺陷,而这些缺陷尚未得到社区的深入检验。鉴于基于LLM的代码生成工具(如GitHub Copilot)在SE活动中的日益普及,理解LLM生成代码中缺陷的特征至关重要。本文检验了从使用三个领先的LLM(即CodeGen、PanGu-Coder和Codex)生成的代码中收集的333个缺陷样本,并识别出以下10种独特的缺陷模式:误解、语法错误、愚蠢错误、提示偏见代码、缺失边界情况、错误输入类型、幻觉对象、错误属性、不完整生成和非提示考虑。这些缺陷模式以分类法的形式呈现。通过一项涉及34位LLM从业者和研究者的在线调查,对识别出的缺陷模式进行了验证。调查参与者普遍肯定了这些缺陷模式的重要性和普遍性。研究者和从业者可以利用这些发现为LLM生成的代码开发有效的质量保证技术。本研究揭示了LLM生成代码的独特特征。

英文摘要:

Large Language Models (LLMs) for code have gained significant attention recently. They can generate code in different programming languages based on provided prompts, fulfilling a long-lasting dream in Software Engineering (SE), i.e., automatic code generation. Similar to human-written code, LLM-generated code is prone to bugs, and these bugs have not yet been thoroughly examined by the community. Given the increasing adoption of LLM-based code generation tools (e.g., GitHub Copilot) in SE activities, it is critical to understand the characteristics of bugs contained in code generated by LLMs. This paper examines a sample of 333 bugs collected from code generated using three leading LLMs (i.e., CodeGen, PanGu-Coder, and Codex) and identifies the following 10 distinctive bug patterns: Misinterpretations, Syntax Error, Silly Mistake, Prompt-biased code, Missing Corner Case, Wrong Input Type, Hallucinated Object, Wrong Attribute, Incomplete Generation, and Non-Prompted Consideration. The bug patterns are presented in the form of a taxonomy. The identified bug patterns are validated using an online survey with 34 LLM practitioners and researchers. The surveyed participants generally asserted the significance and prevalence of the bug patterns. Researchers and practitioners can leverage these findings to develop effective quality assurance techniques for LLM-generated code. This study sheds light on the distinctive characteristics of LLM-generated code.

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

↑