743 1 month ago

GLM 4.6V Flash 9B model with vision, tools, and hybrid thinking enabled. using custom template to align it to ollama and the recomended sampling settigns by default. using unsloth quants at q4K_M

vision tools thinking
e683b5dab156 · 1.8kB
[gMASK]<sop>
{{- if .Tools }}<|system|>
# Tools
You may call one or more functions to assist with the user query.
You are provided with function signatures within <tools></tools> XML tags:
<tools>
{{- range .Tools }}
{"function": {{ .Function }}}
{{- end }}
</tools>
For each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:
<tool_call>
{"name": <function-name>, "arguments": <args-json-object>}
</tool_call>
{{- end -}}
{{- $lastUserIdx := -1 }}
{{- range $i, $_ := .Messages }}
{{- if eq .Role "user" }}{{- $lastUserIdx = $i }}{{ end }}
{{- end -}}
{{- $prevWasTool := false -}}
{{- range $i, $_ := .Messages }}
{{- $last := eq (len (slice $.Messages $i)) 1 }}
{{- $curIsTool := eq .Role "tool" -}}
{{- $startToolBlock := and $curIsTool (not $prevWasTool) -}}
{{- if eq .Role "user" }}<|user|>
{{ .Content }}
{{- if and $.IsThinkSet (not $.Think) -}}
/nothink
{{- end -}}
{{- else if eq .Role "assistant" }}<|assistant|>
{{- if (and $.IsThinkSet (and .Thinking (or $last (gt $i $lastUserIdx)))) }}
<think>{{ .Thinking }}</think>
{{- else if $.IsThinkSet }}
<think></think>
{{- end }}
{{- if .Content }}
{{ .Content }}
{{- end -}}
{{ if .ToolCalls }}
<tool_call>
{{- range .ToolCalls }}
{"name": "{{ .Function.Name }}", "arguments": {{ .Function.Arguments }}}
{{- end }}
</tool_call>
{{- end }}
{{- else if $curIsTool -}}
{{ if not $prevWasTool }}<|observation|>
{{- end }}
<tool_response>
{{ .Content }}
</tool_response>
{{- $prevWasTool = true -}}
{{- else if eq .Role "system" -}}<|system|>
{{ .Content }}
{{- end }}
{{- if and (ne .Role "assistant") $last }}<|assistant|>
{{- if and $.IsThinkSet (not $.Think) }}
<think></think>
{{- end -}}
{{- end }}
{{- $prevWasTool = $curIsTool -}}
{{- end }}