Rocketknight1 HF Staff commited on
Commit
046f212
·
verified ·
1 Parent(s): 5f2c5a5

Update chat_template.jinja

Browse files
Files changed (1) hide show
  1. chat_template.jinja +14 -4
chat_template.jinja CHANGED
@@ -98,12 +98,22 @@
98
  {%- endif %}
99
  {%- set reasoning_content = reasoning_content|trim %}
100
  {{- '<|im_start|>' + message.role + '\n' }}
101
- {%- generation %}
 
102
  {%- if loop.index0 > ns.last_query_index %}
103
- {{- '<think>\n' + reasoning_content + '\n</think>\n\n' + content }}
104
- {%- else %}
105
- {{- content }}
 
 
 
 
 
 
 
106
  {%- endif %}
 
 
107
  {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
108
  {%- for tool_call in message.tool_calls %}
109
  {%- if tool_call.function is defined %}
 
98
  {%- endif %}
99
  {%- set reasoning_content = reasoning_content|trim %}
100
  {{- '<|im_start|>' + message.role + '\n' }}
101
+ {#- What the generation prompt pre-fills stays out of the generation block: the model never generates it #}
102
+ {%- set think_completion = '' %}
103
  {%- if loop.index0 > ns.last_query_index %}
104
+ {%- if enable_thinking is defined and enable_thinking is false %}
105
+ {{- '<think>\n' + reasoning_content + '\n</think>\n\n' }}
106
+ {%- elif reasoning_content %}
107
+ {{- '<think>\n' }}
108
+ {%- set think_completion = reasoning_content + '\n</think>\n\n' %}
109
+ {%- else %}
110
+ {#- Tokenizers merge the empty block's two newlines into one token #}
111
+ {{- '<think>\n\n' }}
112
+ {%- set think_completion = '</think>\n\n' %}
113
+ {%- endif %}
114
  {%- endif %}
115
+ {%- generation %}
116
+ {{- think_completion + content }}
117
  {%- if message.tool_calls and message.tool_calls is iterable and message.tool_calls is not mapping %}
118
  {%- for tool_call in message.tool_calls %}
119
  {%- if tool_call.function is defined %}