Toolformer: Language Models Can Teach Themselves to Use Tools

Timo Schick,Jane Dwivedi-Yu,Roberto Dessì,Roberta Raileanu,Maria Lomeli,Luke Zettlemoyer,Nicola Cancedda,Thomas Scialom
DOI: https://doi.org/10.48550/arXiv.2302.04761
2023-02-10
Abstract:Language models (LMs) exhibit remarkable abilities to solve new tasks from just a few examples or textual instructions, especially at scale. They also, paradoxically, struggle with basic functionality, such as arithmetic or factual lookup, where much simpler and smaller models excel. In this paper, we show that LMs can teach themselves to use external tools via simple APIs and achieve the best of both worlds. We introduce Toolformer, a model trained to decide which APIs to call, when to call them, what arguments to pass, and how to best incorporate the results into future token prediction. This is done in a self-supervised way, requiring nothing more than a handful of demonstrations for each API. We incorporate a range of tools, including a calculator, a Q\&A system, two different search engines, a translation system, and a calendar. Toolformer achieves substantially improved zero-shot performance across a variety of downstream tasks, often competitive with much larger models, without sacrificing its core language modeling abilities.
Computation and Language
What problem does this paper attempt to address?
This paper attempts to address the problem of large - language models (LMs) performing poorly when handling certain basic - function tasks. Although these models can solve new tasks from a small number of examples or text instructions after being trained on large - scale data, they have difficulties in performing basic functions such as arithmetic operations or fact - finding, while these tasks are very easy for simpler and smaller - scale models. The paper proposes a new method that enables language models to learn to use external tools through simple API calls, thus combining the powerful capabilities of large - language models and the advantages of small models on specific tasks. This method, named Toolformer, can self - supervise to learn how to call APIs, when to call them, and how to integrate the results into future predictions without a large amount of human annotation, thereby significantly improving zero - sample performance in a variety of downstream tasks.