Abstract
Large Language Models (LLMs) have demonstrated remarkable capabilities in utilizing external tools via supervised fine-tuning (SFT). However, these models often struggle with a "generalization gap" when the tool ecosystem evolves—either through the introduction of new tools or the upgrading of existing ones. We present GenTool, a novel framework designed to enhance tool generalization. By simulating "Zero-to-One" and "Weak-to-Strong" scenarios and employing a two-stage ranking-then-selection fine-tuning strategy, GenTool enables open-source models to significantly outperform state-of-the-art closed models like GPT-4o in dynamic tool environments.
Introduction
The current paradigm for training LLMs in tool use relies on static datasets where specific queries are mapped to fixed APIs. This leads to overfitting, where models fail to adapt when a superior tool becomes available or when no suitable tool exists. This research identifies two primary dimensions of tool generalization:
- Zero-to-One Generalization: Transitioning from no available tool to utilizing a newly introduced relevant tool.
- Weak-to-Strong Generalization: Upgrading from a limited or inferior tool to a more comprehensive and superior alternative.
Methodology
GenTool addresses these challenges through a dual approach involving synthetic data simulation and a specialized training objective.
Synthetic Data Simulation
To train models to distinguish between varying levels of tool utility, the framework utilizes GPT-4o to generate "weak" counterparts of existing "strong" tools. For instance, if a strong tool provides detailed restaurant metadata, a weak version might only provide names. Queries are then generated that are partially addressable by the weak tool but fully satisfied only by the strong one, creating a curriculum for comparative reasoning.
Two-Stage Fine-Tuning
Unlike standard SFT which maps a query directly to an API call, GenTool introduces a two-stage process:
- Stage 1: Tool Ranking: The model is prompted to output a ranked list of available tools based on their relevance and utility. This includes a
generate_responseoption as a "null hypothesis" for cases where no tool is suitable. - Stage 2: Tool Invocation: The model generates the specific API call for the top-ranked tool.
Experimental Setup
The study utilizes the UltraTool dataset as a foundation, expanding it into a new synthetic corpus containing 834 synthetic tools and over 8,500 distinct queries. This results in 33,286 high-quality training samples. Evaluation is conducted across four scenarios: Seen/Unseen Queries and Seen/Unseen Tools.
Results and Discussion
GenTool was evaluated on several open-source models, including Llama-3.1, Llama-3.2, Mistral, and Phi-3.5.
Performance Gains
The Llama-3.1-8B model fine-tuned with GenTool achieved a tool selection accuracy of 90.15%, surpassing GPT-4o's 75.87%. The most significant improvements were observed in the "Seen Query, Unseen Tool" scenario, where GenTool provided an average accuracy boost of 18.4% over baseline methods.
The Importance of Ranking
Ablation studies confirmed that the ranking task is the primary driver of performance. Removing the ranking stage led to a performance degradation of up to 10.89%. Explicitly teaching the model to compare tool documentation allows for a deeper functional understanding rather than simple pattern matching.
Conclusion
GenTool demonstrates that structured comparative training is more effective for tool generalization than simply increasing data volume. By teaching models to rank tools and recognize when to provide a direct response, GenTool bridges the gap between static training and dynamic real-world tool use. Future work will explore extending this framework to multi-step agentic workflows and larger model scales.
Summary updated