初始化项目,由ModelHub XC社区提供模型
Model: wexhi/Qwen3-4B-TIR Source: Original Platform
This commit is contained in:
61
chat_template.jinja
Normal file
61
chat_template.jinja
Normal file
@@ -0,0 +1,61 @@
|
||||
{#
|
||||
TIR (Tool-Integrated Reasoning) Chat Template - 单轮格式
|
||||
用于 Qwen3 Thinking 模型的 TIR 训练和推理
|
||||
|
||||
特性:
|
||||
- 支持 system/user/assistant 角色(无独立 tool 角色)
|
||||
- assistant 消息自动添加 <think> 开始标签
|
||||
- 工具调用和响应内联在 assistant 内容中:
|
||||
<think>
|
||||
推理...
|
||||
<tool_call>
|
||||
...
|
||||
</tool_call>
|
||||
<tool_response>
|
||||
...
|
||||
</tool_response>
|
||||
继续推理...
|
||||
</think>
|
||||
最终答案
|
||||
#}
|
||||
{%- if tools %}
|
||||
{{- '<|im_start|>system\n' }}
|
||||
{%- if messages[0].role == 'system' %}
|
||||
{{- messages[0].content + '\n\n' }}
|
||||
{%- endif %}
|
||||
{{- "# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
||||
{%- for tool in tools %}
|
||||
{{- "\n" }}
|
||||
{{- tool | tojson }}
|
||||
{%- endfor %}
|
||||
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
||||
{%- else %}
|
||||
{%- if messages[0].role == 'system' %}
|
||||
{{- '<|im_start|>system\n' + messages[0].content + '<|im_end|>\n' }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- for message in messages %}
|
||||
{%- if message.content is string %}
|
||||
{%- set content = message.content %}
|
||||
{%- else %}
|
||||
{%- set content = '' %}
|
||||
{%- endif %}
|
||||
{%- if message.role == "user" or (message.role == "system" and not loop.first) %}
|
||||
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>\n' }}
|
||||
{%- elif message.role == "assistant" %}
|
||||
{%- set reasoning_content = '' %}
|
||||
{%- if message.reasoning_content is string %}
|
||||
{%- set reasoning_content = message.reasoning_content %}
|
||||
{%- endif %}
|
||||
{%- if reasoning_content %}
|
||||
{#- 有独立的 reasoning_content 字段:使用标准包装格式 #}
|
||||
{{- '<|im_start|>assistant\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') + '<|im_end|>\n' }}
|
||||
{%- else %}
|
||||
{#- 普通 assistant 消息:添加 <think> 开始标签 #}
|
||||
{{- '<|im_start|>assistant\n<think>\n' + content + '<|im_end|>\n' }}
|
||||
{%- endif %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- if add_generation_prompt %}
|
||||
{{- '<|im_start|>assistant\n<think>\n' }}
|
||||
{%- endif %}
|
||||
Reference in New Issue
Block a user