arXiv:2409.05001cs.SEcs.AI2024-09中稿 · the 39th IEEE/ACM …被引 44

用双智能体协作生成代码,提升复杂问题求解准确率。

A Pair Programming Framework for Code Generation via Multi-Plan Exploration and Feedback-Driven Refinement

  • 双智能体分工:导航者规划方案,驾驶员实现编码。
  • 多方案探索+反馈迭代,准确率提升超12%至162%。
  • 适合解决复杂编程任务,尤其适配大模型代码生成场景。

大型语言模型(LLMs)在代码生成任务中表现优异,但面对复杂编程问题时仍因解决方案僵化而受限。本文受结对编程启发,提出PairCoder框架,包含两个协同的LLM智能体:负责高层规划的导航者(Navigator)与执行具体实现的驾驶员(Driver)。导航者生成多种可行解并根据执行反馈选择最优方案,指导下一轮迭代;驾驶员则依据导航者指引完成初始编码、测试与优化。该交替迭代流程实现了多方案探索与反馈驱动的精细化修正,模拟真实结对编程协作模式。在多个代码生成基准测试中,使用开源与闭源模型评估表明,PairCoder相比直接提示调用模型,平均通过率(pass@1)提升12.00%至162.43%,显著优于现有方法。

原文摘要 · Abstract (English)

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.

代码生成大模型双智能体程序推理

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。