agent-readings / Tool Use and Interoperability
Self-supervised API calls inside the token stream
The one sentence
Toolformer is the bridge from hand-written tool-use prompts to tool-use data pipelines: APIs become textual actions, execution results become training signals, and tool invocation becomes part of the language model's decoding loop.
Before this paper
Large language models could follow instructions and solve many text tasks, but still struggled with arithmetic, factual lookup, translation, and temporal awareness.
Earlier tool-use approaches often depended on human annotations or task-specific prompting where the user already knew which tool should be used.
A general-purpose tool-using LM needs to decide when to call a tool, which tool to call, what arguments to pass, and how to use the result without losing ordinary...
The paper asks whether a frozen pretrained LM can bootstrap its own tool-use training data from a few demonstrations per API plus a self-supervised usefulness filter.
Core idea
Prompt the base LM with a few examples for each API, sample candidate call positions and calls over plain text, execute the calls, filter out calls whose results do not reduce future-token loss, interleave surviving calls into the text, and finetune the LM on...
Write a handful of demonstrations for each tool.
Use the pretrained LM to annotate plain language-modeling text with candidate API calls.
Execute each candidate API call to obtain a text response.
Keep only calls where the response lowers weighted next-token loss by the filtering threshold.
Action grammar
API call: a textual tuple containing an API name and input argument.
API result: a single text sequence returned by the external tool.
Candidate sampler: the base LM prompted to propose where and how to call an API.
Usefulness filter: a weighted loss comparison over future tokens with and without the API result.
Executable shape
Evidence
The paper describes using a handful of demonstrations to prompt an LM to propose API calls over a language-modeling corpus, executing those calls, filtering them by usefulness,...
A candidate API call is kept only if adding both the call and its result lowers weighted cross-entropy loss over future tokens by at least the threshold, compared with no call or...
During decoding, the system proceeds normally until the model produces the API response marker; decoding is interrupted, the API is called, the response and closing marker are...
On LAMA subsets, Toolformer scores 33.8 on SQuAD, 11.5 on Google-RE, and 53.5 on T-REx, compared with GPT-J + CC at 19.2, 5.6, and 33.2 and GPT-3 175B at 26.8, 7.0, and 39.8.
Claim map
Toolformer learns tool use self-supervised from a few demonstrations per API by generating, executing, filtering, and finetuning on API calls inserted into...
The central filtering criterion is whether providing the API result lowers weighted loss on future tokens compared with no call or a call without the result.
Toolformer represents calls and responses as text in the model stream and uses inference-time decoding hooks to execute tools when the model emits the API...
A 6.7B-parameter GPT-J Toolformer improves zero-shot factual lookup and math results over same-size baselines and often beats much larger OPT 66B and GPT-3...
Agent infrastructure
Tool use begins with a protocol: every tool must have a textual call format, a textual result format, and examples showing intended use.
The loss filter is an early form of execution-derived supervision: a runtime can log which calls actually reduce uncertainty or improve downstream...
Tool invocation needs an execution boundary in decoding. The model can propose calls, but infrastructure must pause, authorize, execute, insert...
The paper's single-call setup is not enough for agent workflows; multi-step plans require trajectories, dependency tracking, and loop prevention.
Caveats
Toolformer is finetuned for a fixed set of tools, not a dynamic tool-discovery protocol.
The method needs executable tools during data generation and inference.
The paper's main downstream setup permits at most one API call per input.
Loss reduction is a local proxy for usefulness and does not encode user authorization, safety, or side-effect policy.
Run it
No PoC yet - contributions welcome. A useful local PoC would annotate a small text corpus with calculator calls, filter calls by next-token loss using a local model, and compare generated answers with and without tool execution.