liveBook · Manning

ToolFormer

As explained in Introduction to Generative AI, Second Edition

Toolformer is a language model trained to decide when and how to invoke external tools through generated API calls.

Toolformer is a language model trained to decide when and how to invoke external tools through generated application programming interface (API) calls. It emerged as models moved beyond producing text alone toward retrieving information, calculating answers, checking dates, and translating language. section 8.11

The approach starts with a pretrained open-source language model and a small set of examples for each tool. Generated API calls are executed, their results are formatted alongside the input, and the model learns associations between special tokens and useful tools. The design aims to preserve general-purpose behavior rather than restrict the model to predefined tasks. section 8.11

The demonstrated tool set includes:

  • Question answering for straightforward factual questions. section 8.11
  • Wikipedia search, calculation, calendar lookup, and machine translation. section 8.11
Table 8.1 Sample API tool calls and output formats [49]

API name

Example input

Example output

Question answering

“Where was the Knights of Columbus founded?”

“New Haven, Connecticut”

Wikipedia search

“Fishing Reel Types”

“Spin fishing > Spin fishing is distinguished between fly fishing and bait cast fishing by the type of rod and reel used. There are two types of reels used when spin fishing, the open-faced reel and the closed-faced reel.”

Calculator

“27 + 4 * 2”

“35”

Calendar

(none)

Today is Monday, June 30, 2025.

Machine translation

“sûreté nucléaire”

“nuclear safety”

Sample inputs and outputs make the model’s tool calls concrete, from arithmetic and factual lookup to date retrieval and translation. section 8.11

How Introduction to Generative AI, Second Edition covers it

How deep it goes
Explains dataset generation, API execution, and token associations, but stops short of implementation-level detail.
Examples
Uses question answering, Wikipedia search, a calculator, a calendar, and machine translation as concrete API examples.
What it assumes
Assumes a pretrained language model and introduces tool use without requiring vast human-collected demonstrations.
What you can do after
Evaluate and understand how language models can learn flexible tool invocation from limited annotated examples.
How it connects
Connects language models with AI agents, APIs, information retrieval, calculation, calendars, and machine translation.

Also explained in

Compare how 2 books explain ToolFormer →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Introduction to Generative AI, Second Edition. The section links point to the parts of the book it draws on.