arXiv:2412.15305cs.SEcs.AI2024-12ACL被引 17

提出树状代码框架,让AI生成代码更连贯稳定,准确率提升近20%。

Tree-of-Code: A Tree-Structured Exploring Framework for End-to-End Code Generation and Execution in Complex Task Handling

  • 构建可执行代码的树状结构,实现端到端推理与自监督
  • 在两个数据集上比CodeAct准确率高近20%,且用时不足1/4
  • 适合需要高可靠性代码生成的自动化任务研究者

解决复杂推理任务是智能体的关键应用场景。得益于大语言模型(LLMs)在代码数据上的预训练,近期方法如CodeAct利用代码作为智能体动作,取得良好效果。然而,CodeAct依赖碎片化思考贪婪生成下一段代码,导致不一致和不稳定;且缺乏动作相关的真值(GT),使多轮交互中的监督信号与终止条件存疑。为此,我们首先提出一种简单有效的端到端代码生成范式CodeProgram,利用代码的系统逻辑对齐全局推理,实现连贯问题求解。随后,提出树状代码(ToC)框架,基于代码的可执行性自生长CodeProgram节点,实现在无真值场景下的自监督。在两个数据集上使用十种主流零样本LLM的实验表明,ToC将准确率显著提升近20%,且交互轮次不足CodeAct的1/4。部分模型甚至在单轮CodeProgram上表现优于多轮CodeAct。为探究效能与效率的权衡,我们测试了不同树大小与探索机制,并指出ToC在端到端数据生成方面对监督与强化微调的潜力。

原文摘要 · Abstract (English)

Solving complex reasoning tasks is a key real-world application of agents. Thanks to the pretraining of Large Language Models (LLMs) on code data, recent approaches like CodeAct successfully use code as LLM agents' action, achieving good results. However, CodeAct greedily generates the next action's code block by relying on fragmented thoughts, resulting in inconsistency and instability. Moreover, CodeAct lacks action-related ground-truth (GT), making its supervision signals and termination conditions questionable in multi-turn interactions. To address these issues, we first introduce a simple yet effective end-to-end code generation paradigm, CodeProgram, which leverages code's systematic logic to align with global reasoning and enable cohesive problem-solving. Then, we propose Tree-of-Code (ToC), which self-grows CodeProgram nodes based on the executable nature of the code and enables self-supervision in a GT-free scenario. Experimental results on two datasets using ten popular zero-shot LLMs show ToC remarkably boosts accuracy by nearly 20% over CodeAct with less than 1/4 turns. Several LLMs even perform better on one-turn CodeProgram than on multi-turn CodeAct. To further investigate the trade-off between efficacy and efficiency, we test different ToC tree sizes and exploration mechanisms. We also highlight the potential of ToC's end-to-end data generation for supervised and reinforced fine-tuning.

代码生成智能体自监督推理

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