chapter thirteen

13 Tool use and function calling

 

This chapter covers

  • How models are trained to use tools
  • Why tools mitigate structural weaknesses of language models
  • What to consider when giving your model tools

Language models using tools is a natural way to expand their capabilities, especially for high-precision tasks where external tools contain the information or for agents that need to interact with complex web systems. Tool use is a skill that language models need to be trained to have, and RLHF and all the other methods presented in this book can refine it. Consider a question from a user, such as

A language model without tools will have a hard time answering this question due to the knowledge cutoff of pretraining data, but the information is readily accessible with one search query. Consider another example:

This is a task that the model weights alone cannot even attempt—the use of tools enables language models to address a far broader range of tasks.

13.1 Tool-use overview

13.2 Interweaving tool calls in generation

13.3 Multistep tool reasoning

13.4 Model Context Protocol

13.5 Implementation details

Summary