一句话:提出PairCoder,用导航员与驾驶员两个LLM智能体结对编程,通过多方案探索与执行反馈迭代提升代码生成准确率。
LLM在代码生成上表现突出,但现有提示与精化方法因解法计划僵化,在复杂编程问题上仍受限。本文借鉴结对编程实践提出PairCoder,包含两个协作LLM智能体:Navigator负责提出候选方案、选择当前最优计划,并依据执行反馈决定下一轮迭代;Driver在Navigator指导下完成初始代码生成、代码测试与精化。该交替迭代流程实现多方案探索与反馈驱动精化。作者在多种代码生成基准上使用开源与闭源LLM进行评估,结果表明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.
DOI 原文 ·
@inproceedings{paperbot8382,
title = {A Pair Programming Framework for Code Generation via Multi-Plan Exploration and Feedback-Driven Refinement},
author = {Huan Zhang and Wei Cheng and Yuhan Wu and Wei Hu},
booktitle = {ASE},
year = {2024},
doi = {10.1145/3691620.3695506}
}