Abstract
Large language models (LLMs) achieve remarkable advancements by leveraging tools to interact with environments, a critical step toward generalized AI. However, the standard supervised fine-tuning (SFT) approach, which relies on large-scale datasets, often overlooks task-specific characteristics in tool use, leading to performance bottlenecks. To address this issue, we analyze three existing LLMs and uncover key insights: training data can inadvertently impede tool-use behavior, token importance is distributed unevenly, and errors in tool calls fall into a small set of categories. Building on these findings, we propose TL-Training, a task-feature-based framework that mitigates the effects of suboptimal training data, dynamically adjusts token weights to prioritize key tokens during SFT, and incorporates a robust reward mechanism tailored to error categories, optimized through proximal policy optimization. We validate TL-Training by training CodeLLaMA-2-7B and evaluating it on four open-source test sets. Our results demonstrate that the LLM trained by our method matches or surpasses both open- and closed-source LLMs in tool-use performance using only 1,217 training data points.
Introduction
While LLMs excel at natural language processing, "tool use" requires a level of precision that standard Supervised Fine-Tuning (SFT) often fails to provide. Traditional methods typically employ "brute force" training on over 100,000 examples. However, analysis of these massive datasets—often generated by other AI models—reveals a significant flaw: approximately 17% of the training data contains errors. Training on these flawed trajectories essentially teaches models how to fail.
Furthermore, in tool-use tasks, token importance is not uniform. A mistake in a tool name is catastrophic, whereas minor variations in descriptive arguments may be inconsequential. Current SFT paradigms treat every token with equal weight, leading to inefficiencies and selection errors.
Methodology: The TL-Training Framework
To overcome these limitations, we introduce TL-Training, a framework designed to leverage the unique features of tool-use tasks. It consists of three primary components:
- Mitigating Adverse Effects (MAE): This module identifies erroneous tool calls within the training set by monitoring tool feedback. When an error is detected (e.g., a missing positional argument), the system blocks that specific step from updating the model's weights, preventing the reinforcement of incorrect behaviors.
- Prioritizing Key Tokens (PKT): We observed that models often struggle with the initial tokens of a tool name. PKT dynamically increases the training weight for these critical tokens, forcing the model to focus on structural accuracy and tool selection.
- Introducing a Reward Mechanism (IRM): Using Proximal Policy Optimization (PPO), we fine-tune the model with a structured reward system. Instead of binary feedback, we categorize errors (e.g., tool hallucinations, wrong tool calls, parameter hallucinations) and assign specific penalties, guiding the model toward perfect execution.
Experimental Results
We evaluated our approach by training TL-CodeLLaMA-2 (7B) on a "Self-Construct" dataset of just 1,217 multi-turn trajectories. Despite the small data scale, the model demonstrated exceptional performance across multiple benchmarks.
- Benchmarking: On the ToolAlpaca benchmark, TL-CodeLLaMA-2 achieved a Content Filling (CF) score of 57.89%, significantly outperforming GPT-4-turbo (42.11%) and NexusRaven-13B (37.72%).
- Robustness: In noisy environments (RoTBench), our model outperformed RoTLLaMA—a model specifically optimized for noise—despite TL-Training having no specific noise-augmentation during training.
- Multi-Turn Performance: On the complex ToolEyes test, the model achieved a total error rate of only 5.64%, rivaling GPT-4o (4.76%).
Discussion and Conclusion
The success of TL-Training highlights a shift from quantity to quality in LLM training. By focusing on task-specific features—such as error mitigation and token prioritization—we can achieve state-of-the-art tool-use capabilities with less than 1% of the data typically required. This approach not only improves efficiency but also enhances the model's robustness in real-world, noisy environments without sacrificing general reasoning capabilities. Future work will explore scaling this framework to tens of thousands of tools and incorporating human preference models to further refine tool-use intent.
Summary updated