arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2408.00994cs.SEcs.AIcs.CL
收藏

ArchCode:将软件需求融入大语言模型代码生成

ArchCode: Incorporating Software Requirements in Code Generation with Large Language Models

Seoul National University(首尔大学);SNU-LG AI Research Center(首尔大学-LG人工智能研究中心)

Hojae Han, Jaejin Kim, Jaeseok Yoo, Youngwon Lee, Seung-won Hwang

AI总结:

本文提出ARCHCODE框架,通过上下文学习从文本描述中组织并推断软件需求,生成代码和定制测试用例,并引入HumanEval-NFR基准,显著提升LLMs在功能性与非功能性需求上的代码生成表现。

摘要:

本文旨在扩展大语言模型(LLMs)的代码生成能力,使其能够根据给定的文本描述自动管理全面的软件需求。这些需求既包括功能性需求(即为输入实现预期行为),也包括非功能性需求(例如时间/空间性能、鲁棒性、可维护性)。然而,文本描述可能冗长地表达需求,甚至可能遗漏其中一些需求。我们提出了ARCHCODE,这是一个新颖的框架,利用上下文学习来组织描述中观察到的需求,并从中推断未表达的需求。ARCHCODE从给定描述中生成需求,并以这些需求为条件生成代码片段和测试用例。每个测试用例针对其中一项需求定制,从而能够根据代码片段执行结果对需求的符合程度对代码片段进行排序。公开基准测试表明,ARCHCODE增强了满足功能性需求的能力,显著提高了Pass@k分数。此外,我们引入了HumanEval-NFR,这是首个针对LLMs在代码生成中非功能性需求的评估,证明了ARCHCODE相对于基线方法的优越性。ARCHCODE的实现和HumanEval-NFR基准测试均已公开可用。

英文摘要:

This paper aims to extend the code generation capability of large language models (LLMs) to automatically manage comprehensive software requirements from given textual descriptions. Such requirements include both functional (i.e. achieving expected behavior for inputs) and non-functional (e.g., time/space performance, robustness, maintainability) requirements. However, textual descriptions can either express requirements verbosely or may even omit some of them. We introduce ARCHCODE, a novel framework that leverages in-context learning to organize requirements observed in descriptions and to extrapolate unexpressed requirements from them. ARCHCODE generates requirements from given descriptions, conditioning them to produce code snippets and test cases. Each test case is tailored to one of the requirements, allowing for the ranking of code snippets based on the compliance of their execution results with the requirements. Public benchmarks show that ARCHCODE enhances to satisfy functional requirements, significantly improving Pass@k scores. Furthermore, we introduce HumanEval-NFR, the first evaluation of LLMs' non-functional requirements in code generation, demonstrating ARCHCODE's superiority over baseline methods. The implementation of ARCHCODE and the HumanEval-NFR benchmark are both publicly accessible.

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

↑