Synthetic Data for Tool Use
A model's tool use ability can be improved by showing it tool use examples, typically written with domain experts who know which tasks need which tools.
Predicting the Training Path for a Ticket Search
Suppose you want a model to find the cheapest train ticket between two cities. A person would typically open a browser, type the route into a search bar, and click through the results one by one. That routine works well for a person. The question this article opens with is what a model should be trained to do instead.
What do you think happens?
Which approach should a model be trained to use: copying the click-by-click routine a person follows, or sending a single request to a search interface that returns the results directly?
Reveal answer
Send a single request to a search interface that returns the results directly.
The source explains that the efficiency of an action depends on who performs it. A human may prefer a visual web interface, while a model can often call an API directly. A record of human steps may therefore describe a route the model should never take.
The rest of this article follows the path from a human's routine to a usable training example. You will trace how a demonstration changes, how a tool use exchange is structured as a sequence of messages, and how a training dataset is judged by three criteria.
Why Watching Humans Is a Tempting Shortcut
A natural first idea for teaching a model to use tools is to watch people do the job and record what they do. If a person can search the web, book a room, or run a spreadsheet calculation, a faithful record of that person's steps seems like the best possible training material. The belief is not entirely wrong, but treating human behavior as the ideal target is the mistake to avoid.
The source makes a direct claim: human annotations are not automatically ideal for AI agents. The reason is that the efficiency of an action depends on who performs it. Human annotations are the written records that a person produces when showing how to finish a task. What is efficient for a human, such as clicking through a visual results page, may be wasteful or unnecessary for a model that can call an interface directly.
Tracing a Human Demonstration Into Agent Data
Adjusting a demonstration means changing its form while keeping the knowledge it carries. Take the ticket search again. The human routine contains a browser, a search bar, and a manual scan of results. The agent-ready version keeps the goal, which is finding the cheapest ticket on a route, but replaces the visual steps with a direct request to the search interface. The diagram below shows the substitution.
Notice what does not change. The goal stays the same, and the person's knowledge of which search matters is still the reason the example exists. Only the steps that were shaped by human convenience are rewritten for the model.
Where Expert Knowledge Still Helps
None of this means human expertise is useless. The source recommends using domain experts to write tool use data. In that setup, each prompt is a task that needs tools, and each response is the set of actions that completes it. Experts know what the tasks are and which tools they require. The caution is about the form of the demonstration, not the value of the knowledge behind it.
Experts have a second limitation. When asked to explain their work, they may leave steps out. They may forget a step, or judge it unimportant even when it changes the outcome. For this reason the source says it is often necessary to observe how humans perform these tasks in order to ensure accuracy. Observation catches what the explanation omits, so a good process combines expert knowledge of the task with direct watching of the work.
Single-Turn and Multi-Turn Data
Before collecting data, the source asks you to decide how the interaction should be structured. Your application may need single-turn data, multi-turn data, or both. The distinction depends on how many exchanges a task requires before it is finished. A single-turn example contains one prompt and one answer. A multi-turn example contains several exchanges that lead toward a finished result.
Ordinary conversation data assumes a simple rhythm. The user speaks, the AI replies with one message, and the turns alternate. Tool use breaks that rhythm. The AI may need to produce several messages within a single turn, and each message may go to a different destination.
| Feature | Single-turn data | Multi-turn tool use data |
|---|---|---|
| Typical contents | One prompt and one answer | A task prompt, tool calls, tool results, and a final reply |
| Rhythm | User speaks, AI replies, done | Several messages may come from one AI turn |
| Destinations | All output goes to the user | Messages may go to a tool, such as a code interpreter, or to the user |
| Suitable for | Interactions that need only one exchange | Tasks that need tools before they are finished |
How single-turn and multi-turn data differ in structure
The Multi-Message Chat Format
The source's example makes the problem concrete. An AI sends one message to a code interpreter, which runs the code, and another message to the user to explain what it is doing. Both messages come from the same AI turn, yet they travel to different places. A plain alternating transcript has no way to show that difference.
To handle this, the Llama 3 authors designed a multi-message chat format. It has two main parts. Message headers specify the source and destination of each message. Special termination tokens mark where the human and AI turns begin and end. Together these let training data express which message goes where. A training pipeline that stores each turn as one undivided message would lose the destination information the model needs to learn.
Read the diagram from top to bottom. The user produces only the first message. The AI produces two messages, but they are not sent to the same place. Only the message headers tell the model which message is code for the interpreter and which is an explanation for the user.
Tracing One Tool-Use Exchange
Averaging a list of prices through a code interpreter
A user asks a tool-using assistant for the average of a list of prices. Trace which party produces each message and where it goes.
- 1Step 1: user message
The user asks for the average of a list of prices. The message goes from the user to the AI.
- 2Step 2: AI message to the interpreter
Within the same AI turn, the assistant sends code to the code interpreter. The header marks this message as going to the interpreter, not to the user.
- 3Step 3: interpreter result
The interpreter runs the code and returns its output. The AI can now use that output.
- 4Step 4: AI message to the user
The AI sends a second message in the same turn, this time to the user, explaining the result. The header marks this message as going to the user.
One user request, one AI turn containing two messages with different destinations, and one tool result. A training example that records only the final explanation would hide the tool call the model needs to learn.
Three Criteria for Curating Data
Curation is the work of deciding what data a model learns from. The source says data curation follows three criteria: data quality, data coverage, and data quantity. Each application may need data with different characteristics, and different training phases may need different data mixes, but these three criteria apply throughout.
The source offers a cooking analogy. Think of model training as cooking, where the data fed into the model are the ingredients. Data quality is the quality of the ingredients, since a meal cannot be good if the ingredients are spoiled. Data coverage is the right mix of ingredients, such as not using too much or too little sugar. Data quantity is how many ingredients you should have.
The three criteria are separate questions, so a dataset can succeed on one and fail on another. A large collection of spoiled examples has quantity but not quality. A small set that contains only one kind of interaction may have quality but poor coverage. A good decision checks all three rather than relying on the one that is easiest to measure.
Removing Bad Behavior as Well as Adding Good
Curation is often pictured as adding material, but the source defines it in two directions. Data curation means creating new data to help a model learn new behaviors and removing existing data to help a model unlearn bad behaviors. Removal matters as much as creation.
The source gives a concrete case. Imagine a chatbot that users complain is arrogant. When asked to verify whether a statement is factually correct, it confirms the fact and then produces an unsolicited rewrite of the statement. Investigating the training data reveals several annotations that include unsolicited suggestions. The fix has two parts: request removal of those examples from the training data, and request new examples that demonstrate fact-checking without unsolicited rewriting.
Notice how the three criteria apply to this fix. The unsolicited-rewrite examples are a data quality problem, because they teach a bad behavior. The new fact-checking examples are about data coverage, because they supply the missing kind of interaction. Removing the bad examples and adding good ones are both curation decisions.
Mistakes When Building Tool Use Data
Common mistake Treating a human's recorded steps as the ideal training path
What it looks likeTraining an agent to click through search results one by one because that is how a person does it.
Why it failsThe efficiency of an action depends on who performs it. A model can often call an interface directly, so the human route may be one the model should never take.
Do this insteadAdjust the demonstration so it keeps the goal and drops the steps shaped by human convenience.
Common mistake Trusting an expert's explanation as a complete record of the work
What it looks likeAn expert describes a task but leaves out a step that changes the outcome.
Why it failsExperts may forget a step or judge it unimportant even when it matters.
Do this insteadObserve how humans perform the task so that the observation catches what the explanation omits.
Common mistake Storing a multi-message turn as one undivided message
What it looks likeSaving the AI's code and its explanation as one block of text with no destination information.
Why it failsThe two messages travel to different places, and the model needs that destination information to learn.
Do this insteadUse a multi-message chat format with message headers and termination tokens.
Common mistake Thinking curation only means adding data
What it looks likeAdding more fact-checking examples while leaving the examples that teach unsolicited rewriting in place.
Why it failsExisting bad examples keep teaching the bad behavior.
Do this insteadRemove the examples that teach bad behavior and add examples that teach the desired one.
Common mistake Judging a dataset on quantity alone, even when its examples are spoiled or cover only one kind of interaction
Applying the Criteria to a Dataset
A training set for a tool-using assistant contains 5,000 examples. Every example is a single-turn question paired with a single answer, and none includes a tool call. Using the three criteria of data quality, data coverage, and data quantity, identify which criterion this set is weak on, and describe one change that would help.
Hints
- Ask whether the set contains the kind of interaction that tool use requires, which is a question about coverage.
- Consider whether the examples can show a destination for each message, which connects to the structure of single-turn data.
- Remember that a large set can still fail on coverage even when its quantity is high.
Choose a task you know well and write out the steps a person takes to finish it. Mark which steps exist only because of human convenience, such as reading a visual page, and which steps are needed for the goal. Then rewrite the example as the steps an agent would take, and note which of the three criteria your rewrite serves best.
Hints
- Keep the goal the same and change only the steps shaped by how people work.
- If you cannot tell whether a step matters for the outcome, that is a sign you should observe a real person doing the task.
Key Takeaways
- 1A model's tool use ability can be improved by showing it tool use examples, typically written with domain experts who know which tasks need which tools.
- 2Human annotations are not automatically ideal for AI agents, so demonstrations should be checked and observed carefully and adjusted to fit how a model works.
- 3Tool use often needs multi-message chat data, where one AI turn sends messages to different destinations, supported by message headers and termination tokens.
- 4Data curation creates new data to teach new behaviors and removes existing data that teaches bad ones, and it is judged by data quality, data coverage, and data quantity.
At a glance
- A model's tool use ability can be improved by showing it tool use examples, typically written with domain experts who know which tasks need which tools.
- Human annotations are not automatically ideal for AI agents, so demonstrations should be checked, observed, and adjusted before they become training examples.
- Tool use often needs multi-message chat data, where one AI turn sends messages to different destinations, supported by message headers and termination tokens.
- Data curation both creates new data and removes existing data, and it is judged by data quality, data coverage, and data quantity.