You have access to the following functions. To call a function, please respond with JSON for a function call.Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.Do not use variables.
{
"type": "function",
"function": {
"name": "get_current_temperature",
"description": "Get the current temperature at a location.",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The location to get the temperature for, in the format "City, Country""
}
},
"required": [
"location"
]
},
"return": {
"type": "number",
"description": "The current temperature at the specified location in the specified units, as a float."
}
}
}
You are a bot that responds to weather queries.<|eot_id|>
<|start_header_id|>user<|end_header_id|>
Hey, what's the temperature in Paris right now?<|eot_id|>
除别的,llama 在 system prompt 中举行了调试,让模型能够只在激活了 tool call 的情况下去调用共外部工具。
llama 团队采用了以下方法来构造 Zero-shot tool use data (与 function calling 类似)
Single, nested, and parallel function calling: 个人明白是 llama 基于 the Stack 的开源数据举行筛选/修改,构造了 function call 信息,而后用 llama 3 基于 function call 信息,生成对应的用户 query。
Multi-turn function calling: 采用了 API-Bank: A Comprehensive Benchmark for Tool-Augmented LLMs 中的方法生成数据。Llama 采用了 5 个 agent 如下图:
第一个 agent 用于生成差异的范畴,如医疗保险,健身等。
第二个 agent,根据范畴数据,生成潜在的 API。值得注意的是,在这一阶段,为了确保模拟 API 的真实性,我们在署理输入中加入了来自公共 API 的示例。
第三个 agent 从模拟 API 中随机选择一个或多个 API。别的,它还选择了我们计划原则中概述的一种能力。然后使用这些信息创建一个匹配所选能力的 query 问题,这个 query 问题可以通过调用所选 API 来完成答复。
"content": "{"books": ["Sapiens: A Brief History of Humankind by Yuval Noah Harari", "A Brief History of Time by Stephen Hawking", "Dune by Frank Herbert", "The Martian by Andy Weir"]}"
},
{
"role": "assistant",
"content": "Based on your interests in history and science fiction, I would recommend the following books: "Sapiens: A Brief History of Humankind" by Yuval Noah Harari, "A Brief History of Time" by Stephen Hawking, "Dune" by Frank Herbert, and "The Martian" by Andy Weir."
{"books": ["Sapiens: A Brief History of Humankind by Yuval Noah Harari", "A Brief History of Time by Stephen Hawking", "Dune by Frank Herbert", "The Martian by Andy Weir"]}<|assistant|>
Based on your interests in history and science fiction, I would recommend the following books: "Sapiens: A Brief History of Humankind" by Yuval Noah Harari, "A Brief History of Time" by Stephen Hawking, "Dune" by Frank Herbert, and "The Martian" by Andy Weir.
"""
复制代码
效果如下
GLM function call 能力(Berkeley function-calling leaderboard):
其他
GLM 公开的信息还是挺少的,官方 github 及 官方技能报告 都没有找到一些 function call 训练细节。
Qwen 2
Qwen2 instruct 的 chat template 如下:
{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system
Qwen 初代的 function call 采用的 react 的思绪,当时模型有在额外的工具调用数据集上专门对 function call 举行训练。Qwen 2 Qwen2 Technical Report, blog 中虽然没有提到 function call 实现细节,但个人猜测也是经过了额外的 function call 能力训练。