[论文解读] Self-collaboration Code Generation via ChatGPT
这篇论文提出一个自我协作框架,其中 ChatGPT 的角色(分析员、编码员、测试员)作为一个虚拟团队协同生成代码,在代码生成基准上达到最先进的结果,在某些设置中甚至超过 GPT-4。
Although Large Language Models (LLMs) have demonstrated remarkable code-generation ability, they still struggle with complex tasks. In real-world software development, humans usually tackle complex tasks through collaborative teamwork, a strategy that significantly controls development complexity and enhances software quality. Inspired by this, we present a self-collaboration framework for code generation employing LLMs, exemplified by ChatGPT. Specifically, through role instructions, 1) Multiple LLM agents act as distinct `experts', each responsible for a specific subtask within a complex task; 2) Specify the way to collaborate and interact, so that different roles form a virtual team to facilitate each other's work, ultimately the virtual team addresses code generation tasks collaboratively without the need for human intervention. To effectively organize and manage this virtual team, we incorporate software-development methodology into the framework. Thus, we assemble an elementary team consisting of three LLM roles (i.e., analyst, coder, and tester) responsible for software development's analysis, coding, and testing stages. We conduct comprehensive experiments on various code-generation benchmarks. Experimental results indicate that self-collaboration code generation relatively improves 29.9%-47.1% Pass@1 compared to the base LLM agent. Moreover, we showcase that self-collaboration could potentially enable LLMs to efficiently handle complex repository-level tasks that are not readily solved by the single LLM agent.
研究动机与目标
- 通过利用协作型大模型团队来应对复杂代码生成任务的难度,从而提供动机与解决方案。
- 提出一个自我协作框架,分配角色并定义代理之间的协作以解决任务。
- 按照软件开发方法学(SDM)实例化一个包含三个角色的初步团队(分析员、编码员、测试员)。
- 展示在多个基准和接近真实世界的任务上具有鲁棒性和通用性。
提出的方法
- 通过角色指令定义分工(DOL),以创建专业化的LLM专家。
- 通过共享黑板并将角色间协调形式化来实现协作(Eq. 1 和 Eq. 2)。
- 使用 three ChatGPT roles 实例化一个初级团队(分析员、编码员、测试员),遵循瀑布式的 SDM(分析、编码、测试)。
- 使用角色指令在每个代理初始化时固定角色,从而在后续交互中无需重新提示。
- 在 MBPP、HumanEval、MBPP-ET 和 HumanEval-ET 上使用仅 NL 的提示与 NL+签名+公共测试用例设置,采用 Pass@k(强调 Pass@1)进行评估。
- 探索角色扮演与非角色提示的影响,并衡量交互轮次(MI)的效应。
实验结果
主要发现
| 方法/途径 | HumanEval | HumanEval-ET | MBPP | MBPP-ET |
|---|---|---|---|---|
| 直接 | 57.3 | 42.7 | 52.2 | 36.8 |
| 自我协作(虚拟团队) | 74.4 | 56.1 | 68.2 | 49.5 |
- 自我协作通过比直接生成提高了 29.9%–47.1% 的 Pass@1 的代码生成性能。
- 一个初级三角色团队(分析员、编码员、测试员)在四个代码生成基准上实现了最先进的结果,有时甚至超越 GPT-4。
- 角色扮演角色在 NL 驱动的提示中显著优于非角色扮演基线。
- 交互(更多轮反馈)在初始轮之后回报递减,但在处理复杂任务时仍提供持续的收益。
- 该方法在扩展测试基准(HumanEval-ET 和 MBPP-ET)上尤为有益,表明对边界情况和错误的处理更好。
- 案例研究表明该框架能够自主解决复杂的真实世界任务(如一个 Python 游戏)。
更好的研究,从现在开始
从论文设计到论文写作,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。