用树状结构生成代码,让AI更稳定地解决复杂任务
Tree-of-Code: A Hybrid Approach for Robust Complex Task Planning and Execution
- 将代码执行结果构建成决策树,分步探索多种解法
- 通过广度优先搜索遍历路径,投票选出最可靠结果
- 适合需要严谨推理的复杂任务,如跨领域问题求解
大型语言模型(LLMs)的卓越能力显著推动了智能体的发展与应用。近期研究发现,将基于LLM的智能体动作统一为Python代码(CodeAct)是一种有前景的方法。然而,传统的逐步代码生成方式常缺乏一致性和鲁棒性,导致在复杂推理和域外任务中表现不稳定。本文提出一种名为Tree-of-Code(ToC)的新方法,通过融合Tree-of-Thought与CodeAct的核心思想,构建端到端的复杂任务规划与执行机制。在该框架中,每个代码执行结果被视为决策树中的一个节点,采用广度优先搜索策略探索潜在解,并通过节点输出的投票机制确定最终结果。
原文摘要 · Abstract (English)
The exceptional capabilities of large language models (LLMs) have substantially accelerated the rapid rise and widespread adoption of agents. Recent studies have demonstrated that generating Python code to consolidate LLM-based agents' actions into a unified action space (CodeAct) is a promising approach for developing real-world LLM agents. However, this step-by-step code generation approach often lacks consistency and robustness, leading to instability in agent applications, particularly for complex reasoning and out-of-domain tasks. In this paper, we propose a novel approach called Tree-of-Code (ToC) to tackle the challenges of complex problem planning and execution with an end-to-end mechanism. By integrating key ideas from both Tree-of-Thought and CodeAct, ToC combines their strengths to enhance solution exploration. In our framework, each final code execution result is treated as a node in the decision tree, with a breadth-first search strategy employed to explore potential solutions. The final outcome is determined through a voting mechanism based on the outputs of the nodes.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。