AnyTool: Self-Reflective, Hierarchical Agents for Large-Scale API Calls

📄 arXiv: 2402.04253v1 📥 PDF

作者: Yu Du, Fangyun Wei, Hongyang Zhang

分类: cs.CL

发布日期: 2024-02-06

🔗 代码/项目: GITHUB


💡 一句话要点

提出AnyTool以优化大规模API调用的工具使用

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

关键词: API调用 自我反思机制 层次化检索 大规模工具使用 智能代理

📋 核心要点

  1. 现有方法在处理大规模API调用时,常常面临工具选择不当和效率低下的问题。
  2. AnyTool通过引入层次结构的API检索器和自我反思机制,优化了API的选择和使用过程。
  3. 实验结果显示,AnyTool在ToolBench上的平均通过率比ToolLLM高出35.4%,展现出显著的性能提升。

📝 摘要(中文)

我们介绍了AnyTool,这是一种大型语言模型代理,旨在革命性地利用大量工具来解决用户查询。我们利用来自Rapid API的超过16,000个API,假设其中一部分API能够有效解决查询。AnyTool主要包括三个元素:具有层次结构的API检索器、用于通过选定API候选者解决用户查询的求解器,以及自我反思机制,当初始解决方案不可行时重新激活AnyTool。AnyTool利用GPT-4的函数调用特性,无需训练外部模块。我们还重新审视了之前工作的评估协议,识别出该协议的局限性,导致通过率虚高。通过修订评估协议以更好地反映实际应用场景,我们引入了一个额外的基准,称为AnyToolBench。实验结果表明,AnyTool在多个数据集上优于强基线,如ToolLLM和针对工具使用优化的GPT-4变体。

🔬 方法详解

问题定义:本论文旨在解决在大规模API调用中,如何有效选择和利用合适的API以满足用户查询的问题。现有方法往往存在工具选择不当和效率低下的痛点。

核心思路:AnyTool的核心思路是通过层次化的API检索和自我反思机制,动态选择最合适的API来解决用户问题。这种设计旨在提高API调用的准确性和效率。

技术框架:AnyTool的整体架构包括三个主要模块:API检索器、求解器和自我反思机制。API检索器负责从大量API中筛选出潜在候选者,求解器则利用这些候选者来解决具体的用户查询,自我反思机制在初始解决方案不成功时重新激活系统。

关键创新:AnyTool的主要创新在于其自我反思机制和层次化的API检索结构,这与现有方法的静态选择方式形成了鲜明对比,能够更灵活地应对复杂查询。

关键设计:在设计中,AnyTool利用了GPT-4的函数调用特性,避免了对外部模块的训练需求。此外,评估协议的修订也为实际应用提供了更可靠的基准。实验中使用的参数和网络结构经过精心调整,以确保最佳性能。

🖼️ 关键图片

fig_0
fig_1
fig_2

📊 实验亮点

实验结果表明,AnyTool在ToolBench上的平均通过率比ToolLLM高出35.4%,显示出其在API调用效率和准确性上的显著优势。此外,AnyTool在多个数据集上的表现均优于针对工具使用优化的GPT-4变体,验证了其创新设计的有效性。

🎯 应用场景

AnyTool的潜在应用领域包括智能客服、自动化编程助手和数据分析工具等。其高效的API调用能力能够显著提升用户体验,降低开发成本,未来可能在各类软件开发和服务中发挥重要作用。

📄 摘要(原文)

We introduce AnyTool, a large language model agent designed to revolutionize the utilization of a vast array of tools in addressing user queries. We utilize over 16,000 APIs from Rapid API, operating under the assumption that a subset of these APIs could potentially resolve the queries. AnyTool primarily incorporates three elements: an API retriever with a hierarchical structure, a solver aimed at resolving user queries using a selected set of API candidates, and a self-reflection mechanism, which re-activates AnyTool if the initial solution proves impracticable. AnyTool is powered by the function calling feature of GPT-4, eliminating the need for training external modules. We also revisit the evaluation protocol introduced by previous works and identify a limitation in this protocol that leads to an artificially high pass rate. By revising the evaluation protocol to better reflect practical application scenarios, we introduce an additional benchmark, termed AnyToolBench. Experiments across various datasets demonstrate the superiority of our AnyTool over strong baselines such as ToolLLM and a GPT-4 variant tailored for tool utilization. For instance, AnyTool outperforms ToolLLM by +35.4% in terms of average pass rate on ToolBench. Code will be available at https://github.com/dyabel/AnyTool.