Need Better Tool-Use Data? ToolGrad Hits 99.8% Pass Rate

Training an LLM to reliably call external tools is hampered by the high cost and low success rate of creating datasets that pair user queries with correct tool‑use chains. Traditional pipelines such as ToolBench and ToolACE start with a synthetic query, then run a depth‑first search agent to find a satisfying API path. Because the search often hits dead ends, many explored trajectories are wasted, samples are discarded, and the overall pass rate stays modest—only about 64 % of generated examples are usable, with short chains and excessive LLM calls.

ToolGrad flips this workflow. It first builds a verified tool chain by actually executing APIs, then attaches a matching user query in a single LLM call. This guarantees that every produced sample contains a working sequence, eliminating wasted exploration. The process repeats four lightweight modules in a loop: an API Proposer narrows candidates, parallel API Executors run them and generate reports, an API Selector picks the best call and supplies a textual gradient, and an LLM Updater rewrites the query and response to reflect the updated chain. Ten iterations over ~50 sampled APIs yield one high‑quality example consisting of a query, a validated workflow, and the final response.

Evaluated on the ToolBench API repository (16 k+ real‑world APIs), ToolGrad raises the pass rate from 63.8 % to 99.8 %, increases average tool uses per sample from 2.1 to 3.4, cuts tool‑use steps from 34.3 to 20.0, and keeps LLM invocations per sample roughly constant (64.5 → 63.9). The only failures (0.2 %) occur when no API succeeds across all iterations, resulting in an empty sample that is simply discarded.

The method is ready for deployment: the code is released under Apache‑2.0, the ToolGrad‑500 dataset and fine‑tuned Gemma‑3 models (1 B, 4 B, 12 B) are hosted on Hugging Face, and a PyPI package provides easy integration. Teams can now generate reliable tool‑calling data at scale without the prohibitive compute waste of query‑first approaches.

#AI #Product #MachineLearning #LLM #DataGeneration #OpenSource