苹果研究:先规划还是先检索工具?
苹果机器学习研究团队在 EMNLP 发表论文,由 Mingfei Zhang 等人比较工具增强型 LLM 智能体在规划前发现 API 的两种架构:Retrieve-then-Plan(RtP)先嵌入用户查询并检索相似工具,Plan-then-Retrieve(PtR)则先让模型生成抽象工具桩(Abstract Tool Stubs),再以其作为检索查询。在包含 46,984 个 API、50 个类别的 ToolBench 上,单工具查询中 RtP 优于 PtR,多工具查询中 PtR 优于 RtP;这一交叉在 k=1 至 20 的检索预算、1k 至 47k 的注册表规模,以及 Gemini 2.5 Flash 和 gpt-oss-120b 上均成立。作者还描述了“工具桩幻觉”失败模式,指出 PtR 额外的发现调用约使推理成本翻倍,并提出可用 RtP 的 top-1 检索分数驱动复杂度自适应路由。
对于构建工具型智能体的团队,这项研究提供了基于基准的取舍依据:检索顺序应随查询复杂度变化,而现有的 RtP top-1 检索分数可能足以驱动方法路由。
content type paperpublished October 2026
Plan or Retrieve First? A Scale Study of Tool Discovery Architectures
AuthorsMingfei Zhang, Amit Surana, Ziauddin Majid, Chenxi Wang, Michael Xu
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).
#Apple#Apple Machine Learning Research#ToolBench#Gemini 2.5 Flash#gpt-oss-120b#EMNLP