Toolken+: Improving LLM Tool Usage with Reranking and a Reject Option

Konstantin Yakovlev, Sergey I. Nikolenko, Andrey Bout

Abstract

Large Language Models (LLMs) often struggle with precise tool selection and over-eager tool invocation. Toolken+ addresses these issues by augmenting the ToolkenGPT framework with a documentation-aware reranking mechanism and a "Reject" (REJ) option. This approach allows the model to reason over tool descriptions before execution and decline tool usage if standard text generation is more appropriate. Evaluated across math reasoning and tool selection benchmarks, Toolken+ demonstrates superior performance and reliability while maintaining parameter efficiency by keeping base model weights frozen.

Introduction

While LLMs are powerful, they often struggle with tasks requiring complex mathematics, real-time data, or specific API interactions. To address this, the ToolkenGPT framework was developed, representing tools as special tokens ("toolkens") in the model's vocabulary. However, ToolkenGPT suffers from two primary limitations: "documentation blindness," where the model cannot read a tool's description to understand its nuances, and "over-eagerness," where the model attempts to use tools even when unnecessary.

Toolken+ bridges the gap between efficient embedding-based retrieval and the deep reasoning capabilities of LLMs by introducing a two-stage selection process and a mechanism for self-correction.

The Toolken+ Framework

Toolken+ introduces a refined workflow for tool interaction that leverages the LLM's inherent linguistic reasoning:

  1. Top-k Retrieval: Similar to the original ToolkenGPT, the model first predicts the most likely toolkens based on the current context.
  2. Reranking with Documentation: Instead of immediate execution, Toolken+ takes the top-$k$ candidates and inserts their text descriptions into the prompt. The LLM then performs a "second look," reasoning over the documentation to select the most relevant tool.
  3. The Reject (REJ) Option: A special "Reject" tool is added to the candidate list. If the reranker determines that none of the proposed tools are suitable, or if a tool call was triggered erroneously, it selects "REJ," signaling the model to return to standard text generation.
The Toolken+ workflow showing the transition from token prediction to documentation-based reranking and the final invocation or rejection.

Experimental Evaluation

The researchers evaluated Toolken+ across three distinct benchmarks using Llama-2 and Vicuna backbones:

  • GSM8K: A multi-step math reasoning dataset modified to make arithmetic tool selection more challenging.
  • MetaTool: A dataset featuring over 200 different tools, specifically designed to test selection accuracy.
  • VirtualHome: A benchmark for embodied plan generation requiring sequences of household actions.

Key Results and Insights

Toolken+ consistently outperformed both the original ToolkenGPT and standard few-shot prompting. As shown in the results table below, Toolken+ achieved the highest scores across nearly all metrics and model sizes.

Performance comparison of Toolken+ against ToolkenGPT and 4-shot prompting across multiple LLM backbones and benchmarks.

Reasoning over Retrieval

The core advantage of Toolken+ is its ability to leverage the model's reasoning capabilities. While embeddings are efficient for finding relevant tools, they lack the precision for exact selection. By presenting documentation to the LLM, Toolken+ allows for more nuanced decision-making. The authors found that $k=3$ is often the optimal number of tools to rerank; providing too many options can clutter the prompt and degrade performance.

The Power of "No"

The "Reject" option acts as a vital safety valve. In math reasoning tasks (GSM8K), this option significantly improved Exact Match scores by allowing the model to avoid unnecessary tool calls that would otherwise derail the reasoning process. For instance, on Vicuna-7B, accuracy improved from 16.9% to 18.8% primarily through this mechanism.

Conclusion and Future Work

Toolken+ provides a parameter-efficient method to enhance LLM tool usage. By combining the speed of embedding-based retrieval with the precision of documentation-aware reranking, it reduces false positives and improves task success. Future work will focus on addressing the retrieval bottleneck—ensuring the correct tool is within the initial top-$k$—and scaling the system to handle massive toolsets containing thousands of APIs.

Summary updated

BibTeX
@inproceedings{yakovlev2024toolken,
  author = {Konstantin Yakovlev and Sergey I. Nikolenko and Andrey Bout},
  title = {{Toolken+: Improving LLM Tool Usage with Reranking and a Reject Option}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2024},
  doi = {10.18653/v1/2024.findings-emnlp.345},
}
Figure