Introduction
Supervised Fine-Tuning (SFT) is the standard approach for teaching Large Language Models (LLMs) to interact with external tools via APIs. Modern techniques often employ Chain-of-Thought (CoT) reasoning, where the model generates a "thought" process before producing a structured function call. However, this approach faces two significant challenges that hinder performance, particularly in smaller models.
First, Imbalanced Training Signals occur because reasoning chains are often much longer than the resulting function calls. Standard loss functions treat all tokens equally, causing the model to prioritize "looking smart" in its reasoning over the precision of the actual execution. Second, Imbalanced Data Hardness stems from the prevalence of simple, single-turn examples in open-source datasets, which fail to prepare models for complex, real-world multi-turn dialogues.
Methodology: The BalanceSFT Framework
To address these issues, we introduce BalanceSFT, a framework designed to recalibrate the learning process through two core innovations.
Self-adjusted Signal Balancing (SSB) Loss
Unlike standard cross-entropy loss, SSB loss decomposes the objective into two components: $L_{think}$ for reasoning and $L_{result}$ for the function call. A learnable hyperparameter, $\alpha$, dynamically adjusts the weight of these components during training. This prevents the concise function call from being overwhelmed by verbose reasoning tokens, ensuring the model maintains high execution accuracy.
Hard Data Re-sampling (HDR) Strategy
The HDR strategy implements a self-evolving feedback loop. The framework identifies "hard" cases where the model fails and utilizes an ensemble of "LLM Judges" (e.g., GPT-4o, Claude) to generate and verify high-quality solutions. The model is then iteratively retrained on this refined, increasingly difficult dataset.
Experimental Setup
The framework was trained on a combined dataset of approximately 90,000 samples, including the xlam-function-calling-60k (single-turn) and Open-Agentic-tool-use (multi-turn) datasets. Evaluation was conducted across several rigorous benchmarks: the Berkeley Function Calling Leaderboard (BFCL) v3, ACEBench, and APIBank.
Key Insights
- Optimal Loss Weighting: In typical CoT datasets, reasoning tokens outnumber result tokens by a 10:1 ratio. The learnable $\alpha$ allows the model to find an optimal balance, prioritizing execution without sacrificing reasoning depth.
- Preserving General Capabilities: Fine-tuning for specific tool-use tasks often leads to "catastrophic forgetting" of general reasoning or coding skills. BalanceSFT mitigates this, allowing models to retain base capabilities as measured by HumanEval and MBPP.
- Synergistic Effects: Ablation studies indicate that the combination of SSB and HDR is particularly effective for multi-turn tasks, where maintaining state and precision over long contexts is critical.
Results
BalanceSFT-7B, based on the Qwen2.5-Coder architecture, demonstrates that sophisticated data and loss engineering can enable smaller models to outperform much larger proprietary systems.
- Competitive Performance: On the BFCL multi-turn benchmark, BalanceSFT-7B achieved a score of 47.00, surpassing GPT-4o (42.50) and DeepSeek-R1 (44.50).
- Robustness in Complex Scenarios: The model showed significant improvements in handling "Missed Functions" and "Long Context" scenarios compared to larger models.
Conclusion and Future Work
While BalanceSFT significantly advances the state-of-the-art for 7B-parameter models, it remains somewhat dependent on the initial quality of reasoning chains. Furthermore, the reliance on proprietary LLMs as judges introduces computational costs and potential biases. Future research will focus on reducing dependence on external judges and extending this balanced learning approach to a broader range of agentic tasks.
Summary updated