深入探究大语言模型代码生成错误:是什么与为什么?
A Deep Dive Into Large Language Model Code Generation Mistakes: What and Why?
AI总结:
该研究针对大语言模型代码生成的非语法错误问题,覆盖独立函数与真实软件开发两类场景,识别出七类错误及六类成因,验证了GPT-4结合ReAct提示的错误成因检测效果,为提升代码生成质量提供参考。
摘要:
大语言模型(LLM)的最新进展推动其在自动化代码生成领域得到广泛应用,但这类模型仍可能生成偏离需求规范的缺陷代码。既往研究主要关注LLM生成的独立函数中的错误,忽略了真实软件开发场景——这类场景下代码的成功生成需要外部依赖等软件上下文。\n本文同时考虑这两类代码生成场景,识别出一系列由LLM对编码问题规范理解偏差导致的非语法错误。通过大量人工分析,我们划分出七类非语法错误,其中四类是既往研究未覆盖的。为深入理解这些错误,我们从多维度提出了六类错误成因。此外,我们还探究了LLM检测错误及其成因的效果。评估结果显示,采用ReAct提示技术的GPT-4在识别LLM错误成因(如误导性函数签名)时,F1值最高可达0.65。我们认为这些发现为提升LLM生成代码的质量提供了有价值的参考。
英文摘要:
Recent advancements in Large Language Models (LLMs) have led to their widespread application in automated code generation. However, these models can still generate defective code that deviates from the specification. Previous research has mainly focused on the mistakes in LLM-generated standalone functions, overlooking real-world software development situations where the successful generation of the code requires software contexts such as external dependencies. In this paper, we considered both of these code generation situations and identified a range of \textit{non-syntactic mistakes} arising from LLMs' misunderstandings of coding question specifications. Seven categories of non-syntactic mistakes were identified through extensive manual analyses, four of which were missed by previous works. To better understand these mistakes, we proposed six reasons behind these mistakes from various perspectives. Moreover, we explored the effectiveness of LLMs in detecting mistakes and their reasons. Our evaluation demonstrated that GPT-4 with the ReAct prompting technique can achieve an F1 score of up to 0.65 when identifying reasons for LLM's mistakes, such as misleading function signatures. We believe that these findings offer valuable insights into enhancing the quality of LLM-generated code.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。