外贸wordpress收款插件,发不了软文的网站怎么做关键词优化,seo优化是做什么的,公司官网搭建默认 Ollama 中的 Qwen2 模型不支持 Function Calling#xff0c;使用默认 Qwen2#xff0c;Ollama 会报错。本文将根据官方模板对 ChatTemplate 进行改进#xff0c;使得Qwen2 支持 Tools#xff0c;支持函数调用。 Ollama 会检查对话模板中是否存在 Tools#xff0c;如…默认 Ollama 中的 Qwen2 模型不支持 Function Calling使用默认 Qwen2Ollama 会报错。本文将根据官方模板对 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 }}# ToolsYou are provided with function signatures within tools/tools XML tags. You may call one or more functions to assist with the user query. Dont make assumptions about what values to plug into functions. Here are the available tools:
tools{{- range .Tools }}{{ .Function }}{{- end }}/toolsFor each function call, return a JSON object with function name and arguments within tool_call/tool_call XML tags as follows:
tool_call
{name: function-name, arguments: args-json-object}
/tool_call{{- end }}|im_end|{{- end }}
{{- range .Messages }}
{{- if eq .Role user }}
|im_start|{{ .Role }}
{{ .Content }}|im_end|
{{- else if eq .Role assistant }}
|im_start|{{ .Role }}
{{- if .Content }}
{{ .Content }}
{{- end }}
{{- if .ToolCalls }}
tool_call
{{ range .ToolCalls }}{name: {{ .Function.Name }}, arguments: {{ .Function.Arguments }}}
{{ end }}/tool_call
{{- end }}|im_end|
{{- else if eq .Role tool }}
|im_start|user
tool_response
{{ .Content }}
/tool_response|im_end|
{{- end }}
{{- end }}
|im_start|assistant
{{ else }}{{ if .System }}|im_start|system
{{ .System }}|im_end|
{{ end }}{{ if .Prompt }}|im_start|user
{{ .Prompt }}|im_end|
{{ end }}|im_start|assistant
{{ end }}构建模型
ollama create qwen2tools --file ./qwen_tools 测试模型 总结
现在的模型都是支持 Tools在 Ollama 中使用我们需要对 Template 配置配置好 Tools 后就可以通过 Ollama 直接进行函数调用了。