Toolformer: Language Models Can Teach Themselves to Use Tools
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.
The following analysis is generated by AI and may contain errors. It is separate from the authors’ abstract and is not peer review.
Research summary
Toolformer introduces a self-supervised framework that enables language models to autonomously learn when and how to utilize external APIs by filtering candidate tool calls based on perplexity reduction, establishing a scalable and highly influential paradigm for tool-augmented generation that significantly enhances zero-shot capabilities across diverse tasks without compromising core language modeling performance.
Methodology
The proposed framework is elegantly minimal yet conceptually profound. By leveraging in-context learning to generate candidate API calls, executing them externally, and applying a self-supervised perplexity-reduction filter ($L_i^- - L_i^+ > \tau_f$), the authors bypass the traditional bottleneck of human-annotated tool-use datasets. The linearization of tool interactions into standard text tokens allows seamless integration with autoregressive language modeling objectives. The filtering criterion is theoretically grounded: it directly optimizes for the LM's predictive utility rather than superficial syntactic correctness, ensuring only genuinely informative tool calls survive. The approach is dataset-agnostic, model-agnostic, and requires only a handful of demonstration prompts per tool, making it highly scalable and broadly applicable.
Results & evaluation
The experimental design is rigorous and comprehensive. Evaluation spans factual recall (LAMA), mathematical reasoning (ASDiv, SVAMP, MAWPS), open-domain QA (WebQ, NQ, TriviaQA), multilingual comprehension (MLQA), and temporal awareness (TempLAMA, Dateset). The strict zero-shot setup effectively isolates the model's autonomous tool-selection capability. Results demonstrate substantial, consistent gains over the base GPT-J model, frequently surpassing significantly larger baselines (OPT-66B, GPT-3) on targeted tasks. The scaling analysis revealing a ~775M parameter threshold for emergent tool-use capability is a valuable empirical contribution. Crucially, perplexity evaluations on held-out corpora confirm that tool integration does not degrade core generative capabilities, validating the dataset-agnostic fine-tuning strategy.
Reproducibility
The paper provides clear algorithmic pseudocode, explicit prompt templates, filtering thresholds, and detailed training configurations (batch size, learning rate, ZeRO-3 optimization, hardware setup). The reliance on publicly available base models (GPT-J, Atlas, NLLB) and standard open datasets strongly facilitates replication. Minor reproducibility friction points include the exact construction of the Wikipedia BM25 index, heuristic data filtering for specific tools, and API latency/cost management during large-scale annotation. Nevertheless, the methodology is sufficiently transparent to be reproduced by well-resourced academic or industry labs.
Limitations
The authors transparently identify several constraints: (1) inability to chain multiple tool calls sequentially, as each is sampled independently; (2) lack of interactive or iterative tool refinement (e.g., multi-turn search or query adjustment); (3) high sensitivity to prompt phrasing when deciding whether to invoke a tool; (4) sample inefficiency for certain tools (e.g., calculator calls are rare in natural text); and (5) no consideration of computational or latency costs during tool selection. The single-call-per-example inference restriction also limits applicability to complex, multi-step reasoning tasks. These limitations are well-documented and provide clear pathways for subsequent research.
Broader impact
Toolformer establishes a foundational paradigm for autonomous, self-supervised tool integration in LLMs, effectively bridging the gap between static parametric knowledge and dynamic, external resources. By demonstrating that models can teach themselves to use APIs without massive human curation, it democratizes tool-augmented generation and shifts the field away from task-specific prompting toward general-purpose, capability-augmented architectures. The approach has directly influenced subsequent frameworks (e.g., ReAct, Gorilla, HuggingGPT) and accelerated industry adoption of tool-calling LLMs. Potential risks include increased inference latency, dependency on external API reliability, and the propagation of tool-generated errors, which require careful engineering and evaluation in production deployments. Toolformer introduces a self-supervised framework that enables language models to autonomously learn when and how to utilize external APIs by filtering candidate tool calls based on perplexity reduction, establishing a scalable and highly influential paradigm for tool-augmented generation that significantly enhances zero-shot capabilities across diverse tasks without compromising core language modeling performance.
Curator note
Schick et al.; Meta; self-supervised tool-use learning
Author of this paper? Send a correction.