{"title":"通过多计划探索和反馈驱动改进生成代码的结对编程框架","authors":"Huan Zhang, Wei Cheng, Yuhan Wu, Wei Hu","doi":"arxiv-2409.05001","DOIUrl":null,"url":null,"abstract":"Large language models (LLMs) have achieved impressive performance on code\ngeneration. Although prior studies enhanced LLMs with prompting techniques and\ncode refinement, they still struggle with complex programming problems due to\nrigid solution plans. In this paper, we draw on pair programming practices to\npropose PairCoder, a novel LLM-based framework for code generation. PairCoder\nincorporates two collaborative LLM agents, namely a Navigator agent for\nhigh-level planning and a Driver agent for specific implementation. The\nNavigator is responsible for proposing promising solution plans, selecting the\ncurrent optimal plan, and directing the next iteration round based on execution\nfeedback. The Driver follows the guidance of Navigator to undertake initial\ncode generation, code testing, and refinement. This interleaved and iterative\nworkflow involves multi-plan exploration and feedback-based refinement, which\nmimics the collaboration of pair programmers. We evaluate PairCoder with both\nopen-source and closed-source LLMs on various code generation benchmarks.\nExtensive experimental results demonstrate the superior accuracy of PairCoder,\nachieving relative pass@1 improvements of 12.00%-162.43% compared to prompting\nLLMs directly.","PeriodicalId":501278,"journal":{"name":"arXiv - CS - Software Engineering","volume":"7 1","pages":""},"PeriodicalIF":0.0000,"publicationDate":"2024-09-08","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":"{\"title\":\"A Pair Programming Framework for Code Generation via Multi-Plan Exploration and Feedback-Driven Refinement\",\"authors\":\"Huan Zhang, Wei Cheng, Yuhan Wu, Wei Hu\",\"doi\":\"arxiv-2409.05001\",\"DOIUrl\":null,\"url\":null,\"abstract\":\"Large language models (LLMs) have achieved impressive performance on code\\ngeneration. Although prior studies enhanced LLMs with prompting techniques and\\ncode refinement, they still struggle with complex programming problems due to\\nrigid solution plans. In this paper, we draw on pair programming practices to\\npropose PairCoder, a novel LLM-based framework for code generation. PairCoder\\nincorporates two collaborative LLM agents, namely a Navigator agent for\\nhigh-level planning and a Driver agent for specific implementation. The\\nNavigator is responsible for proposing promising solution plans, selecting the\\ncurrent optimal plan, and directing the next iteration round based on execution\\nfeedback. The Driver follows the guidance of Navigator to undertake initial\\ncode generation, code testing, and refinement. This interleaved and iterative\\nworkflow involves multi-plan exploration and feedback-based refinement, which\\nmimics the collaboration of pair programmers. We evaluate PairCoder with both\\nopen-source and closed-source LLMs on various code generation benchmarks.\\nExtensive experimental results demonstrate the superior accuracy of PairCoder,\\nachieving relative pass@1 improvements of 12.00%-162.43% compared to prompting\\nLLMs directly.\",\"PeriodicalId\":501278,\"journal\":{\"name\":\"arXiv - CS - Software Engineering\",\"volume\":\"7 1\",\"pages\":\"\"},\"PeriodicalIF\":0.0000,\"publicationDate\":\"2024-09-08\",\"publicationTypes\":\"Journal Article\",\"fieldsOfStudy\":null,\"isOpenAccess\":false,\"openAccessPdf\":\"\",\"citationCount\":\"0\",\"resultStr\":null,\"platform\":\"Semanticscholar\",\"paperid\":null,\"PeriodicalName\":\"arXiv - CS - Software Engineering\",\"FirstCategoryId\":\"1085\",\"ListUrlMain\":\"https://doi.org/arxiv-2409.05001\",\"RegionNum\":0,\"RegionCategory\":null,\"ArticlePicture\":[],\"TitleCN\":null,\"AbstractTextCN\":null,\"PMCID\":null,\"EPubDate\":\"\",\"PubModel\":\"\",\"JCR\":\"\",\"JCRName\":\"\",\"Score\":null,\"Total\":0}","platform":"Semanticscholar","paperid":null,"PeriodicalName":"arXiv - CS - Software Engineering","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/arxiv-2409.05001","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
A Pair Programming Framework for Code Generation via Multi-Plan Exploration and Feedback-Driven Refinement
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.