ToolGrad:利用文本“梯度”高效生成工具使用数据集

内容来源:https://research.google/blog/toolgrad-efficient-tool-use-dataset-generation-with-textual-gradients/
内容总结:
谷歌X研究团队提出全新数据生成框架ToolGrad,通过“先生成工具使用答案、再反推用户指令”的逆向范式,显著提升大语言模型的工具使用能力。该研究成果在ACL 2026上发表,研究团队利用ToolGrad生成了包含500条样本的工具使用数据集ToolGrad-500,并基于此微调Gemma-3系列模型。实验表明,微调后的ToolGrad-1B、4B和12B模型在伯克利函数调用排行榜(BFCL)上表现优异,部分模型甚至超越其教师模型,并在未见工具上达到与当前最先进专有模型相当的水平。
传统工具使用数据集的构建通常采用“查询优先”方式:先从API池中采样生成假设性用户指令,再通过深度优先搜索代理反复试错,寻找工具使用路径。这种方法效率低下、成本高昂,难以规模化。ToolGrad则反其道而行之,先构造真实有效的工具调用链,再据此生成对应的用户查询。由于明确的工具使用方案比模糊的用户指令包含更清晰的信息,标注过程仅需一步大语言模型调用即可完成,大幅降低了数据生成成本。
ToolGrad借鉴了TextGrad将数值梯度转化为文本反馈的思路,将其应用于合成数据集生成。框架包含提议、执行、选择、更新四个核心模块,通过迭代式“文本梯度”引导,从庞大工具库中逐步构建复杂且合法的API工作流,最终形成包含用户查询、已验证API工作流及最终AI响应的完整数据样本。
研究团队以ToolBench的1.6万余个真实API为数据库进行对比实验。结果显示,ToolGrad生成的数据复杂度更高、通过率接近100%,且生成成本显著低于传统方法。在BFCL基准测试中,ToolGrad微调模型不仅优于未微调的基础模型,还超越了ToolACE、Hammer-2.1-7B等专用工具使用模型,与Gemini、GPT、Claude等专有模型相比也具备竞争力。
该研究由周中一在谷歌访问研究员期间主导完成。团队表示,ToolGrad为高质量工具使用数据集的生成提供了更高效、更可靠的路径,解决了长期存在的成本与可扩展性瓶颈。未来工作将致力于将该框架扩展至更动态、更庞大的API生态系统,并探索持续在线学习能力,以支持随时间演进的个性化智能体应用。
中文翻译:
2026年9月10日
周忠毅,研究科学家;杜若飞,交互感知与图形负责人,Google XR
ToolGrad是一个数据生成框架,它颠覆了传统范式,首先生成工具使用答案,然后再生成用户查询。我们证明这种设计能使大语言模型获得更好的工具使用表现。
AI智能体在自动化现实世界任务方面展现出巨大潜力,例如执行Google搜索、读取本地计算机文件或运行生成的Python脚本。要实现此类智能体工作流,大语言模型需要学会正确且高效地使用工具。为了教会大语言模型使用工具,我们需要工具使用链及其对应用户查询的数据集。在我们此前发表于InstructPipe的工作中,我们手动标注了评估数据,但将人工标注扩展到高级大语言模型微调工作流是不现实的。为了简化数据工作流,此前的工作(如ToolBench和ToolACE)探索了使用智能体通过试错自动搜索工具使用路径。这种代表性的标注方法包含两个步骤:(1)从采样的API池中生成假设性的用户指令;(2)使用深度优先搜索(DFS)智能体找到其工具使用解决方案。这种方法本质上效率低下,因为其核心理念是从复杂的智能体探索中蒸馏出有价值的轨迹来训练大语言模型。
在ACL 2026上发表的《ToolGrad:利用文本“梯度”高效生成工具使用数据集》一文中,我们引入了一种替代解决方案范式。ToolGrad首先生成真实的工具使用链,然后标注其对应的用户提示。直观地说,明确的工具使用解决方案比提示提供了更清晰无歧义的信息,使得从工具使用到用户查询的标注变得容易得多,且仅需一步大语言模型操作。我们的结果表明,这种答案优先的方法能够以更低的成本生成更复杂(长视野)的工具使用数据。在我们生成的数据上训练的大语言模型也优于在基线方法上训练的模型,甚至在使用未见工具的分布外(OOD)数据集上能与最先进的专有大语言模型相媲美。
标准机器学习(ML)系统通过计算小批量训练样本上的数值损失梯度来改进,然后优化算法利用这些梯度更新模型权重。最近,TextGrad将这一范式适配到提示工程中,使用大语言模型评判器以纯文本形式提供丰富的描述性反馈——这种反馈被称为“文本梯度”。这些文本梯度随后引导给定提示的改进,使其成为能更好解决目标任务的 new draft。
ToolGrad将文本梯度的概念从提示优化适配到合成数据集生成。ToolGrad不是优化静态文本提示,而是利用这些梯度从大型工具库中迭代构建复杂、有效的API工作流。
ToolGrad具有四个核心模块,依次执行提议、执行、选择和更新。
重复这一迭代过程后,会得到一个数据样本,包含用户查询、经过验证的API工作流以及最终的AI回复。
我们首先评估数据生成的成本和质量。我们使用ToolBench作为API数据库,其中包含16k+真实世界API,来生成我们的工具使用数据集。我们将ToolBench上原始的查询优先数据生成方法(使用深度优先搜索,DFS)与我们的答案优先方法ToolGrad进行比较。结果表明,ToolGrad能够以更低的生成成本生成更复杂的工具使用数据,且通过率更高。
我们使用ToolBench的API数据库生成了名为ToolGrad-500的小规模工具使用数据集。然后我们使用ToolGrad-500微调了Gemma-3模型(1B、4B和12B),并将这些微调后的模型称为ToolGrad-1B、ToolGrad-4B和ToolGrad-12B。我们在伯克利函数调用排行榜(BFCL)上评估了这些模型的工具使用表现,BFCL是一个使用与ToolBench不同工具集的工具使用基准。我们将微调后的模型与以下模型进行比较:(1)未经微调的基座模型;(2)最先进的专有模型(Gemini、GPT和Claude);(3)最先进的工具使用专用模型(ToolACE、Hammer-2.1-7B)。
以下总结我们的发现。
ToolGrad证明,通过答案优先范式可以更高效、更可靠地生成高质量工具使用数据集。通过设计一个利用文本梯度迭代链接API的智能体框架,ToolGrad解决了生成真实数据中长期存在的成本和可扩展性瓶颈。我们的设计在数据生成中实现了接近100%的通过率,使相对紧凑的模型能够表现出色,并表明学生大语言模型甚至可以超越其教师模型。
展望未来,通过将该框架扩展到处理日益动态和庞大的API生态系统,这项研究可以拓展到更广泛的现实世界应用中。未来工作还将探索扩展这种自进化能力,以支持随时间推移的持续、即时学习以实现的个性化。随着智能体工作流日益嵌入企业和日常任务中,像ToolGrad这样的框架为训练既能力强大又具有经济可扩展性的数字智能体奠定了重要基础。
这项研究主要由周忠毅在Google担任访问研究员期间完成。我们衷心感谢主要贡献者Kohei Uehara、Haoyu Zhang、Jingtao Zhou、Lin Gu、Zheng Xu、Tatsuya Harada的支持,以及Adarsh Kowdle和Shahram Izadi的战略指导和悉心审阅。
英文来源:
September 10, 2026
Zhongyi Zhou, Research Scientist, and Ruofei Du, Interactive Perception & Graphics Lead, Google XR
ToolGrad is a data generation framework that reverses the traditional paradigm by first generating tool-use answers before user queries. We show this design enables LLMs to achieve better tool-use performance.
AI agents have shown great potential in automating real-world tasks, such as conducting a Google Search, reading local computer files, or executing generated Python scripts. To achieve such agentic workflows, LLMs need to learn how to use tools correctly and efficiently. To teach large language models tool uses, we need datasets of tool-use chains and their corresponding user queries. In our prior work introduced in InstructPipe, we manually annotated our evaluation data, but it is impractical to scale up the human annotation for advanced LLM fine-tuning workstreams. To streamline the data workstream, prior work, e.g., ToolBench and ToolACE, explored using an agent to automatically search a tool-use path with trial and error. This representative annotation approach involves two steps: (1) generate a hypothetical user instruction from a sampled API pool, and (2) use a depth-first search (DFS) agent to find its tool-use solution. This approach is inherently inefficient because its core concept is to distill valuable trajectories from a complex agent exploration for training an LLM.
In “ToolGrad: Efficient Tool-use Dataset Generation with Textual ‘Gradients’”, presented at ACL 2026, we introduce an alternative solution paradigm. ToolGrad first generates a ground-truth tool-use chain and then annotates its corresponding user prompt. Intuitively, an explicit tool-use solution provides more unambiguous information than a prompt, making the annotation, from tool usage to the use query, much easier and requiring only one LLM step. Our result shows that our answer-first approach can generate more complex (long-horizon) tool-use data with lower cost. LLMs trained on our generated data also outperform those trained on baseline methods, and even match SoTA proprietary LLMs on out-of-distribution (OOD) datasets with unseen tools.
Standard machine learning (ML) systems improve by computing numerical loss gradients across mini-batches of training samples, which are then used by an optimization algorithm to update model weights. Recently, TextGrad adapted this paradigm for prompt engineering using an LLM critic to provide rich, descriptive feedback in plain text — feedback called “textual gradients”. These textual gradients then guide the refinements of a given prompt into a new draft that can better resolve the target task.
ToolGrad adapts the concept of textual gradients from prompt optimization to synthetic dataset generation. Rather than optimizing a static text prompt, ToolGrad uses these gradients to iteratively construct complex, valid API workflows from large tool libraries.
ToolGrad features four core modules that sequentially propose, execute, select, and update.
Repeating this iterative process results in a data sample consisting of a user query, a verified API workflow, and the final AI response.
We first evaluate the cost and quality of the data generation. We use ToolBench as our API database, consisting of 16k+ real-world APIs, to generate our tool-use dataset. We compare the original query-first data generation approach on ToolBench, using depth-first search (DFS), with our answer-first approach, ToolGrad. The results demonstrate that ToolGrad can generate more complex tool-use data with higher pass rate, using lower generation cost.
We generated small-scale tool-use datasets called ToolGrad-500, using API databases from ToolBench. We then fine-tuned Gemma-3 models (1B, 4B and 12B) using ToolGrad-500, and we called these fine-tuned models ToolGrad-1B, ToolGrad-4B and ToolGrad-12B. We evaluated these models' tool-use performance on Berkeley Function Calling Leaderboard (BFCL), a tool-use benchmark with a different tool set from ToolBench. We compare our fine-tuned models against (1) base models without fine-tuning, (2) SoTA proprietary models (Gemini, GPT and Claude), and (3) SoTA tool-use specialized models (ToolACE, Hammer-2.1-7B).
The following summarizes our findings.
ToolGrad demonstrates that high-quality tool-use datasets can be generated more efficiently and reliably through an answer-first paradigm. By designing an agentic framework that iteratively chains APIs via textual gradients, ToolGrad addresses the longstanding cost and scalability bottlenecks in producing ground-truth data. Our design achieves almost 100% pass rate in data generation, enables relatively compact models to perform exceptionally well, and shows that student LLMs can even surpass their teachers.
Looking ahead, this research can be expanded to broader, real-world applications by scaling the framework to handle increasingly dynamic and vast API ecosystems. Future work will also explore extending this self-evolving capability to support continuous, on-the-fly learning for personalization over time. As agentic workflows become increasingly embedded in enterprise and everyday tasks, frameworks like ToolGrad lay the essential groundwork for training digital agents that are both highly capable and economically scalable to deploy.
This research was primarily conducted by Zhongyi Zhou during his Visiting Researcher tenure at Google. We extend our sincere gratitude to key contributors, Kohei Uehara, Haoyu Zhang, Jingtao Zhou, Lin Gu, Zheng Xu, Tatsuya Harada, for their support, and to Adarsh Kowdle and Shahram Izadi for their strategic guidance and thoughtful reviews.
文章标题:ToolGrad:利用文本“梯度”高效生成工具使用数据集
文章链接:https://news.qimuai.cn/?post=5034
本站文章均为原创,未经授权请勿用于任何商业用途