arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2504.04220cs.SE
收藏

AdaCoder:一种用于函数级代码生成的自适应规划与多智能体框架

AdaCoder: An Adaptive Planning and Multi-Agent Framework for Function-Level Code Generation

Yueheng Zhu, Chao Liu, Xuan He, Xiaoxue Ren, Zhongxin Liu, Ruwei Pan, Hongyu Zhang

AI总结:

针对现有函数级代码生成多智能体框架在不同基础LLM上泛化性不稳定的问题,提出自适应规划多智能体框架AdaCoder,通过两阶段策略提升泛化性,在Pass@1上平均提升27.69%,且推理更快、token消耗更低。

摘要:

最近,研究人员提出了许多用于函数级代码生成的多智能体框架,旨在通过基于任务描述自动生成函数级源代码来提高软件开发生产力。典型的多智能体框架由基于大型语言模型(LLM)的智能体组成,负责任务规划、代码生成、测试、调试等。研究表明,现有的多智能体代码生成框架在 ChatGPT 上表现良好。然而,它们在其他基础 LLM 上的泛化性尚未得到系统的研究。在本文中,我们报告了一项实证研究,考察了四个最先进的多智能体代码生成框架在六个具有不同参数规模、架构和性能水平的开源 LLM 上的泛化性。我们的研究揭示了现有框架在不同基础 LLM 上泛化性的不稳定性。基于从实证研究中获得的发现,我们提出了 AdaCoder,一种用于函数级代码生成的新型自适应规划多智能体框架。AdaCoder 有两个阶段。阶段 1 是一个无规划的初始代码生成步骤,使用基于 LLM 的编码智能体和基于脚本的测试智能体来释放 LLM 的原生能力,识别超出 LLM 能力的用例,并确定阻碍执行的错误。阶段 2 添加了一个基于规则的调试智能体和一个基于 LLM 的规划智能体,用于带规划的迭代代码生成。我们的评估表明,AdaCoder 在不同 LLM 上实现了更高的泛化性。与最佳基线 MapCoder 相比,AdaCoder 在 Pass@1 上平均高 27.69%,推理速度快 16 倍,token 消耗低 12 倍。

英文摘要:

Recently, researchers have proposed many multi-agent frameworks for function-level code generation, which aim to improve software development productivity by automatically generating function-level source code based on task descriptions. A typical multi-agent framework consists of Large Language Model (LLM)-based agents that are responsible for task planning, code generation, testing, debugging, etc. Studies have shown that existing multi-agent code generation frameworks perform well on ChatGPT. However, their generalizability across other foundation LLMs remains unexplored systematically. In this paper, we report an empirical study on the generalizability of four state-of-the-art multi-agent code generation frameworks across six open-source LLMs with varying parameter sizes, architectures, and performance levels. Our study reveals the unstable generalizability of existing frameworks on diverse foundation LLMs. Based on the findings obtained from the empirical study, we propose AdaCoder, a novel adaptive planning, multi-agent framework for function-level code generation. AdaCoder has two phases. Phase-1 is an initial code generation step without planning, which uses an LLM-based coding agent and a script-based testing agent to unleash LLM's native power, identify cases beyond LLM's power, and determine the errors hindering execution. Phase-2 adds a rule-based debugging agent and an LLM-based planning agent for iterative code generation with planning. Our evaluation shows that AdaCoder achieves higher generalizability on diverse LLMs. Compared to the best baseline MapCoder, AdaCoder is on average 27.69% higher in Pass@1, 16 times faster in inference, and 12 times lower in token consumption.

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

↑