@ZixuanLi_:更新了 GLM-5.3 和 GLM-5.3-Flash 的聊天模板。工具结果重排现在会提前退出,而不再逐个扫描……
摘要
GLM-5.3 和 GLM-5.3-Flash 的 HuggingFace 聊天模板已更新,通过提前退出优化了工具结果重排,建议开发者拉取最新模板用于部署。
查看缓存全文
缓存时间: 2026/09/06 12:46
已更新 GLM-5.3 和 GLM-5.3-Flash 的聊天模板。工具结果重排序现在会提前退出,而非扫描每个块。拉取最新模板并更新你的部署:https://t.co/7rT1chdsex — # chat_template.jinja · zai-org/GLM-5.3 at main 来源:https://huggingface.co/zai-org/GLM-5.3/blob/main/chat_template.jinja ZHANGYUXUAN-zR 的头像聊天模板:在工具结果重排序检查中提前跳出 aca966e (https://huggingface.co/zai-org/GLM-5.3/commit/aca966e4e02791568aa6a4ced368624b3d897f42) 2 天前已验证 [gMASK]{%-seteffective_reasoning_effort = reasoning_effort if reasoning_effort is defined and reasoning_effortin[‘low’, ‘high’] else ‘max’ -%}{%-ifeffective_reasoning_effort is not none -%}<|system|>Reasoning Effort:{{ effective_reasoning_effort | capitalize }}{%-endif-%}{%-setclear_thinking = clear_thinking if clear_thinking is defined else false -%}{%-iftools -%}{%-macrotool_to_json(tool) -%}{%-setns_tool = namespace(first=true) -%}{{ ‘{’ -}}{%-fork, vintool.items() -%}{%-ifk != ‘defer_loading’ and k != ‘strict’ -%}{%-ifnot ns_tool.first -%}{{- ’, ’ -}}{%-endif-%}{%-setns_tool.first = false -%}“{{ k }}”:{{ v | tojson(ensure_ascii=False) }}{%-endif-%}{%-endfor-%}{{- ‘}’ -}}{%-endmacro-%}{%-macrotool_references_to_response(refs) -%}{{- ‘\n’ -}}{%-fortrinrefs -%}{%-fortoolintools -%}{%-if’function’intool -%}{%-settool = tool[‘function’] -%}{%-endif-%}{%-iftool.name == tr.name -%}{{- tool_to_json(tool) + ‘\n’ -}}{%-endif-%}{%-endfor-%}{%-endfor-%}{{- ‘’ -}}{%-endmacro-%}<|system|># ToolsYou may call one or more functions to assist with the user query.You are provided with function signatures withinXML tags:{%fortoolintools %}{%-if’function’intool -%}{%-settool = tool[‘function’] -%}{%-endif-%}{%iftool.defer_loading is not defined or not tool.defer_loading %}{{ tool_to_json(tool) }}{%endif%}{%endfor%}For each function call, output the function name and arguments within the following XML format:{function-name}{arg-key-1}{arg-value-1}{arg-key-2}{arg-value-2}...{%-endif-%}{%-macrovisible_text(content) -%}{%-ifcontent is string -%}{{- content }}{%-elifcontent is iterable and content is not mapping -%}{%-foritemincontent -%}{%-ifitem is mapping and item.type == ‘text’ -%}{{- item.text }}{%-elifitem is string -%}{{- item }}{%-elifitem is mapping and item.typein[‘image’, ‘image_url’, ‘video’, ‘video_url’, ‘audio’, ‘audio_url’, ‘input_audio’] -%}{%-setmedia_type = item.type | replace(‘_url’, ‘’) | replace(‘input_’, ‘’) -%}{{- “You are unable to process this “ ~ media_type ~ “ because you don’t have multi-modal input ability. Try different methods.” }}{%-endif-%}{%-endfor-%}{%-elifcontent is not none -%}{{- content }}{%-endif-%}{%-endmacro-%}{%-macrotool_response(text) -%}{{- ‘’ + text + ‘’ -}}{%-endmacro-%}{%-macrorender_tool_response(m) -%}{%-ifm.content is string -%}{{- tool_response(m.content) -}}{%-elifm.content and m.content is not mapping and m.content.0.type == “tool_reference” -%}{{- tool_references_to_response(m.content) -}}{%-elifis_list_of_outputs(m) -%}{%-fortrinm.content -%}{%-iftr.output is iterable and tr.output is not string and tr.output is not mapping and tr.output and tr.output.0.type == “tool_reference” -%}{{- tool_references_to_response(tr.output) -}}{%-else-%}{{- tool_response(visible_text(tr.output)) -}}{%-endif-%}{%-endfor-%}{%-else-%}{{- tool_response(visible_text(m.content)) -}}{%-endif-%}{%-endmacro-%}{%-macroid_of(obj) -%}{%-ifobj.tool_call_id -%}{{- obj.tool_call_id -}}{%-elifobj.id -%}{{- obj.id -}}{%-endif-%}{%-endmacro-%}{%-macrois_list_of_outputs(m) -%}{%-ifm.content and m.content.0.output is defined -%}1{%-endif-%}{%-endmacro-%}{%-macrohas_dup_tool_result_id(lo, hi, target) -%}{%-setns_cnt = namespace(n=0) -%}{%-forkinrange(lo, hi + 1) -%}{%-setm = messages[k] -%}{%-ifis_list_of_outputs(m) -%}{%-forentryinm.content -%}{%-ifid_of(entry) == target -%}{%-setns_cnt.n = ns_cnt.n + 1 -%}{%-endif-%}{%-endfor-%}{%-elifid_of(m) == target -%}{%-setns_cnt.n = ns_cnt.n + 1 -%}{%-endif-%}{%-ifns_cnt.n > 1 -%}{%-break-%}{%-endif-%}{%-endfor-%}{%-ifns_cnt.n > 1 -%}1{%-endif-%}{%-endmacro-%}{%-macrotc_id_exists(tcs, target) -%}{%-setns_f = namespace(found=false) -%}{%-fortcintcs -%}{%-ifid_of(tc) == target -%}{%-setns_f.found = true -%}{%-break-%}{%-endif-%}{%-endfor-%}{%-ifns_f.found -%}1{%-endif-%}{%-endmacro-%}{%-setns = namespace(last_user_index=-1) -%}{%-forminmessages %}{%-ifm.role == ‘user’ %}{%-setns.last_user_index = loop.index0 -%}{%-endif%}{%-endfor%}{%-forminmessages -%}{%-ifm.role == ‘user’ -%}<|user|>{{ visible_text(m.content) }}{%-elifm.role == ‘assistant’ -%}<|assistant|>{%-setcontent = visible_text(m.content) %}{%-ifm.reasoning_content is string %}{%-setreasoning_content = m.reasoning_content %}{%-elif’‘incontent %}{%-setreasoning_content = content.split(’‘)[0].split(’‘)[-1] %}{%-setcontent = content.split(’’)[-1] %}{%-endif%}{%-if(not clear_thinking or loop.index0 > ns.last_user_index) and reasoning_content is defined -%}{{ ‘’ + reasoning_content + ‘’}}{%-else-%}{{ ‘’ }}{%-endif-%}{%-ifcontent.strip() -%}{{ content.strip() }}{%-endif-%}{%ifm.tool_calls %}{%fortcinm.tool_calls %}{%-iftc.function %}{%-settc = tc.function %}{%-endif%}{{- ‘’ + tc.name -}}{%set_args = tc.arguments %}{%fork, vin_args.items() %}{{ k }}{{ v | tojson(ensure_ascii=False) if v is not string else v }}{%endfor%}{%endfor%}{%endif%}{%-elifm.role == ‘tool’ -%}{%-ifloop.first or (messages[loop.index0 - 1].role != “tool”) %}{{- ‘<|observation|>’ -}}{%-setblock_start = loop.index0 -%}{%-setns_blk = namespace(end=block_start) -%}{%-forjinrange(block_start, messages|length) -%}{%-ifmessages[j].role == ‘tool’ -%}{%-setns_blk.end = j -%}{%-else-%}{%-break-%}{%-endif-%}{%-endfor-%}{%-setns_a = namespace(tool_calls=none) -%}{%-ifblock_start > 0 and messages[block_start - 1].role == ‘assistant’ and messages[block_start - 1].tool_calls -%}{%-setns_a.tool_calls = messages[block_start - 1].tool_calls -%}{%-endif-%}{%-setns_chk = namespace(can_sort=true) -%}{%-ifnot ns_a.tool_calls -%}{%-setns_chk.can_sort = false -%}{%-else-%}{%-forkinrange(block_start, ns_blk.end + 1) -%}{%-ifnot ns_chk.can_sort -%}{%-break-%}{%-endif-%}{%-setm = messages[k] -%}{%-ifis_list_of_outputs(m) -%}{%-forentryinm.content -%}{%-ifnot ns_chk.can_sort -%}{%-break-%}{%-endif-%}{%-seteid = id_of(entry) -%}{%-ifnot eid -%}{%-setns_chk.can_sort = false -%}{%-elifhas_dup_tool_result_id(block_start, ns_blk.end, eid) -%}{%-setns_chk.can_sort = false -%}{%-elifnot tc_id_exists(ns_a.tool_calls, eid) -%}{%-setns_chk.can_sort = false -%}{%-endif-%}{%-endfor-%}{%-else-%}{%-settk_id = id_of(m) -%}{%-ifnot tk_id -%}{%-setns_chk.can_sort = false -%}{%-elifhas_dup_tool_result_id(block_start, ns_blk.end, tk_id) -%}{%-setns_chk.can_sort = false -%}{%-elifnot tc_id_exists(ns_a.tool_calls, tk_id) -%}{%-setns_chk.can_sort = false -%}{%-endif-%}{%-endif-%}{%-endfor-%}{%-foriinrange(ns_a.tool_calls | length) -%}{%-ifnot ns_chk.can_sort \
相似文章
GLM-5.2 现已可在 HuggingChat 上使用
GLM-5.2 是 zai-org 的一个开源 AI 模型,现已在 HuggingChat 上可用。
GLM 5.3 发布
Z.ai 发布了 GLM 5.3,这是其 GLM 语言模型系列的一次更新。官方公告提供了有关新版本的详细信息。
zai-org/GLM-5.3-Flash
GLM-5.3-Flash 是 GLM-5 系列中首个原生多模态模型,拥有 3200 亿总参数和 180 亿活动参数,通过重新设计的混合架构提高了效率,性能超越之前的版本并接近 Claude Opus 4.8。
Google 正在更新 Gemma 4 的聊天模板,大幅修复工具调用并减少“惰性”,在 Hopper GPU 上启用 Flash Attention 4,同时提供关于如何操作及改进其视觉能力的交互式指南!
Google 更新了 Gemma 4 的聊天模板,显著修复了工具调用,减少了惰性,在 Hopper GPU 上启用了 Flash Attention 4,并发布了交互式视觉指南。这些更新现已可在 Hugging Face 上获取。
@MaximeRivest: 开源LLM中的工具调用在不同模型间差异巨大。我刚刚搭建了:http://chattemplatepl…
一个新的在线工具Chat Template Playground,让用户可视化查看不同开源LLM渲染其聊天模板的方式,突出显示了提示和分词上的差异。