root commited on
Commit
0e5c19a
·
1 Parent(s): ea557f4

Signed-off-by: root <root@rack-ge107-ya-20250517193228.idczw.hb1.kwaidc.com>

Files changed (3) hide show
  1. chat_template.jinja +88 -0
  2. tokenizer.json +2 -2
  3. tokenizer_config.json +6 -15
chat_template.jinja ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- '' }}
7
+ {%- endif %}
8
+ {{- "\n\n# 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>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\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" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" and not message.tool_calls %}
25
+ {%- set content = message.content %}
26
+ {%- if not loop.last %}
27
+ {%- set answer_blocks = message.content.split('<answer>\n') %}
28
+ {%- if answer_blocks|length > 1 %}
29
+ {%- set last_answer_block = answer_blocks[-1] %}
30
+ {%- if '\n</answer>' in last_answer_block %}
31
+ {%- set content = last_answer_block.split('\n</answer>')[0] %}
32
+ {%- else %}
33
+ {%- set content = message.content.split('<think_off>')[-1].lstrip('\n') %}
34
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
35
+ {%- endif %}
36
+ {%- else %}
37
+ {%- set content = message.content.split('<think_off>')[-1].lstrip('\n') %}
38
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
39
+ {%- endif %}
40
+ {%- endif %}
41
+ {{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
42
+ {%- elif message.role == "assistant" %}
43
+ {%- set content = message.content %}
44
+ {%- if not loop.last %}
45
+ {%- set answer_blocks = message.content.split('<answer>\n') %}
46
+ {%- if answer_blocks|length > 1 %}
47
+ {%- set last_answer_block = answer_blocks[-1] %}
48
+ {%- if '\n</answer>' in last_answer_block %}
49
+ {%- set content = last_answer_block.split('\n</answer>')[0] %}
50
+ {%- else %}
51
+ {%- set content = message.content.split('<think_off>')[-1].lstrip('\n') %}
52
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
53
+ {%- endif %}
54
+ {%- else %}
55
+ {%- set content = message.content.split('<think_off>')[-1].lstrip('\n') %}
56
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
57
+ {%- endif %}
58
+ {%- endif %}
59
+ {{- '<|im_start|>' + message.role }}
60
+ {%- if message.content %}
61
+ {{- '\n' + content }}
62
+ {%- endif %}
63
+ {%- for tool_call in message.tool_calls %}
64
+ {%- if tool_call.function is defined %}
65
+ {%- set tool_call = tool_call.function %}
66
+ {%- endif %}
67
+ {{- '\n<tool_call>\n{\"name\": \"' }}
68
+ {{- tool_call.name }}
69
+ {{- '\", \"arguments\": ' }}
70
+ {{- tool_call.arguments | tojson }}
71
+ {{- '}\n</tool_call>' }}
72
+ {%- endfor %}
73
+ {{- '<|im_end|>\n' }}
74
+ {%- elif message.role == "tool" %}
75
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
76
+ {{- '<|im_start|>user' }}
77
+ {%- endif %}
78
+ {{- '\n<tool_response>\n' }}
79
+ {{- message.content }}
80
+ {{- '\n</tool_response>' }}
81
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
82
+ {{- '<|im_end|>\n' }}
83
+ {%- endif %}
84
+ {%- endif %}
85
+ {%- endfor %}
86
+ {%- if add_generation_prompt %}
87
+ {{- '<|im_start|>assistant\n<judge>\n' }}
88
+ {%- endif %}
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b605e8e8cf9ff4382ed3789a92d599e791ac49856eac9a62bde3583feb23ff98
3
- size 11423769
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f624276e49a11cfea0eab481fb41192add20a238c348b4408e915646abf0413d
3
+ size 11423775
tokenizer_config.json CHANGED
@@ -216,7 +216,7 @@
216
  "normalized": false,
217
  "rstrip": false,
218
  "single_word": false,
219
- "special": true
220
  },
221
  "151670": {
222
  "content": "</judge>",
@@ -224,7 +224,7 @@
224
  "normalized": false,
225
  "rstrip": false,
226
  "single_word": false,
227
- "special": true
228
  },
229
  "151671": {
230
  "content": "<answer>",
@@ -232,7 +232,7 @@
232
  "normalized": false,
233
  "rstrip": false,
234
  "single_word": false,
235
- "special": true
236
  },
237
  "151672": {
238
  "content": "</answer>",
@@ -240,7 +240,7 @@
240
  "normalized": false,
241
  "rstrip": false,
242
  "single_word": false,
243
- "special": true
244
  },
245
  "151673": {
246
  "content": "<think_on>",
@@ -248,7 +248,7 @@
248
  "normalized": false,
249
  "rstrip": false,
250
  "single_word": false,
251
- "special": true
252
  },
253
  "151674": {
254
  "content": "<think_off>",
@@ -256,19 +256,10 @@
256
  "normalized": false,
257
  "rstrip": false,
258
  "single_word": false,
259
- "special": true
260
  }
261
  },
262
- "additional_special_tokens": [
263
- "<judge>",
264
- "</judge>",
265
- "<answer>",
266
- "</answer>",
267
- "<think_on>",
268
- "<think_off>"
269
- ],
270
  "bos_token": null,
271
- "chat_template": "{%- if tools %}\n {{- '<|im_start|>system\\n' }}\n {%- if messages[0]['role'] == 'system' %}\n {{- messages[0]['content'] }}\n {%- else %}\n {{- '' }}\n {%- endif %}\n {{- \"\\n\\n# 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>\" }}\n {%- for tool in tools %}\n {{- \"\\n\" }}\n {{- tool | tojson }}\n {%- endfor %}\n {{- \"\\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\" }}\n{%- else %}\n {%- if messages[0]['role'] == 'system' %}\n {{- '<|im_start|>system\\n' + messages[0]['content'] + '<|im_end|>\\n' }}\n {%- else %}\n {{- '<|im_start|>system\\nYou are a helpful assistant.<|im_end|>\\n' }}\n {%- endif %}\n{%- endif %}\n{%- for message in messages %}\n {%- if (message.role == \"user\") or (message.role == \"system\" and not loop.first) %}\n {{- '<|im_start|>' + message.role + '\\n' + message.content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" and not message.tool_calls %}\n {%- set content = message.content %}\n {%- if not loop.last %}\n {%- set answer_blocks = message.content.split('<answer>\\n') %}\n {%- if answer_blocks|length > 1 %}\n {%- set last_answer_block = answer_blocks[-1] %}\n {%- if '\\n</answer>' in last_answer_block %}\n {%- set content = last_answer_block.split('\\n</answer>')[0] %}\n {%- else %}\n {%- set content = message.content.split('<think_off>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- else %}\n {%- set content = message.content.split('<think_off>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {{- '<|im_start|>' + message.role + '\\n' + content + '<|im_end|>' + '\\n' }}\n {%- elif message.role == \"assistant\" %}\n {%- set content = message.content %}\n {%- if not loop.last %}\n {%- set answer_blocks = message.content.split('<answer>\\n') %}\n {%- if answer_blocks|length > 1 %}\n {%- set last_answer_block = answer_blocks[-1] %}\n {%- if '\\n</answer>' in last_answer_block %}\n {%- set content = last_answer_block.split('\\n</answer>')[0] %}\n {%- else %}\n {%- set content = message.content.split('<think_off>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- else %}\n {%- set content = message.content.split('<think_off>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n {%- endif %}\n {{- '<|im_start|>' + message.role }}\n {%- if message.content %}\n {{- '\\n' + content }}\n {%- endif %}\n {%- for tool_call in message.tool_calls %}\n {%- if tool_call.function is defined %}\n {%- set tool_call = tool_call.function %}\n {%- endif %}\n {{- '\\n<tool_call>\\n{\\\"name\\\": \\\"' }}\n {{- tool_call.name }}\n {{- '\\\", \\\"arguments\\\": ' }}\n {{- tool_call.arguments | tojson }}\n {{- '}\\n</tool_call>' }}\n {%- endfor %}\n {{- '<|im_end|>\\n' }}\n {%- elif message.role == \"tool\" %}\n {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|im_start|>user' }}\n {%- endif %}\n {{- '\\n<tool_response>\\n' }}\n {{- message.content }}\n {{- '\\n</tool_response>' }}\n {%- if loop.last or (messages[loop.index0 + 1].role != \"tool\") %}\n {{- '<|im_end|>\\n' }}\n {%- endif %}\n {%- endif %}\n{%- endfor %}\n{%- if add_generation_prompt %}\n {{- '<|im_start|>assistant\\n<judge>\\n' }}\n{%- endif %}",
272
  "clean_up_tokenization_spaces": false,
273
  "eos_token": "<|im_end|>",
274
  "errors": "replace",
 
216
  "normalized": false,
217
  "rstrip": false,
218
  "single_word": false,
219
+ "special": false
220
  },
221
  "151670": {
222
  "content": "</judge>",
 
224
  "normalized": false,
225
  "rstrip": false,
226
  "single_word": false,
227
+ "special": false
228
  },
229
  "151671": {
230
  "content": "<answer>",
 
232
  "normalized": false,
233
  "rstrip": false,
234
  "single_word": false,
235
+ "special": false
236
  },
237
  "151672": {
238
  "content": "</answer>",
 
240
  "normalized": false,
241
  "rstrip": false,
242
  "single_word": false,
243
+ "special": false
244
  },
245
  "151673": {
246
  "content": "<think_on>",
 
248
  "normalized": false,
249
  "rstrip": false,
250
  "single_word": false,
251
+ "special": false
252
  },
253
  "151674": {
254
  "content": "<think_off>",
 
256
  "normalized": false,
257
  "rstrip": false,
258
  "single_word": false,
259
+ "special": false
260
  }
261
  },
 
 
 
 
 
 
 
 
262
  "bos_token": null,
 
263
  "clean_up_tokenization_spaces": false,
264
  "eos_token": "<|im_end|>",
265
  "errors": "replace",