Introduction
To interact effectively with the real world, Large Language Models (LLMs) rely on external APIs, or "tools." However, as tool ecosystems grow to include thousands of options, selecting the right one becomes a significant challenge. Existing tool retrieval methods often operate under the flawed assumption that every user query requires a tool, ignoring common tasks like summarization or casual conversation. Furthermore, they frequently struggle with out-of-distribution (OOD) queries where user intent is phrased in unconventional ways.
MassTool addresses these gaps by introducing a multi-task framework that treats tool retrieval as a dual-step sequential decision-making process: first determining if a tool is necessary, and then identifying the most relevant tools through deep query comprehension.
Methods: Dual-Step Sequential Decision-Making
MassTool utilizes a two-tower architecture to manage the complexity of tool retrieval. This approach ensures that the model doesn't just find tools, but understands the context of the request.
1. Tool Usage Detection Tower
This component acts as a binary classifier. It predicts whether a query requires external tool invocation. The hidden states generated here, termed "detective knowledge," are passed to the retrieval tower to serve as a strong prior for subsequent steps.
2. Tool Retrieval Tower
The retrieval tower ranks the best tools using three primary innovations:
- QC-GCN (Query-Centric Graph Convolution Network): This module learns high-order patterns by constructing bipartite graphs between queries, tools, and scenes. It captures collaborative relationships—identifying tools that are frequently used together for specific types of intents.
- SUIM (Search-based User Intent Modeling): To handle OOD or ambiguous queries, SUIM searches a global pool of historical queries for semantic neighbors. It uses an attention mechanism to enrich the current query's representation based on similar past intents, effectively "translating" unconventional phrasing into recognizable tool requirements.
- AdaKT (Adaptive Knowledge Transfer): An element-wise gating mechanism that fuses the "detective knowledge" from the first tower with the search-enhanced representation from SUIM. This allows the model to dynamically filter information based on the likelihood that a tool is actually needed.
Datasets and Evaluation
To train and validate MassTool, the authors utilized standard benchmarks like ToolLens, ToolBenchG2, and ToolBenchG3. However, because these datasets lack queries that don't require tools, the authors introduced ToolDet. This new dataset contains over 31,000 high-quality, non-tool-invocation queries (e.g., chit-chat, creative writing) to properly train the Tool Usage Detection tower.
Key Results and Insights
MassTool consistently outperforms state-of-the-art baselines across various backbone models. Key findings include:
- Superior Accuracy: On the ToolLens dataset, MassTool achieved a Recall@3 of 0.9648, significantly higher than previous leaders like COLT (0.9215).
- Multi-task Synergy: Forcing the model to decide if a tool is needed improves its ability to decide which tool is needed. The detection task provides a clarifying signal that prevents the retriever from being misled by ambiguous language.
- Robustness to Complexity: MassTool maintains high performance even as queries become more complex and require multiple tools, whereas standard retrievers tend to degrade rapidly in these scenarios.
- OOD Handling: The combination of historical query search (SUIM) and graph-based learning allows MassTool to map creative or slang-heavy user intents (like "Is Tesla giving a Marvel movie vibe?") to the correct financial tools.
Conclusion and Future Work
MassTool represents a significant step forward in making LLMs more reliable tool-users by adding a layer of "common sense" regarding tool necessity. While currently limited to static tool pools, future iterations aim to support dynamic tool expansion and tighter integration with the LLM's internal reasoning steps to create a more interactive and adaptive retrieval loop.
Summary updated