fwizzer1 commited on
Commit
5e24538
·
verified ·
1 Parent(s): 8d572f7

Fix EN chat template without trailing <think>

Browse files
Files changed (1) hide show
  1. en/chat_template.jinja +44 -2
en/chat_template.jinja CHANGED
@@ -1,2 +1,44 @@
1
- {{ bos_token }}{%- set default_system = 'You are a thinking neural network and your name is Fwizzer-R1-3B-RU. Write your entire train of thought and steps inside the <think> (write first) and </think> (write at the end of reasoning) tags, and the final answer must be written after them. Always respond and reason strictly in the language the user addressed you in (for example, if the question is in Russian - answer in Russian, if in English - in English, if in Chinese - in Chinese).' -%}{%- if messages[0]['role'] == 'system' -%} {%- set system_message = messages[0]['content'] -%} {%- set loop_messages = messages[1:] -%}{%- else -%} {%- set system_message = default_system -%} {%- set loop_messages = messages -%}{%- endif -%}{%- for message in loop_messages -%} {%- if message['role'] == 'user' -%} {%- if loop.first and system_message -%} {{ '[SYSTEM_PROMPT]' + system_message + '[/SYSTEM_PROMPT][INST]' + message['content'] + '[/INST]' }} {%- else -%} {{ '[INST]' + message['content'] + '[/INST]' }} {%- endif -%} {%- elif message['role'] == 'assistant' -%} {{ message['content'] + eos_token }} {%- endif -%}{%- endfor -%}{%- if add_generation_prompt -%} {{ '<think>
2
- ' }}{%- endif -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- set default_system_message = 'You are Fwizzer-R1-3B, a helpful and reasoning language model. Always think step-by-step inside <think> and </think> tags before answering, then provide a clear, accurate, and concise response in the language of the user prompt.' %}
2
+ {%- if messages[0]['role'] == 'system' %}
3
+ {{- '[SYSTEM_PROMPT]' -}}
4
+ {%- if messages[0]['content'] is string %}
5
+ {{- messages[0]['content'] -}}
6
+ {%- else %}
7
+ {%- for block in messages[0]['content'] %}
8
+ {%- if block['type'] == 'text' %}
9
+ {{- block['text'] -}}
10
+ {%- endif %}
11
+ {%- endfor %}
12
+ {%- endif %}
13
+ {{- '[/SYSTEM_PROMPT]' -}}
14
+ {%- set loop_messages = messages[1:] %}
15
+ {%- else %}
16
+ {{- '[SYSTEM_PROMPT]' + default_system_message + '[/SYSTEM_PROMPT]' }}
17
+ {%- set loop_messages = messages %}
18
+ {%- endif %}
19
+ {%- for message in loop_messages %}
20
+ {%- if message['role'] == 'user' %}
21
+ {%- if message['content'] is string %}
22
+ {{- '[INST]' + message['content'] + '[/INST]' }}
23
+ {%- else %}
24
+ {{- '[INST]' }}
25
+ {%- for block in message['content'] %}
26
+ {%- if block['type'] == 'text' %}
27
+ {{- block['text'] -}}
28
+ {%- endif %}
29
+ {%- endfor %}
30
+ {{- '[/INST]' }}
31
+ {%- endif %}
32
+ {%- elif message['role'] == 'assistant' %}
33
+ {%- if message['content'] is string %}
34
+ {{- message['content'] }}
35
+ {%- else %}
36
+ {%- for block in message['content'] %}
37
+ {%- if block['type'] == 'text' %}
38
+ {{- block['text'] -}}
39
+ {%- endif %}
40
+ {%- endfor %}
41
+ {%- endif %}
42
+ {{- eos_token }}
43
+ {%- endif %}
44
+ {%- endfor %}