通过多方案探索与反馈驱动改进实现代码生成的结对编程框架
A Pair Programming Framework for Code Generation via Multi-Plan Exploration and Feedback-Driven Refinement
AI总结:
本文提出 PairCoder 双智能体结对编程框架,通过 Navigator 多方案规划与 Driver 实现测试的反馈迭代,显著提升代码生成 pass@1。
摘要:
大语言模型(LLM)在代码生成任务上已取得令人瞩目的性能。尽管已有研究通过提示技术和代码改进来增强 LLM,但由于解决方案计划僵化,它们在处理复杂编程问题时仍然困难。本文借鉴结对编程实践,提出 PairCoder,这是一种新颖的、基于 LLM 的代码生成框架。PairCoder 纳入两个协作式 LLM 智能体:负责高层规划的 Navigator 智能体和负责具体实现的 Driver 智能体。Navigator 负责提出有前景的解决方案计划、选择当前最优计划,并根据执行反馈指导下一轮迭代。Driver 遵循 Navigator 的指导,承担初始代码生成、代码测试和改进工作。这种交错且迭代的工作流包含多计划探索和基于反馈的改进,模拟了结对程序员之间的协作。我们在多个代码生成基准上使用开源和闭源 LLM 对 PairCoder 进行评估。大量实验结果表明 PairCoder 具有优越的准确性;与直接提示 LLM 相比,其 pass@1 实现了 12.00%-162.43% 的相对提升。
英文摘要:
Large language models (LLMs) have achieved impressive performance on code generation. Although prior studies enhanced LLMs with prompting techniques and code refinement, they still struggle with complex programming problems due to rigid solution plans. In this paper, we draw on pair programming practices to propose PairCoder, a novel LLM-based framework for code generation. PairCoder incorporates two collaborative LLM agents, namely a Navigator agent for high-level planning and a Driver agent for specific implementation. The Navigator is responsible for proposing promising solution plans, selecting the current optimal plan, and directing the next iteration round based on execution feedback. The Driver follows the guidance of Navigator to undertake initial code generation, code testing, and refinement. This interleaved and iterative workflow involves multi-plan exploration and feedback-based refinement, which mimics the collaboration of pair programmers. We evaluate PairCoder with both open-source and closed-source LLMs on various code generation benchmarks. Extensive experimental results demonstrate the superior accuracy of PairCoder, achieving relative pass@1 improvements of 12.00%-162.43% compared to prompting LLMs directly.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。