ToolCoder:一种面向大型语言模型的系统性代码赋能工具学习框架
ToolCoder: A Systematic Code-Empowered Tool Learning Framework for Large Language Models
AI总结:
针对大型语言模型工具学习依赖手工提示和多步规划难等问题,提出ToolCoder框架,将其转化为代码生成任务,利用Python函数脚手架和错误回溯机制提升任务完成准确率与执行可靠性。
摘要:
工具学习已成为大型语言模型(LLMs)通过与外部工具交互来解决复杂现实任务的关键能力。现有方法面临重大挑战,包括依赖手工制作的提示、多步规划的困难,以及缺乏精确的错误诊断和反思机制。我们提出了ToolCoder,这是一个将工具学习重新表述为代码生成任务的新颖框架。受软件工程原则启发,ToolCoder将自然语言查询转换为结构化的Python函数脚手架,并使用描述性注释系统地分解任务,使LLMs能够利用编程范式进行复杂的推理和规划。然后,它生成并执行函数实现以获得最终响应。此外,ToolCoder将成功执行的函数存储在存储库中以促进代码重用,同时利用错误回溯机制进行系统调试,优化了执行效率和鲁棒性。实验表明,与现有方法相比,ToolCoder在任务完成准确性和执行可靠性方面取得了卓越的性能,确立了以代码为中心的方法在工具学习中的有效性。
英文摘要:
Tool learning has emerged as a crucial capability for large language models (LLMs) to solve complex real-world tasks through interaction with external tools. Existing approaches face significant challenges, including reliance on hand-crafted prompts, difficulty in multi-step planning, and lack of precise error diagnosis and reflection mechanisms. We propose ToolCoder, a novel framework that reformulates tool learning as a code generation task. Inspired by software engineering principles, ToolCoder transforms natural language queries into structured Python function scaffold and systematically breaks down tasks with descriptive comments, enabling LLMs to leverage coding paradigms for complex reasoning and planning. It then generates and executes function implementations to obtain final responses. Additionally, ToolCoder stores successfully executed functions in a repository to promote code reuse, while leveraging error traceback mechanisms for systematic debugging, optimizing both execution efficiency and robustness. Experiments demonstrate that ToolCoder achieves superior performance in task completion accuracy and execution reliability compared to existing approaches, establishing the effectiveness of code-centric approaches in tool learning.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。