M ulti T ool- C o T : GPT -3 Can Use Multiple External Tools with Chain of Thought Prompting (2023)

Abstract: Large language models (LLMs) have achieved impressive performance on various reasoning tasks. To further improve the performance, we propose MultiTool-CoT, a novel framework that leverages chain-of-thought (CoT) prompting to incorporate multiple external tools, such as a calculator and a knowledge retriever, during the reasoning process. We apply MultiTool-CoT to the Task 2 dataset of NumGLUE, which requires both numerical reasoning and domain-specific knowledge. The experiments show that our method significantly outperforms strong baselines and achieves state-of-the-art performance.

## introduction reasoning refers to the logical process of inferring unknown facts from known facts. solving reasoning problems requires language understanding, real-world knowledge, arithmetic calculation, and symbolic processing. improving the reasoning capability of artificial intelligence has been a long-standing challenge and remains an active research topic to this day @xcite . recently, large language models (llms) have achieved amazing performance on various reasoning tasks @xcite @xcite . however, the amount of real-world knowledge learned by llms is still constrained by the size of model parameters and the training data. this problem could be more severe in the case of sparse domain-specific knowledge. furthermore, llms are based on the computation among continuous token representations, which cannot ensure accurate arithmetic calculations. to solve these problems, previous studies propose to complement the capabilities of llms with 1 our code is publicly available at https://github.com/ inabatatsuro/multitool-cot . an external tool, such as a web browser or a calculator @xcite @xcite . this is performed by invoking an external tool during reasoning with llms and injecting the results into the reasoning process. however, previous studies have focused on using a single external tool to solve a single problem with llms and have not addressed different problems together. this paper proposes multitool-cot, an interactive framework that allows llms to use multiple external tools during reasoning. figure 1 provides an overview. in multitool-cot, llms solve reasoning problems by generating reasoning processes including tool triggers to invoke external tools. we let llms learn to invoke multiple external tools at proper reasoning steps by chain-ofthought (cot) prompting based on few-shot learning @xcite . as a proof of concept, we apply multitool-cot to the task 2 dataset of numglue @xcite , which requires both numerical reasoning and domain-specific knowledge. experiments show that multitool-cot significantly outperforms strong baselines and achieves state-ofthe-art performance. ## related work large language models (llms) can perform various tasks by prompting @xcite . as for reasoning tasks, chain-of-thought (cot) prompting @xcite is known for its effectiveness, which elicits the answer with intermediate reasoning steps from llms. there is a growing body of work on using an external tool to improve reasoning with llms. @xcite use a calculator to process mathematical formulas that appear in reasoning processes by fine-tuning llms to generate mathematical formulas with a tool trigger to call the calculator. @xcite allow llms to use a a: first, use the chemical reaction predictor to determine the chemical equation for the reaction. reactants: ?ca(oh)2, 2co2 products: 2caco3, 2h2o << chemical reaction @xmath0, use the molar mass list to determine the molar mass of calcium hydroxide. ca(oh)2 << molar mass @xmath1, use the calculator to calculate the amount of 2 moles of calcium hydroxide. 2 x 74 = << @xmath2, 148 g of calcium hydroxide is required. ## method we propose multitool-cot, an interactive framework that allows llms to use multiple external 2 https://langchain.readthedocs.io/en/latest tools during reasoning. figure 1 illustrates an overview. multitool-cot leverages chain-of-thought (cot) prompting based on few-shot learning @xcite . our prompt consists of an instruction specifying the available external tools, few-shot examples demonstrating several question-answer pairs with reasoning processes, and a question to be solved. we manually annotate the reasoning processes shown as few-shot examples with tool triggers marked with corresponding input data, adhering to a specific format. in this study, we let the @xmath3. for example, if we use a calculator as an external tool, we annotate the reasoning processes with the tool @xmath4. when reasoning, gpt-3 follows the prompt and generates a reasoning process including tool triggers. if a tool trigger is generated, we stop text generation. we then extract the name of the external tool and the input for the tool from the reasoning process, execute the tool with the input, and append the result to the end of the reasoning process. after that, we restart text generation. if we cannot execute an external tool for some reason (e.g., invalid tool input is generated), we fall back on gpt-3 and let it generate the output of the tool. we observe that the final answer value is nearly always contained in the last sentence of the reasoning process. therefore, we apply an additional gpt-3 few-shot learning process for mapping the last sentence to the answer value by prompting several sentence-answer pairs. ## experiment as a proof of concept, we applied multitool-cot to solve a knowledge-based numerical reasoning task. ## conclusion we proposed multitool-cot, a framework that allows llms to use multiple external tools, such as a knowledge retriever and a calculator, during reasoning. we applied multitool-cot to a numerical reasoning task that requires knowledge of chemistry and confirmed its effectiveness. the proposed framework is general and can be applied to various tasks by changing and extending external tools. we plan to verify the effectiveness of the proposed method in other tasks in the future.