Introduction
Training Large Language Models (LLMs) to interact with external APIs—a process known as tool learning—is increasingly accomplished through Reinforcement Learning (RL). However, this approach faces significant hurdles. First, sample inefficiency often leads to models being overwhelmed by "easy" samples they have already mastered, resulting in diminishing returns and wasted compute. Second, tool use presents complex reward landscapes. Unlike binary pass/fail tasks like math, tool use involves multiple facets (e.g., correct tool name vs. correct parameter value). Existing dynamic sampling techniques, designed for binary rewards where variance is a simple function of the mean, fail to capture the nuanced selection strategies required for tool learning.
To address these challenges, we introduce ToolSample, a framework utilizing Dynamic Sampling with Curriculum Learning (DSCL) to enhance the efficiency and performance of RL-based tool learning.
The DSCL Framework
The DSCL framework consists of two synergistic components designed to optimize the training signal:
- Reward-Based Dynamic Sampling (RDS): RDS moves beyond binary success metrics by tracking three dimensions: mean reward across rollouts, sample-level variance (intra-prompt consistency), and epoch-level variance (inter-epoch stability). By categorizing data into Easy, Hard, and Intermediate, RDS discards samples that are either fully mastered or too unstable, focusing the model on the most informative data.
- Task-Based Dynamic Curriculum Learning (TDCL): Recognizing that tool use involves a hierarchy of sub-tasks—Format (JSON structure), Tool Name/Key (selection), and Parameter Value (extraction)—TDCL implements a three-stage curriculum. It dynamically shifts reward weights from basic formatting to tool selection, and finally to the most difficult task: precise parameter value completion.
Crucially, the system includes a warmup phase. Dynamic sampling only activates once the model achieves stable proficiency in basic formatting, preventing the premature rejection of valuable foundational data.
Key Insights: Beyond Binary Rewards
A core observation of this work is the decoupling of mean and variance in tool learning rewards. In binary reward systems, variance is strictly tied to the mean. However, in tool learning, the actual mean-variance distribution is much broader. This allows variance to serve as an independent signal for "informativeness"—a sample with high variance indicates model uncertainty, representing a high-potential learning opportunity.
Furthermore, the authors identified asynchronous convergence among sub-tasks. Models often master tool names long before they achieve precision in parameter values. TDCL addresses this by "shifting the goalposts" as the model matures. Finally, the research highlights the danger of early filtering: applying dynamic sampling from the start can hurt performance because initial failures in basic formatting make almost all samples appear "hard" or "unstable," leading the sampler to discard essential foundational data.
Experimental Results
The DSCL method was evaluated using a curated mix of datasets, including ToolACE, Hammer, and xLAM for training, and BFCL v3 and API-Bank for evaluation. DSCL consistently outperformed strong baselines like ToolRL and DAPO:
- BFCL v3: Achieved an overall accuracy of 60.25%, a significant improvement over the ToolRL baseline of 56.96%.
- Multi-Turn Excellence: The most dramatic gains were observed in multi-turn dialogues on BFCL, where accuracy rose from 13.25% to 18.50%.
- API-Bank: Reached an overall accuracy of 64.99%, outperforming the foundation model (Qwen2.5-7B-Instruct) by nearly 7 percentage points.
- Efficiency: Ablation studies confirmed that while RDS and TDCL are effective individually, their combination (DSCL) provides the most robust performance, particularly in mastering complex parameter values.
Conclusion and Future Work
ToolSample demonstrates that dynamic sampling and curriculum learning can significantly improve the efficiency of RL for tool-using LLMs. By focusing on informative samples and prioritizing difficult sub-tasks, the DSCL framework achieves state-of-the-art results on major benchmarks.
Future work will explore the framework's sensitivity to hyperparameters, its scalability to larger models (e.g., 70B+), and its impact on extremely long-horizon "agentic" reasoning tasks requiring extensive sequences of tool calls.
Summary updated