All models

Toolformer

A small PaLM-style decoder from a community Toolformer implementation of self-taught API calling.

Language · 99 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (17 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
56M
Operations
99
Framework
PyTorch
Recurrent
No
Published
NeurIPS 2023
Cited by
1,070 (as of 19 October 2026)
Authors
Timo Schick, Jane Dwivedi-Yu, Roberto Dessì and others
License
MIT
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m12962
Graph hash
b6c2b1dedc7f6064deb7ef0d3606c6fa06f4ed1ec8006c6dc713ba21ab473971
Skeleton hash
b3ac1a04bf1315cb9e77e498bf67fd082ccf609822779c3eae457318f0649acb
Architecture hash
7c45087d8830946c7bb8b48187dd65619102a7790a489b840e1ad52b3497adb3
Diagram SHA-256
a4e6d11b5ce23d545e0511d28dd33dd5f3e80359a6f6fb333439599bf4e7f789
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

This model is the small PaLM-style language model that ships with toolformer-pytorch, a community PyTorch implementation of Toolformer, Meta AI's method for teaching language models to call external tools. The decoder is interchangeable: the README notes that any module returning logits of shape (batch, seq, num_tokens) can take its place. The paper itself fine-tunes a pretrained GPT-J model with 6.7B parameters, not this decoder.

Toolformer is 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. The training is self-supervised, requiring nothing more than a handful of demonstrations for each API. Given a few human-written examples, the language model annotates a large text corpus with candidate API calls, the calls are executed, and only those whose responses reduce the loss on the following tokens are kept for fine-tuning. The README describes this fitness score as the main novelty of the paper. The tools are a question answering system, a Wikipedia search engine, a calculator, a calendar, and a machine translation system. The paper reports improved zero-shot performance across a variety of downstream tasks, often competitive with much larger models, without sacrificing its core language modeling abilities.

The README's example builds the PaLM decoder with dim 512, depth 2, heads 8 and dim_head 64, the same sizes used for this model.

Key idea. Toolformer lets a language model teach itself to call external APIs by keeping only the API calls that reduce its loss on the following tokens.

  • toolformer
  • toolformer-pytorch
  • palm
  • tool use
  • api calls
  • language model
  • lucidrains
  • self-supervised tool learning
  • decoder

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{schick2023toolformerlanguagemodelsteach,
      title={Toolformer: Language Models Can Teach Themselves to Use Tools}, 
      author={Timo Schick and Jane Dwivedi-Yu and Roberto Dessì and Roberta Raileanu and Maria Lomeli and Luke Zettlemoyer and Nicola Cancedda and Thomas Scialom},
      year={2023},
      eprint={2302.04761},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2302.04761}, 
}