Ollama Qwen2 支持 Function Calling

默认 Ollama 中的 Qwen2 模型不支持 Function Calling,使用默认 Qwen2,Ollama 会报错。本文将根据官方模板对 ChatTemplate 进行改进,使得Qwen2 支持 Tools,支持函数调用。
在这里插入图片描述
Ollama 会检查对话模板中是否存在 Tools,如果不存在就会报错,下面的代码是 Ollama 解析模板的代码。
在这里插入图片描述
Ollama 3.1 是支持 Tools 的,可以看到模板中定义了 Tools。
在这里插入图片描述
修改 Qwen2 配置并创建新的模型,首先我们定义一个 Ollama 模型文件,创建文件 qwen_tools。

FROM qwen2:7b

# set the temperature to 0.7 [higher is more creative, lower is more coherent]
PARAMETER temperature 0.7
PARAMETER top_p 0.8
PARAMETER repeat_penalty 1.05
TEMPLATE """{
  
  { if .Messages }}
{
  
  {- if or .System .Tools }}<|im_start|>system
{
  
  { .System }}
{
  
  {- if .Tools }}

# Tools

You are provided with function signatures within &
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值