joerowell commited on
Commit
2bea609
·
verified ·
1 Parent(s): 259f52e

Fix chat template: preserve reasoning across turns (llama.cpp --reasoning-preserve)

Browse files
Files changed (1) hide show
  1. chat_template.jinja +2 -1
chat_template.jinja CHANGED
@@ -3,6 +3,7 @@
3
  {{- "〈|EOS|〉" -}}
4
  {%- set enable_thinking = enable_thinking | default(false) -%}
5
  {%- set add_generation_prompt = add_generation_prompt | default(false) -%}
 
6
 
7
  {#- ───── header (system message) ───── -#}
8
  {#- A caller-supplied system message with empty content opts out of the default below, producing no <system> block — used to train without a system message. -#}
@@ -51,7 +52,7 @@
51
  {%- set reasoning_content = message.reasoning_content -%}
52
  {%- endif -%}
53
  {#- Display reasoning content for all messages if enable_thinking -#}
54
- {%- if enable_thinking -%}
55
  {{- '<think>' + reasoning_content + '</think>' -}}
56
  {%- else -%}
57
  {{- '</think>' -}}
 
3
  {{- "〈|EOS|〉" -}}
4
  {%- set enable_thinking = enable_thinking | default(false) -%}
5
  {%- set add_generation_prompt = add_generation_prompt | default(false) -%}
6
+ {%- set preserve_thinking = preserve_thinking | default(false) -%}
7
 
8
  {#- ───── header (system message) ───── -#}
9
  {#- A caller-supplied system message with empty content opts out of the default below, producing no <system> block — used to train without a system message. -#}
 
52
  {%- set reasoning_content = message.reasoning_content -%}
53
  {%- endif -%}
54
  {#- Display reasoning content for all messages if enable_thinking -#}
55
+ {%- if enable_thinking or preserve_thinking -%}
56
  {{- '<think>' + reasoning_content + '</think>' -}}
57
  {%- else -%}
58
  {{- '</think>' -}}