Training large language models to reliably call external tools has long been a bottleneck, plagued by expensive and inefficient data generation pipelines. A new approach called ToolGrad, developed by researchers from Google, the University of Tokyo, RIKEN AIP, and Tohoku University, flips the script. Instead of asking an LLM to guess a user query and then hoping it finds a working API chain, ToolGrad builds a verified execution path first and writes the matching query second. The results are stark. On the ToolBench API database, the pass rate for generating valid training samples jumped from 63.8% using traditional depth-first search methods to 99.8% with ToolGrad.
The efficiency gains come from a four-module loop that narrows down API candidates, executes them in parallel, selects the best performing call, and updates the synthetic query to match. This process reduces the average number of tool-use steps per sample from 34.3 to 20.0 while increasing the complexity of the chains, which now average 3.4 ground-truth tool uses per sample. By eliminating the dead ends that waste compute in query-first approaches, the team created high-quality data with minimal friction. The method treats the selection feedback as a textual gradient, guiding the model toward robust workflows without exhaustive searching.
The real shocker is how little data you actually need. The team fine-tuned Gemma-3 models on a mere 500 samples generated by this process. On the Berkeley Function Calling Leaderboard, the 12B parameter version scored 83.1, effectively tying Gemini 2.5 Pro at 83.2 and beating Claude 4.5 Opus at 82.8. It even outperformed its own teacher model, Gemini 2.5 Flash-Lite, which generated the training data. This suggests that data quality trumps quantity by a wide margin in tool-use scenarios. With the code, dataset, and models available under Apache-2.0 on Hugging Face, the barrier to entry for building capable agent systems just dropped significantly.