arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.04329cs.CL
收藏

CodeTree:面向大语言模型代码生成的智能体引导树搜索

CodeTree: Agent-guided Tree Search for Code Generation with Large Language Models

The University of Texas at Austin(德克萨斯大学奥斯汀分校);Salesforce Research Asia(Salesforce 亚洲研究院);Salesforce Research(Salesforce 研究院)

Jierui Li, Hung Le, Yingbo Zhou, Caiming Xiong, Silvio Savarese, Doyen Sahoo

AI总结:

针对大模型在复杂代码生成中多阶段规划与调试困难的问题,提出CodeTree框架,利用统一树结构结合环境与智能体反馈指导各阶段决策,在多个基准上取得显著性能提升。

摘要:

通过在海量代码和文本数据上进行预训练,大语言模型(LLMs)在执行代码生成任务方面展现出了卓越的成就。借助额外的基于执行的反馈,这些模型可以作为智能体,具备自我完善并自主改进生成代码的能力。然而,在面对搜索空间极大的挑战性编码任务时,当前的智能体方法在多阶段规划、生成和调试方面仍存在困难。为了解决这个问题,我们提出了CodeTree,这是一个供LLM智能体在代码生成过程的不同阶段高效探索搜索空间的框架。具体而言,我们采用统一的树结构来显式探索不同的编码策略,生成相应的编码解决方案,并随后对这些解决方案进行完善。在每个阶段,探索过程的关键决策(排序、终止、扩展)均由环境基于执行的反馈和LLM智能体生成的反馈共同指导。我们在7个代码生成基准上全面评估了CodeTree,并展示了CodeTree相对于强基线的显著性能提升。使用GPT-4o作为基础模型,我们在HumanEval上持续取得了95.1的顶尖结果,在MBPP上为98.7,在CodeContests上为43.0。在极具挑战性的SWEBench基准上,我们的方法带来了显著的性能提升。

英文摘要:

Pre-trained on massive amounts of code and text data, large language models (LLMs) have demonstrated remarkable achievements in performing code generation tasks. With additional execution-based feedback, these models can act as agents with capabilities to self-refine and improve generated code autonomously. However, on challenging coding tasks with extremely large search space, current agentic approaches still struggle with multi-stage planning, generating, and debugging. To address this problem, we propose CodeTree, a framework for LLM agents to efficiently explore the search space in different stages of the code generation process. Specifically, we adopted a unified tree structure to explicitly explore different coding strategies, generate corresponding coding solutions, and subsequently refine the solutions. In each stage, critical decision-making (ranking, termination, expanding) of the exploration process is guided by both the environmental execution-based feedback and LLM-agent-generated feedback. We comprehensively evaluated CodeTree on 7 code generation benchmarks and demonstrated the significant performance gains of CodeTree against strong baselines. Using GPT-4o as the base model, we consistently achieved top results of 95.1 on HumanEval, 98.7 on MBPP, and 43.0 on CodeContests. On the challenging SWEBench benchmark, our approach led to significant performance gains.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑