Research

AI-generated text

ToolGrad: answer‑first method speeds creation of tool‑use datasets with textual “gradients”

ToolGrad is an answer-first framework that generates verified API call chains and then produces corresponding user prompts, using LLM-produced textual feedback to iteratively build workflows.

ToolGrad: answer‑first method speeds creation of tool‑use datasets with textual “gradients”

Large language models (LLMs) are increasingly used to automate real‑world tasks such as running a Google search, reading local files, or executing generated Python scripts. To support agentic workflows, models must learn to use tools (APIs) correctly and efficiently. Training LLMs for tool use requires datasets that pair user queries with corresponding tool‑use action chains. In earlier work like InstructPipe, evaluation data were annotated by hand, but manual annotation does not scale for the large datasets needed for advanced fine‑tuning.

Prior automated approaches, such as ToolBench and ToolACE, follow a query‑first pipeline: they sample APIs, generate hypothetical user instructions, and then run a depth‑first search (DFS) agent to find a working tool‑use solution through trial and error. This query‑first paradigm is inherently inefficient because it must distill useful trajectories from extensive agent exploration, which is costly in computation and time.

ToolGrad: an answer‑first alternative

In the ACL 2026 paper “ToolGrad: Efficient Tool‑use Dataset Generation with Textual ‘Gradients’”, the authors propose an alternative answer‑first paradigm. ToolGrad first generates an explicit, ground‑truth tool‑use chain and only afterwards produces the corresponding user prompt. The rationale is that a concrete solution chain contains clearer information than a speculative prompt, so annotating from tool usage to user query is simpler and can be done in a single LLM step.

According to the authors, this answer‑first approach generates more complex, long‑horizon tool‑use examples at lower cost. Models fine‑tuned on ToolGrad data outperform models trained with baseline methods, and in out‑of‑distribution (OOD) evaluations can match or approach state‑of‑the‑art proprietary LLMs even when the tools are unseen during generation.

Textual “gradients” and iterative chain construction

ToolGrad adapts the idea of textual gradients from prompt engineering. Traditional machine learning uses numerical loss gradients to update weights; TextGrad repurposes this idea by having an LLM provide rich, descriptive feedback in plain text — so‑called textual gradients — to iteratively refine prompts. ToolGrad repurposes textual gradients for synthetic dataset generation: instead of optimizing a static prompt, it uses textual feedback to iteratively build valid API workflows from large tool libraries.

The ToolGrad framework

ToolGrad is composed of four sequential modules that propose, execute, select, and update:

  • API Proposer: narrows a sampled API set to a few promising candidates to extend the current workflow each iteration.
  • API Executors: test the selected APIs in parallel and generate detailed execution reports.
  • API Selector: reviews reports and selects the single best‑performing API call — treated as a textual gradient that provides directional feedback — and appends it to the workflow.
  • LLM Updater: revises the synthetic user query and AI response to reflect the new API set.

Repeating these iterations produces training samples consisting of a user query, a verified API workflow, and the final AI response.

Experiments and findings

Data generation efficiency The authors used the ToolBench API database (over 16,000 real‑world APIs) to generate tool‑use datasets and compared the traditional query‑first DFS generation with ToolGrad’s answer‑first process. Results indicate that ToolGrad can produce more complex tool‑use examples with a higher pass rate and lower generation cost than the query‑first baseline.

Berkeley Function Calling Leaderboard (BFCL) The team created a small ToolGrad dataset, ToolGrad‑500, from ToolBench APIs and fine‑tuned Gemma‑3 models (1B, 4B, 12B parameters) on that data, naming the resulting models ToolGrad‑1B, ToolGrad‑4B, and ToolGrad‑12B. They evaluated these models on the Berkeley Function Calling Leaderboard (BFCL), which uses a different tool set than ToolBench.

Comparisons included (1) base models without fine‑tuning, (2) state‑of‑the‑art proprietary models (Gemini, GPT and Claude), and (3) tool‑use specialized models (ToolACE, Hammer‑2.1‑7B). Key findings were:

  • Consistent improvements: fine‑tuning Gemma‑3 models on ToolGrad‑500 improved tool‑use performance across all tested parameter sizes.
  • Competitive with proprietary LLMs: ToolGrad‑12B scored 83.1 on BFCL, comparable to gemini‑2.5‑pro (83.2), claude‑4.5 Opus (82.8), and ahead of gpt‑5 (74.4) at the time of publication.
  • Self‑evolving behavior: ToolGrad‑500 was generated using gemini‑2.5‑flash‑lite; interestingly, Gemma‑3‑12B fine‑tuned on that data outperformed its original teacher model.
  • Lead over other open models: ToolGrad‑12B outperformed other open‑source, tool‑use specialized models including ToolACE, even though ToolACE had been fine‑tuned on a more advanced API database.

Conclusions and future work

ToolGrad shows that answer‑first dataset generation guided by textual gradients can produce high‑quality tool‑use examples more efficiently and reliably than prior query‑first pipelines. The framework attains nearly 100% pass rate in data generation, lets relatively compact models achieve strong tool‑use performance, and demonstrates cases where student models exceed their teachers.

Future directions include scaling ToolGrad to larger, more dynamic API ecosystems and extending the self‑evolving capability for continuous, on‑the‑fly learning and personalization. As agentic workflows become more common in enterprise and everyday tasks, frameworks like ToolGrad aim to provide cost‑effective foundations for training capable digital agents.

Acknowledgements

The research was primarily conducted by Zhongyi Zhou during his Visiting Researcher tenure at Google. The paper thanks Kohei Uehara, Haoyu Zhang, Jingtao Zhou, Lin Gu, Zheng Xu, and Tatsuya Harada for contributions, and Adarsh Kowdle and Shahram Izadi for strategic guidance and reviews.