Abstract
This paper introduces a framework to transform Large Language Models (LLMs) from passive tool-users requiring explicit prompting into autonomous agents that internalize tool knowledge. By decomposing the decision-making process into a sequence of "Whether, Which, and How," and employing a dynamic rehearsal strategy for continual learning, we develop a model that achieves a 91.2% success rate, significantly outperforming GPT-4 in autonomous tool selection and execution.
Introduction
While LLMs are powerful, they are often characterized as "stochastic parrots" limited by training data cutoffs and a lack of specialized capabilities, such as high-precision mathematics or real-time information retrieval. To address these gaps, researchers have integrated external tools (APIs) into LLM workflows. However, current methods suffer from a "passive" utilization problem: they typically require tool descriptions and instructions to be included within the prompt. This consumes valuable context window space, increases the risk of model distraction, and fails to scale as the number of available tools grows into the thousands.
This work proposes a framework for autonomous tool utilization, enabling a model to independently decide if a tool is needed, select the correct one, and execute the call without being "hand-held" by the prompt.
Methodology
The proposed framework consists of three main pillars designed for efficiency and scalability.
1. Unified Decision Decomposition
Instead of treating tool use as a single generation task, we decompose the process into a sequential chain of conditional probabilities:
- Whether ($W_e$): Determining if the query requires an external tool.
- Which ($W_i$): Selecting the most appropriate API from the internalized library.
- How ($H$): Formulating the correct parameters for the API call.
- Response ($Y$): Generating the final answer based on the tool's output.
2. "Instruct, Execute, and Reformat" Pipeline
To build a high-quality dataset, we employ a self-instruction approach. We generate queries, have an LLM devise an API call, execute it in a real-world environment, and retain only successful instances. These are then reformatted into a structured "thought process" template that the model learns to emulate.
3. Dynamic Rehearsal for Scalability
To manage an expanding set of APIs, we use a continual learning strategy. When training on new tools, the model uses a sampling ratio that gradually re-introduces data from previously learned tools, preventing catastrophic forgetting and allowing the model to master new tools with as few as 10 annotated samples.
Experimental Setup
We curated a dataset covering 26 diverse APIs categorized by domain:
- Solvable (NLP): Translation and summarization.
- Verifiable (Reasoning/Facts): Wolfram Alpha, Bing Search, and Map APIs.
- Unsolvable (Real-time/Multimodal): Stock/Weather data, ArXiv, and image generation tools (e.g., Stable Diffusion).
We generated 1,000 query-response pairs per API using GPT-4 to create a robust benchmark for autonomous tool use.
Results
Our fine-tuned Alpaca-7B model was compared against several baselines, including GPT-3.5 and GPT-4.
Superior Accuracy
The model achieved a 91.2% success rate across all tasks, significantly outperforming GPT-4 (80.4%) and GPT-3.5 (62.8%) in the same autonomous setting. This demonstrates that internalizing tool knowledge is more effective than relying on general-purpose in-context learning for complex tool-use tasks.
Key Insights
- Internalization is Key: Eliminating long system prompts makes the model more efficient and less prone to distraction by irrelevant context.
- Self-Awareness: The model learns to recognize when its internal weights are insufficient (e.g., for real-time data) and automatically triggers tool-seeking behavior.
- Generalization: The model showed strong generalization to unseen domains, maintaining high success rates even when applied to new contexts like "Education."
Conclusion
This framework enables LLMs to become autonomous agents by internalizing tool knowledge and following a structured decision-making process. While currently focused on single-step tool calls, future work will explore multi-step reasoning and tool chaining to handle more complex real-world tasks.
Summary updated