arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.19068cs.AIcs.IR
收藏

先规划还是先检索?工具发现架构的规模研究

Plan or Retrieve First? A Scale Study of Tool Discovery Architectures

Apple(苹果公司)

Mingfei Zhang, Amit Surana, Ziauddin Majid, Chenxi Wang, Michael Xu

AI总结:

该研究对比Retrieve-then-Plan与Plan-then-Retrieve两种工具发现架构,发现单工具查询时RtP更优、多工具查询时PtR更优,且提出复杂度自适应路由的实用方向。

摘要:

工具增强型大语言模型(LLM)智能体在规划执行前会从大型注册表中发现相关API,但有限的上下文窗口无法将所有工具定义注入单个提示。主流方法我们称为“检索后规划(Retrieve-then-Plan, RtP)”,它会嵌入用户查询并通过近似最近邻搜索检索相似工具。我们研究了另一种“规划后检索(Plan-then-Retrieve, PtR)”范式,其中LLM首先生成抽象工具存根(描述所需能力的假设函数签名),随后将其作为针对注册表的检索查询。在ToolBench(46984个唯一API端点,50个类别)上针对单工具(G1)、类别内多工具(G2)和跨类别多工具(G3)查询子集进行评估,我们发现了清晰的复杂度相关交叉现象:RtP在单工具查询上优于PtR,而PtR在多工具查询上优于RtP。该交叉在每个检索预算(k=1至20)下均成立,在1k至47k API的注册表规模下具有鲁棒性,且在模型家族(Gemini 2.5 Flash和gpt-oss-120b)中一致。我们表征了一种存根幻觉失败模式(LLM编造看似合理但不存在的API名称),这是一把双刃剑:在简单查询中,PtR的存根抽象了RtP直接匹配的专有名词信号,而在复杂查询中,同一机制将多方面意图分解为功能子需求。我们进一步分析了令牌开销,表明PtR的额外发现调用大致使推理成本翻倍,这在多工具查询上有回报但在单工具查询上不利,推动了复杂度自适应路由作为实用方向,该方向可由管道中已存在的零成本信号(RtP的Top-1检索分数)驱动。

英文摘要:

Tool-augmented LLM agents discover relevant APIs from large registries before planning execution, yet finite context windows prohibit injecting all tool definitions into a single prompt. The dominant approach, which we term Retrieve-then-Plan (RtP), embeds the user query and retrieves similar tools via approximate nearest-neighbor search. We study an alternative Plan-then-Retrieve (PtR) paradigm in which the LLM first generates Abstract Tool Stubs (hypothesized function signatures describing needed capabilities) which then serve as retrieval queries against the registry. Evaluating on ToolBench (46,984 unique API endpoints, 50 categories) across single-tool (G1), intra-category multi-tool (G2), and cross-category multi-tool (G3) query subsets, we find a clear complexity-dependent crossover: RtP outperforms PtR on single-tool queries while PtR outperforms RtP on multi-tool queries. This crossover holds at every retrieval budget (k=1 to 20), is robust across registry sizes from 1k to 47k APIs, and is consistent across model families (Gemini 2.5 Flash and gpt-oss-120b). We characterize a stub-hallucination failure mode (the LLM invents plausible but non-existent API names) that acts as a double-edged sword: on simple queries PtR's stubs abstract away proper-noun signals that RtP matches directly, yet on complex queries the same mechanism decomposes multi-faceted intent into functional sub-needs. We further analyze token overhead and show that PtR's extra discovery call roughly doubles inference cost, which pays off on multi-tool queries but hurts on single-tool ones, motivating complexity-adaptive routing as a practical direction, one that can be driven by a zero-cost signal already present in the pipeline (RtP's top-1 retrieval score).

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑