TOOLVERIFIER : Generalization to New Tools via Self-Verification (2024)

Abstract: Teaching language models to use tools is an important milestone towards building general assistants, but remains an open problem. While there has been significant progress on learning to use specific tools via fine-tuning, language models still struggle with learning how to robustly use new tools from only a few demonstrations. In this work we introduce a self-verification method which distinguishes between close candidates by self-asking contrastive questions during (1) tool selection; and parameter generation. We construct synthetic, high-quality, self-generated data for this goal using Llama-2 70B, which we intend to release publicly. Extensive experiments on 4 tasks from the ToolBench benchmark, consisting of 17 unseen tools, demonstrate an average improvement of 22% over few-shot baselines, even in scenarios where the distinctions between candidate tools are finely nuanced.

## introduction incorporating external tools into large language models (llms) enhances their real-world applicability @xcite @xcite . many tools exist in the form of apis @xcite @xcite @xcite , machine learning models @xcite , and other functions @xcite . nevertheless, the evolving landscape of existing tools and apis, marked by frequent parameter updates and the daily introduction of new tools, poses a challenge for generalization. llms must quickly adapt to these changes and generalize to previously unseen tools without additional fine-tuning or extensive human input. several recent studies enable tool usage by finetuning llms on real @xcite @xcite or synthetic tools @xcite , equipping them to effectively utilize tools present in the training data with a high success rate. currently, the integration of unseen tools into llms relies on providing them with few-shot demonstrations that contain examples of user instructions and corresponding tool calls @xcite . however, these prompting-based approaches still struggle to accurately generate a complete tool call from a set of unseen tools. to address these challenges, we propose toolverifier, a self-verification method tailored for tool-use scenarios, capable of discerning between candidate tools and their respective parameters through verification questions. to achieve this, we decompose the tool call generation task into two distinct sub-tasks: (1) tool selection, given a user instruction, the most suitable tool is selected from a library of options, and (2) parameter generation, the appropriate parameters for the selected tool are then generated. crucially, we propose verification for each sub-task, to both improve sensitivity and to curb error propagation. figure 1 shows an overview of each sub-task. in the tool selection stage, our model must choose one tool among multiple options, given only the description of the tool. to facilitate learning how to choose the appropriate tool, we curate a high-quality, model-generated, synthetic training dataset containing tools, their descriptions, and user instructions. a: the latitude is 22.1 q: are you looking for the level of air pollution in a specific location or the weather conditions in that same location? a: the question was "how's the air quality this week at latitude 22.1 and longitude -128.7?". they are looking for air quality data which suggests they want to know air pollution levels. time to select from tools never seen during training. after the tool is selected, parameters are generated for the selected tool call, which is achieved through few-shot prompting with demonstrations corresponding to the chosen tool. self-verification is used at each step to reduce error propagation and enhance overall performance. as shown in figure 1 , for tool selection verification, we extract the top two predictions from the fine-tuned model. a verification question is then generated contrasting the two options via 0-shot prompting, enabling the model to focus on a finegrained decision where the answer aids in selecting one tool from the top two predictions. the model answers the question, and the context is updated by appending this answer to the user instruction, to guide tool selection. a similar approach is adopted for verifying the parameter generation. we evaluate our approach on 4 tasks from the publicly available toolbench benchmark which tests generalization to 17 unseen real-life apis. toolverifier demonstrates a noteworthy 22% improvement over few-shot prompting baselines. the proposed self-verification mechanism contributes an improvement of 8%, underscoring its pivotal role in boosting overall performance. ## toolverifier toolverifier chooses and calls a tool given a user instruction. it consists of the following steps: ## experiments in our experiments, we assess the effectiveness of our method using publicly available real-life tools. ## related work self-verification iterative improvement of llms typically involves prompting an llm to provide feedback on given generated facts or answers and subsequently refining their outputs @xcite @xcite which has also been shown to reduce hallucination @xcite . additionally, some studies involve the fine-tuning of custom llms to better accommodate feedback @xcite @xcite , aiming to enhance reasoning in chain-of-thought prompting for improved downstream performance. in this paper, we focus on tool usage, whereas previous works typically focus on generation. our approach contrasts the choice between selecting options, whereas previous work typically verifies single facts or answers in responses. enabling tool use in llms many approaches have emerged for enabling tool usage in llms, involving techniques such as few-shot prompting with tool-use demonstrations across diverse tool categories, including apis @xcite , machine learning models @xcite , and code interpreters @xcite . additionally, several approaches advocate for fine-tuning llms on custom-generated datasets tailored for tool usage @xcite @xcite @xcite @xcite . recent works introduce tool documentation @xcite and tool tokens @xcite to facilitate tool usage. despite the plethora of works focused on enabling tool usage in llms, to the best of our knowledge none has explored verification methods for this purpose. this paper aims to fill this gap by introducing multi-step contrastive verification. llms for data generation lms have been used for generating training data for various tasks including classification @xcite , semantic similarity @xcite , and instruction tuning @xcite @xcite . several works @xcite @xcite @xcite have employed llms to generate synthetic tools or tool use data. ## conclusion in this paper, we present a self-verification method for enhancing the performance of tool calls for llms. this involves decomposing the tool call generation task into tool selection and parameter generation, where we apply verification at each step. additionally, we open-source a synthetic dataset for improved reasoning and generalization to unseen tools. experimental results on four tasks from the toolbench benchmark demonstrate substantial improvements using our approach.