GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
NeurIPS 2023

Toolformer: Language Models Can Teach Themselves to Use Tools

A model writes candidate API calls into ordinary text, keeps those whose results make the next words easier to predict, and trains on them. A 6.7B model learned when to call a calculator.

Breakdown by FDE Interviews · 13 min read · Updated

About the original · 2023
AUTHORS
Schick, Dwivedi-Yu, Dessì, Raileanu, Lomeli, Zettlemoyer, Cancedda, Scialom
FROM
Meta AI Research, Universitat Pompeu Fabra
PUBLISHED
Feb 2023 · NeurIPS 2023
CITED BY
6,197Semantic Scholar · Oct 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 18% of this breakdown.

01

The paper in one minute

Language models are oddly bad at things that simple programs do perfectly: dividing two numbers, looking up a fact that changed last year, knowing today's date. The obvious fix is to let the model call tools. The question in early 2023 was how to teach a model when to call which tool, with what input, and how to use the answer, without a large hand-labeled dataset of tool use.

Timo Schick, Thomas Scialom and colleagues at Meta AI Research answer with a self-supervised trick. Write a short prompt with a few examples per tool, then let the model annotate a large slice of web text with candidate calls, such as [Calculator(400/1400) → 0.29] placed just before "29%". Execute each candidate call. Then keep a call only if putting the call and its result in front of the text makes the model better at predicting the next few words than having no call, or the call without its result. Fine-tune the model on the text with the surviving calls. Because the text is ordinary pretraining-style data, the model keeps its general abilities.

The tools were a question-answering model, a Wikipedia search engine, a calculator, a calendar and a translation model. The base model, GPT-J with 6.7 billion parameters, became much stronger zero-shot on fact completion, arithmetic word problems and date questions, often beating GPT-3 with 175 billion parameters. It still lagged on open question answering and could neither chain tools nor search interactively.

THE IDEA, VISUALLY
A MODEL LABELS ITS OWN TOOL CALLS 1 sample where might a call help? 2 execute run the candidate calls 3 filter keep only calls that cut the loss on the next tokens 4 fine-tune on text with the kept calls Out of 1400 participants, 400 (or [Calculator(400/1400) → 0.29] 29%) passed the test. keep the call if L(no call, or call without result) − L(call + result) ≥ τ Tools: question answering, Wikipedia search, calculator, calendar, translation. Base model GPT-J 6.7B; at most one call per output at inference. A 6.7B MODEL WITH TOOLS VS GPT-3 175B zero-shot scores, Tables 3 to 5 LAMA SQuAD (facts) 17.8 33.8 26.8 ASDiv (arithmetic) 7.5 40.4 14.0 SVAMP (arithmetic) 5.2 29.4 10.0 WebQuestions (QA) 18.5 26.3 29.0 GPT-J 6.7B Toolformer 6.7B GPT-3 175B The calculator was used on 97.9% of math questions.
Toolformer's training data comes from the model itself: calls that do not lower its loss on the next tokens are thrown away. With a calculator and a search engine, a 6.7B model beat GPT-3 on arithmetic and fact lookup.
Research notes: the problem, approach and results
40.4 vs 14.0

ASDiv math accuracy, Toolformer 6.7B versus GPT-3 175B, zero-shot

97.9%

of math examples where Toolformer chose to call the calculator

~775M

parameters below which models gained nothing from the tools

THE PROBLEM

Large language models handle open-ended text well but fail at exact arithmetic, current facts and dates, which a calculator or search engine solves trivially. Teaching tool use usually needed lots of human-annotated examples or task-specific prompts.

THE IDEA

Show the model a few examples per tool, let it insert candidate calls into a large text corpus, execute them, and keep only calls whose results reduce the model's loss on the words that follow. Fine-tune on the result.

THE RESULT

GPT-J 6.7B trained this way more than doubled its zero-shot scores on math word problems, beat GPT-3 175B on fact completion and arithmetic, and kept its language-modeling quality. It did not catch up on open question answering, and could not chain tools.

02

Why it matters to an FDE

Modern models arrive already trained to call functions, so few teams will reproduce Toolformer. The ideas in it still decide whether a customer's tool-using system works.

Tools fix what models are structurally bad at. Exact arithmetic, current facts and dates are the cases where tools gave the largest gains. If a customer workflow depends on any of them, route it to a tool rather than hoping the model computes or remembers.

"Did the tool help?" is measurable. Toolformer's filter asks whether the tool's result made the following text more predictable. In evaluation you can ask the same question: does the call change the outcome, or is it ceremony that adds latency?

Placement matters. A call helps most right before its result is needed. In agents, fetch information close to where it is used, rather than front-loading everything into the context.

Small models may not benefit. Below roughly 775M parameters, the models did no better with tools than without. When a customer insists on a very small model, test whether tool calls help at all.

Single calls are not enough for real work. Toolformer makes at most one call per output and cannot chain tools. Most business tasks need several calls and decisions between them, which is where agent loops and code actions come in.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 99 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The filter, the tools, the decoding tweak, each result, scaling, and the misreadings to avoid

    Free account
  2. 04How it works

    Sampling positions and calls, the filtering loss, merging tools, and the evaluation setup

    Premium
  3. 05The numbers that matter

    Every benchmark family, the controls, the scaling study and the multilingual exception

    Premium
  4. 06Try it yourself

    Implement Toolformer's loss-reduction filter and watch it sort useful calls from useless ones

    Premium
  5. 07Where it breaks

    The limits the authors list, and what has changed since

    Premium
  6. 08Using it on a deployment

    Applying the paper's ideas to tool design and evaluation in a customer system

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →