Tool Learning in the Wild: Empowering Language Models as Automatic Tool Agents

📄 arXiv: 2405.16533v2 📥 PDF

作者: Zhengliang Shi, Shen Gao, Lingyong Yan, Yue Feng, Xiuyi Chen, Zhumin Chen, Dawei Yin, Suzan Verberne, Zhaochun Ren

分类: cs.CL

发布日期: 2024-05-26 (更新: 2025-03-04)

备注: Accepted by WWW 2025


💡 一句话要点

AutoTools:赋能语言模型作为自动工具代理,实现工具学习

🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)

关键词: 大型语言模型 工具学习 自动化 函数编程 知识增强

📋 核心要点

  1. 现有方法依赖人工解析工具文档和创建演示,难以扩展到大型工具集,且集成方式限制了LLM的灵活性。
  2. AutoTools框架通过自动转换工具文档为可调用函数,并集成到可执行程序中,灵活地实现工具使用。
  3. 实验表明AutoTools在现有和新的基准测试中表现优越,并通过AutoTools-learning提升了LLM的工具使用能力。

📝 摘要(中文)

本文提出AutoTools框架,旨在使大型语言模型(LLMs)能够自动化工具使用的工作流程。该框架自动将工具文档转换为可调用的函数,并验证其语法和运行时正确性。然后,LLM将这些函数集成到可执行程序中,以解决实际任务,从而灵活地将工具使用操作融入其推理过程。在现有和新收集的、更具挑战性的基准测试上的大量实验表明了该框架的优越性。受这些有希望的结果的启发,进一步研究了如何在AutoTools中提高LLM的专业知识,特别是参数较少的开源LLM。因此,提出了AutoTools-learning方法,利用34k高质量合成数据的三个学习任务(包括文档理解、相关性学习和函数编程)来训练LLM。细粒度的结果验证了整体训练方法和每个单独任务的有效性。该方法是利用LLM通过外部工具解决现实世界任务的重要一步。

🔬 方法详解

问题定义:现有方法在利用大型语言模型(LLMs)使用外部工具时,面临着手动解析工具文档和创建上下文演示的难题。这种手动过程需要领域专业知识,并且难以扩展到大型工具集。此外,现有方法严重依赖于特定的推理技术或特殊token,将自由形式的LLM生成与工具调用操作集成,限制了LLM在处理各种工具规范和集成多个工具方面的灵活性。

核心思路:AutoTools的核心思路是自动化工具使用的工作流程,使LLM能够自动将工具文档转换为可调用的函数,并验证其正确性。通过将这些函数集成到可执行程序中,LLM可以灵活地将工具使用操作融入其推理过程,从而解决实际任务。这种自动化方法旨在克服手动解析和集成工具的局限性,提高LLM使用工具的效率和灵活性。

技术框架:AutoTools框架主要包含以下几个阶段:1) 工具文档转换:LLM自动将工具文档转换为可调用的函数,包括解析文档、提取函数签名和参数信息等。2) 语法和运行时验证:验证转换后的函数的语法和运行时正确性,确保函数能够正确执行。3) 程序集成:将转换后的函数集成到可执行程序中,LLM可以根据任务需求调用这些函数。4) 任务执行:LLM执行集成了工具函数的程序,完成实际任务。

关键创新:AutoTools最重要的技术创新点在于其自动化工具使用流程的能力。与现有方法相比,AutoTools无需手动解析工具文档和创建演示,而是通过LLM自动完成这些任务,从而大大提高了工具使用的效率和可扩展性。此外,AutoTools还能够灵活地将工具使用操作融入LLM的推理过程,使其能够更好地处理各种工具规范和集成多个工具。

关键设计:AutoTools-learning方法通过三个学习任务来提升LLM的工具使用能力:1) 文档理解:训练LLM理解工具文档,提取关键信息。2) 相关性学习:训练LLM判断工具与任务的相关性,选择合适的工具。3) 函数编程:训练LLM编写调用工具函数的代码。该方法使用34k高质量合成数据进行训练,并取得了显著的效果。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,AutoTools在工具使用任务上表现优于现有方法。通过AutoTools-learning,LLM的工具使用能力得到了显著提升。具体而言,在多个基准测试中,AutoTools在任务完成率和效率方面均取得了显著的提升,证明了其有效性和优越性。

🎯 应用场景

AutoTools具有广泛的应用前景,可应用于自动化软件开发、智能客服、数据分析等领域。通过赋能LLM自动使用各种工具,AutoTools可以提高工作效率,降低人工成本,并为用户提供更智能、更便捷的服务。未来,AutoTools有望成为LLM在现实世界中发挥更大作用的关键技术。

📄 摘要(原文)

Augmenting large language models (LLMs) with external tools has emerged as a promising approach to extend their utility, enabling them to solve practical tasks. Previous methods manually parse tool documentation and create in-context demonstrations, transforming tools into structured formats for LLMs to use in their step-by-step reasoning. However, this manual process requires domain expertise and struggles to scale to large toolsets. Additionally, these methods rely heavily on ad-hoc inference techniques or special tokens to integrate free-form LLM generation with tool-calling actions, limiting the LLM's flexibility in handling diverse tool specifications and integrating multiple tools. In this work, we propose AutoTools, a framework that enables LLMs to automate the tool-use workflow. Specifically, the LLM automatically transforms tool documentation into callable functions, verifying syntax and runtime correctness. Then, the LLM integrates these functions into executable programs to solve practical tasks, flexibly grounding tool-use actions into its reasoning processes. Extensive experiments on existing and newly collected, more challenging benchmarks illustrate the superiority of our framework. Inspired by these promising results, we further investigate how to improve the expertise of LLMs, especially open-source LLMs with fewer parameters, within AutoTools. Thus, we propose the AutoTools-learning approach, training the LLMs with three learning tasks on 34k instances of high-quality synthetic data, including documentation understanding, relevance learning, and function programming. Fine-grained results validate the effectiveness of our overall training approach and each individual task. Our methods are an important step towards the use of LLMs for solving real-world tasks with external tools.