Tool Calling
Tool calling is a technique where a model can call a tool to perform a specific action. Learn more about tool calling in the OpenAI Function Calling guide.
With finetuning a chat model for Tool Calling
- You can improve performace and behavior of Tool Calling
- Style, Tone and Behavior of LLM responses
- Reduce tokens by omitting information from Tools schema. You can skip info in following ways:
- function and parameter descriptions: remove the description field from function and parameters
- parameters: remove the entire properties field from the parameters object
- function entirely: remove the entire function object from the functions array
Data Preparation
Tool Calling is supported only by Chat LLMs. You need to prepare data in the same format as you do for Chat LLMs. You can refer: Data Preparation for Chat guide.
Sample Data:
{
"messages": [
{
"role": "user",
"content": "What is the weather in San Francisco?"
},
{
"role": "assistant",
"tool_calls": [
{
"id": "call_id",
"type": "function",
"function": {
"name": "get_current_weather",
"arguments": "{\"location\": \"San Francisco, USA\", \"format\": \"celsius\"}"
}
}
]
},
{
"role": "tool",
"tool_call_id": "call_id",
"content": "21.0"
},
{
"role": "assistant",
"content": "It is 21 degrees celsius in San Francisco, CA"
}
],
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and country, eg. San Francisco, USA"
},
"format": { "type": "string", "enum": ["celsius", "fahrenheit"] }
},
"required": ["location", "format"]
}
}
}
]
}
Note
Above one is just a single sample. You need to prepare more data and create the dataset in JSONL format.