周中一,研究科学家;杜若飞,互动感知与图形负责人,谷歌 XR
ToolGrad 是一个数据生成框架,它通过先生成工具使用答案而不是用户查询来颠覆传统范式。我们展示了这种设计能够使大语言模型(LLM)实现更好的工具使用性能。
在 ACL 2026:https://aclanthology.org/2026.findings-acl.950/ 上发表的“ToolGrad: Efficient Tool-use Dataset Generation with Textual ‘Gradients:https://arxiv.org/abs/2508.04086’”中,我们介绍了一种替代的解决方案范式。ToolGrad:https://github.com/zhongyi-zhou/toolgrad 首先生成一个真实的工具使用链,然后再标注其对应的用户提示。直观上,明确的工具使用解决方案提供了比提示更清晰的信息,使得从工具使用到使用查询的标注更容易,仅需一个 LLM 步骤。我们的结果表明,我们的先答方法可以以更低的成本生成更复杂(长周期)的工具使用数据。基于我们生成的数据训练的 LLM 在性能上也超过了基线方法训练的模型,甚至在具有未见工具的分布外(OOD)数据集上可以匹配最先进的专有 LLM。
尽管现有技术通过搜索用户查询的解决方案生成工具使用数据集,但工具通过率低,ToolGrad 则是在生成提示之前生成成功的工具使用链,从而获得高通过率。
标准机器学习(ML)系统通过对训练样本的小批量计算数值损失梯度来改进,然后优化算法使用这些梯度更新模型权重。近期,TextGrad:https://arxiv.org/abs/2406.07496 将这一范式适用于提示工程,利用 LLM 评论者提供丰富的、描述性的纯文本反馈——这种反馈被称为“文本梯度”。这些文本梯度随后指导给定提示的优化,使其生成的新草稿能够更好地完成目标任务。
ToolGrad 将文本梯度的概念从提示优化适配到合成数据集生成。ToolGrad 并非优化静态文本提示,而是使用这些梯度从大型工具库中迭代构建复杂且有效的 API 工作流。
将 ToolGrad 的优化组件与传统机器学习和 TextGrad 进行对比。
ToolGrad 具有四个核心模块,按顺序执行提议、执行、选择和更新。
重复这一迭代过程会生成一个数据样本,包含用户查询、经过验证的 API 工作流以及最终的 AI 响应。
ToolGrad 在生成提示之前生成成功的工具使用链,从而产生高通过率。
我们首先评估数据生成的成本和质量。我们使用 ToolBench:https://arxiv.org/abs/2307.16789 作为我们的 API 数据库,该数据库包含 16k+ 个现实世界的 API,以生成我们的工具使用数据集。我们将 ToolBench 上的原始“先查询”数据生成方法(使用深度优先搜索,DFS)与我们的“先答案”方法 ToolGrad 进行比较。结果表明,ToolGrad 可以以更低的生成成本生成更复杂的工具使用数据且通过率更高。
“先查询”方法(基线)与“先答案”方法(我们的方法)之间的生成效率比较。
我们生成了名为 ToolGrad-500 的小规模工具使用数据集,使用来自 ToolBench 的 API 数据库。然后,我们使用 ToolGrad-500 对 Gemma-3:https://arxiv.org/abs/2503.19786 模型(1B、4B 和 12B)进行微调,并将这些微调模型命名为 ToolGrad-1B、ToolGrad-4B 和 ToolGrad-12B。我们在 Berkeley Function Calling Leaderboard (BFCL):https://gorilla.cs.berkeley.edu/leaderboard.html 上评估了这些模型的工具使用性能,该基准测试的数据工具集与 ToolBench 不同。我们将微调后的模型与 (1) 未微调的基础模型、(2) SoTA 专有模型(Gemini、GPT 和 Claude)、(3) SoTA 工具使用专用模型(ToolACE:https://arxiv.org/abs/2409.00920、Hammer-2.1-7B:https://arxiv.org/abs/2410.04587v2)进行比较。
以下总结了我们的调查结果。
BFCL 在 Gemma-3、ToolGrad 模型、Gemini 2.5 系列、GPT-5、Claude-4.5、ToolACE 和 Hammer-2.1-7B 模型上的评估结果。
ToolGrad 展示了通过“先得答案”范式可以更高效、更可靠地生成高质量的工具使用数据集。通过设计一个能够通过文本梯度迭代地链式调用 API 的智能框架,ToolGrad 解决了长期存在的生成真实数据的成本和可扩展性瓶颈。我们的设计在数据生成中实现了几乎 100% 的通过率,使相对紧凑的模型也能表现出色,并显示出学生 LLM 甚至可以超越其教师。
展望未来,这项研究可以通过扩展框架以处理日益动态和庞大的 API 生态系统,应用到更广泛的现实世界场景。未来的工作还将探索将这种自我进化能力扩展到支持持续的、即时的个性化学习。随着智能工作流程越来越多地嵌入企业和日常任务中,像 ToolGrad 这样的框架为训练既高效又具有经济可扩展性的数字代理奠定了基础。
这项研究主要由周中义在谷歌担任访问研究员期间完成。我们向主要贡献者上原耕平(Kohei Uehara)、张浩宇、周景涛、顾林、许铮、原田达也(Tatsuya Harada)致以诚挚的感谢,并感谢 Adarsh Kowdle 和 Shahram Izadi 在战略指导和细致评审方面的支持。
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.
In “ToolGrad: Efficient Tool-use Dataset Generation with Textual ‘Gradients:https://arxiv.org/abs/2508.04086’”, presented at ACL 2026:https://aclanthology.org/2026.findings-acl.950/, we introduce an alternative solution paradigm. ToolGrad:https://github.com/zhongyi-zhou/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.
While prior art generates tool-use datasets by searching solutions of user queries with low pass rate, ToolGrad generates successful tool-use chains before generating prompts, yielding high pass rate.
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:https://arxiv.org/abs/2406.07496 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.
Comparing the optimization components of ToolGrad to traditional ML and TextGrad.
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.
ToolGrad generates successful tool-use chains before generating prompts, yielding a high pass rate.
We first evaluate the cost and quality of the data generation. We use ToolBench:https://arxiv.org/abs/2307.16789 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.
Generation efficiency comparison between the query-first approach (baseline) and the answer-first approach (ours).
We generated small-scale tool-use datasets called ToolGrad-500, using API databases from ToolBench. We then fine-tuned Gemma-3:https://arxiv.org/abs/2503.19786 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):https://gorilla.cs.berkeley.edu/leaderboard.html, 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:https://arxiv.org/abs/2409.00920, Hammer-2.1-7B:https://arxiv.org/abs/2410.04587v2).
The following summarizes our findings.
BFCL evaluation results on Gemma-3, ToolGrad models, Gemini 2.5 series, GPT-5, Claude-4.5, ToolACE and Hammer-2.1-7B models.
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.