Transformers
JingzeShi commited on
Commit
3d3f3a2
·
verified ·
1 Parent(s): 93381dc

Upload tokenizer

Browse files
Files changed (3) hide show
  1. chat_template.jinja +123 -103
  2. tokenizer.json +2 -2
  3. tokenizer_config.json +22 -22
chat_template.jinja CHANGED
@@ -1,108 +1,128 @@
1
- {%- if not documents is defined %}
2
- {%- set documents = none %}
3
- {%- endif %}
4
- {%- if not tools is defined %}
5
- {%- set tools = none %}
6
- {%- endif %}
7
 
 
 
 
8
 
9
- {#- extracts the system message, so we can slot it into the right place. #}
10
- {%- if messages[0].role == 'system' %}
11
- {%- set system_message = messages[0].content|trim %}
12
- {%- else %}
13
- {%- set system_message = "You are Doge, created by SmallDoge Team. You are a helpful assistant" %}
14
- {%- endif %}
15
 
 
 
 
16
 
17
- {#- system message + documents + tools #}
18
- {{- '<|im_start|>system\n' }}
19
- {{- system_message }}
20
- {%- if documents is not none %}
21
- {{- "\n\nYou have access to the following documents. Please use them to answer the user's question.\n\n" }}
22
- {%- for doc in documents %}
23
- {%- if doc.title is defined %}
24
- {{- "Title: " + doc.title + "\n" }}
25
- {%- endif %}
26
- {{- "Content: " + doc.text + "\n\n" }}
27
- {%- endfor %}
28
- {{- "If the documents don't contain relevant information, rely on your general knowledge but acknowledge when you're doing so." }}
29
- {%- endif %}
30
- {%- if tools is not none %}
31
- {{- "\n\nYou may call one or more functions to assist with the user query. You are provided with function signatures within <tools></tools> XML tags:\n\n<tools>" }}
32
- {%- for tool in tools %}
33
- {{- "\n" }}
34
- {{- tool | tojson }}
35
- {%- endfor %}
36
- {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call>" }}
37
- {%- endif %}
38
- {{- "<|im_end|>\n" }}
39
 
40
- {%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
41
- {%- for message in messages[::-1] %}
42
- {%- set index = (messages|length - 1) - loop.index0 %}
43
- {%- if ns.multi_step_tool and message.role == "user" and not(message.content.startswith('<tool_response>') and message.content.endswith('</tool_response>')) %}
44
- {%- set ns.multi_step_tool = false %}
45
- {%- set ns.last_query_index = index %}
46
- {%- endif %}
47
- {%- endfor %}
48
- {%- for message in messages %}
49
- {%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
50
- {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
51
- {%- elif message.role == "assistant" %}
52
- {%- set content = message.content %}
53
- {%- set reasoning_content = '' %}
54
- {%- if message.reasoning_content is defined and message.reasoning_content is not none %}
55
- {%- set reasoning_content = message.reasoning_content %}
56
- {%- else %}
57
- {%- if '</think>' in message.content %}
58
- {%- set content = message.content.split('</think>')[-1].lstrip('\n') %}
59
- {%- set reasoning_content = message.content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
60
- {%- endif %}
61
- {%- endif %}
62
- {%- if loop.index0 > ns.last_query_index %}
63
- {%- if loop.last or (not loop.last and reasoning_content) %}
64
- {{- '<|im_start|>' + message.role + '\n<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
65
- {%- else %}
66
- {{- '<|im_start|>' + message.role + '\n' + content }}
67
- {%- endif %}
68
- {%- else %}
69
- {{- '<|im_start|>' + message.role + '\n' + content }}
70
- {%- endif %}
71
- {%- if message.tool_calls %}
72
- {%- for tool_call in message.tool_calls %}
73
- {%- if (loop.first and content) or (not loop.first) %}
74
- {{- '\n' }}
75
- {%- endif %}
76
- {%- if tool_call.function %}
77
- {%- set tool_call = tool_call.function %}
78
- {%- endif %}
79
- {{- '<tool_call>\n{"name": "' }}
80
- {{- tool_call.name }}
81
- {{- '", "arguments": ' }}
82
- {%- if tool_call.arguments is string %}
83
- {{- tool_call.arguments }}
84
- {%- else %}
85
- {{- tool_call.arguments | tojson }}
86
- {%- endif %}
87
- {{- '}\n</tool_call>' }}
88
- {%- endfor %}
89
- {%- endif %}
90
- {{- '<|im_end|>\n' }}
91
- {%- elif message.role == "tool" %}
92
- {%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
93
- {{- '<|im_start|>user' }}
94
- {%- endif %}
95
- {{- '\n<tool_response>\n' }}
96
- {{- message.content }}
97
- {{- '\n</tool_response>' }}
98
- {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
99
- {{- '<|im_end|>\n' }}
100
- {%- endif %}
101
- {%- endif %}
102
- {%- endfor %}
103
- {%- if add_generation_prompt %}
104
- {{- '<|im_start|>assistant\n' }}
105
- {%- if enable_thinking is defined and enable_thinking is false %}
106
- {{- '<think>\n\n</think>\n\n' }}
107
- {%- endif %}
108
- {%- endif %}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {# ───── defaults ───── #}
2
+ {%- if enable_thinking is not defined -%}
3
+ {%- set enable_thinking = true -%}
4
+ {%- endif -%}
 
 
5
 
6
+ {%- if not documents is defined -%}
7
+ {%- set documents = none -%}
8
+ {%- endif -%}
9
 
10
+ {%- if not tools is defined -%}
11
+ {%- set tools = none -%}
12
+ {%- endif -%}
 
 
 
13
 
14
+ {%- if not xml_tools is defined -%}
15
+ {%- set xml_tools = none -%}
16
+ {%- endif -%}
17
 
18
+ {%- if not python_tools is defined -%}
19
+ {%- set python_tools = none -%}
20
+ {%- endif -%}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
+ {# ───── reasoning mode ───── #}
23
+ {%- if enable_thinking -%}
24
+ {%- set reasoning_mode = "/think" -%}
25
+ {%- else -%}
26
+ {%- set reasoning_mode = "/no_think" -%}
27
+ {%- endif -%}
28
+
29
+ {# ───── system header ───── #}
30
+ {%- if messages[0].role == 'system' -%}
31
+ {%- set system_message = messages[0].content -%}
32
+ {%- if "/no_think" in system_message -%}
33
+ {%- set reasoning_mode = "/no_think" -%}
34
+ {%- elif "/think" in system_message -%}
35
+ {%- set reasoning_mode = "/think" -%}
36
+ {%- endif -%}
37
+ {%- set custom_instructions = system_message.replace("/no_think", "").replace("/think", "").rstrip() -%}
38
+ {%- endif -%}
39
+
40
+ {# ───── build system message ───── #}
41
+ {{- '<|im_start|>system\n' -}}
42
+
43
+ {%- if "/system_override" in system_message -%}
44
+ {{- custom_instructions.replace("/system_override", "").rstrip() -}}
45
+ {{- "<|im_end|>\n" -}}
46
+ {%- else -%}
47
+ {{- "## Metadata\n\n" -}}
48
+ {{- "Knowledge Cutoff Date: June 2025\n" -}}
49
+ {%- set today = strftime_now("%d %B %Y") -%}
50
+ {{- "Today Date: " ~ today ~ "\n" -}}
51
+ {{- "Reasoning Mode: " + reasoning_mode + "\n\n" -}}
52
+
53
+ {{- "## Custom Instructions\n\n" -}}
54
+ {%- if custom_instructions -%}
55
+ {{- custom_instructions + "\n\n" -}}
56
+ {%- elif reasoning_mode == "/think" -%}
57
+ {{- "You are Doge, an AI assistant created by the SmallDoge Team. Your role as an assistant involves thoroughly exploring questions through a systematic thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracking, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution using the specified format: <think> Thought section </think> Solution section. In the Thought section, detail your reasoning process in steps. Each step should include detailed considerations such as analysing questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The Solution section should be logical, accurate, and concise and detail necessary steps needed to reach the conclusion.\n\n" -}}
58
+ {%- else -%}
59
+ {{- "You are Doge, an AI assistant created by the SmallDoge Team.\n\n" -}}
60
+ {%- endif -%}
61
+
62
+ {# ───── Document Support ───── #}
63
+ {%- if documents is not none -%}
64
+ {{- "### Documents\n\n" -}}
65
+ {{- "You have access to the following documents to answer the user's questions:\n\n" -}}
66
+ {%- for doc in documents -%}
67
+ {%- if doc.title is defined -%}
68
+ {{- "**Title**: " ~ doc.title ~ "\n" -}}
69
+ {%- endif -%}
70
+ {{- "**Content**: " ~ doc.text ~ "\n\n" -}}
71
+ {%- endfor -%}
72
+ {{- "If the documents don't contain relevant information, rely on your general knowledge but acknowledge when you're doing so.\n\n" -}}
73
+ {%- endif -%}
74
+
75
+ {# ───── Tool Support ───── #}
76
+ {%- if xml_tools or python_tools or tools -%}
77
+ {{- "### Tools\n\n" -}}
78
+ {%- if xml_tools or tools -%}
79
+ {%- if tools -%}
80
+ {%- set xml_tools = tools -%}
81
+ {%- endif -%}
82
+ {%- set ns = namespace(xml_tool_string="You may call one or more functions to assist with the user query.\nYou are provided with function signatures within <tools></tools> XML tags:\n\n<tools>\n") -%}
83
+ {%- for tool in xml_tools[:] -%} {# The slicing makes sure that xml_tools is a list #}
84
+ {%- set ns.xml_tool_string = ns.xml_tool_string ~ (tool | string) ~ "\n" -%}
85
+ {%- endfor -%}
86
+ {%- set xml_tool_string = ns.xml_tool_string + "</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>" -%}
87
+ {{- xml_tool_string -}}
88
+ {%- endif -%}
89
+ {%- if python_tools -%}
90
+ {%- set ns = namespace(python_tool_string="When you send a message containing Python code between '<code>' and '</code>' tags, it will be executed in a stateful Jupyter notebook environment, and you will then be given the output to continued reasoning in an agentic loop.\n\nYou can use the following tools in your python code like regular functions:\n<tools>\n") -%}
91
+ {%- for tool in python_tools[:] -%} {# The slicing makes sure that python_tools is a list #}
92
+ {%- set ns.python_tool_string = ns.python_tool_string ~ (tool | string) ~ "\n" -%}
93
+ {%- endfor -%}
94
+ {%- set python_tool_string = ns.python_tool_string + "</tools>\n\nThe state persists between code executions: so variables that you define in one step are still available thereafter." -%}
95
+ {{- python_tool_string -}}
96
+ {%- endif -%}
97
+ {{- "\n\n" -}}
98
+ {%- endif -%}
99
+ {%- endif -%}
100
+
101
+ {{- '<|im_end|>\n' -}}
102
+
103
+ {# ───── Message loop ───── #}
104
+ {%- for message in messages -%}
105
+ {%- set content = message.content if message.content is string else "" -%}
106
+ {%- if message.role == "user" -%}
107
+ {{ "<|im_start|>" + message.role + "\n" + content + "<|im_end|>\n" }}
108
+ {%- elif message.role == "assistant" -%}
109
+ {% generation %}
110
+ {%- if reasoning_mode == "/think" -%}
111
+ {{ "<|im_start|>assistant\n" + content.lstrip("\n") + "<|im_end|>\n" }}
112
+ {%- else -%}
113
+ {{ "<|im_start|>assistant\n" + "<think>\n\n</think>\n" + content.lstrip("\n") + "<|im_end|>\n" }}
114
+ {%- endif -%}
115
+ {% endgeneration %}
116
+ {%- elif message.role == "tool" -%}
117
+ {{ "<|im_start|>" + "user\n" + content + "<|im_end|>\n" }}
118
+ {%- endif -%}
119
+ {%- endfor -%}
120
+
121
+ {# ───── Generation prompt ───── #}
122
+ {%- if add_generation_prompt -%}
123
+ {%- if enable_thinking -%}
124
+ {{- '<|im_start|>assistant\n' -}}
125
+ {%- else -%}
126
+ {{- '<|im_start|>assistant\n<think>\n\n</think>\n\n' -}}
127
+ {%- endif -%}
128
+ {%- endif -%}
tokenizer.json CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:b85fb1de25c35f6bab2908dc8f264bc5e3b95818bc0c70e5645913cf38c8400d
3
- size 17209526
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3093b6709da4163f45f32cf0d9965a3f78fd203d1fb6d0e6a3d30a2568bd6688
3
+ size 17209488
tokenizer_config.json CHANGED
@@ -83,7 +83,7 @@
83
  "special": true
84
  },
85
  "128010": {
86
- "content": "<|object_ref_start|>",
87
  "lstrip": false,
88
  "normalized": false,
89
  "rstrip": false,
@@ -91,7 +91,7 @@
91
  "special": true
92
  },
93
  "128011": {
94
- "content": "<|object_ref_end|>",
95
  "lstrip": false,
96
  "normalized": false,
97
  "rstrip": false,
@@ -99,7 +99,7 @@
99
  "special": true
100
  },
101
  "128012": {
102
- "content": "<|box_start|>",
103
  "lstrip": false,
104
  "normalized": false,
105
  "rstrip": false,
@@ -107,7 +107,7 @@
107
  "special": true
108
  },
109
  "128013": {
110
- "content": "<|box_end|>",
111
  "lstrip": false,
112
  "normalized": false,
113
  "rstrip": false,
@@ -115,7 +115,7 @@
115
  "special": true
116
  },
117
  "128014": {
118
- "content": "<|quad_start|>",
119
  "lstrip": false,
120
  "normalized": false,
121
  "rstrip": false,
@@ -123,7 +123,7 @@
123
  "special": true
124
  },
125
  "128015": {
126
- "content": "<|quad_end|>",
127
  "lstrip": false,
128
  "normalized": false,
129
  "rstrip": false,
@@ -131,7 +131,7 @@
131
  "special": true
132
  },
133
  "128016": {
134
- "content": "<|vision_start|>",
135
  "lstrip": false,
136
  "normalized": false,
137
  "rstrip": false,
@@ -139,7 +139,7 @@
139
  "special": true
140
  },
141
  "128017": {
142
- "content": "<|vision_end|>",
143
  "lstrip": false,
144
  "normalized": false,
145
  "rstrip": false,
@@ -147,7 +147,7 @@
147
  "special": true
148
  },
149
  "128018": {
150
- "content": "<|vision_pad|>",
151
  "lstrip": false,
152
  "normalized": false,
153
  "rstrip": false,
@@ -155,7 +155,7 @@
155
  "special": true
156
  },
157
  "128019": {
158
- "content": "<|image_pad|>",
159
  "lstrip": false,
160
  "normalized": false,
161
  "rstrip": false,
@@ -163,7 +163,7 @@
163
  "special": true
164
  },
165
  "128020": {
166
- "content": "<|video_pad|>",
167
  "lstrip": false,
168
  "normalized": false,
169
  "rstrip": false,
@@ -171,7 +171,7 @@
171
  "special": true
172
  },
173
  "128021": {
174
- "content": "<|fim_prefix|>",
175
  "lstrip": false,
176
  "normalized": false,
177
  "rstrip": false,
@@ -179,7 +179,7 @@
179
  "special": true
180
  },
181
  "128022": {
182
- "content": "<|fim_middle|>",
183
  "lstrip": false,
184
  "normalized": false,
185
  "rstrip": false,
@@ -187,7 +187,7 @@
187
  "special": true
188
  },
189
  "128023": {
190
- "content": "<|fim_suffix|>",
191
  "lstrip": false,
192
  "normalized": false,
193
  "rstrip": false,
@@ -195,7 +195,7 @@
195
  "special": true
196
  },
197
  "128024": {
198
- "content": "<|fim_pad|>",
199
  "lstrip": false,
200
  "normalized": false,
201
  "rstrip": false,
@@ -203,7 +203,7 @@
203
  "special": true
204
  },
205
  "128025": {
206
- "content": "<|repo_name|>",
207
  "lstrip": false,
208
  "normalized": false,
209
  "rstrip": false,
@@ -211,7 +211,7 @@
211
  "special": true
212
  },
213
  "128026": {
214
- "content": "<|file_sep|>",
215
  "lstrip": false,
216
  "normalized": false,
217
  "rstrip": false,
@@ -219,7 +219,7 @@
219
  "special": true
220
  },
221
  "128027": {
222
- "content": "<|conversation_title|>",
223
  "lstrip": false,
224
  "normalized": false,
225
  "rstrip": false,
@@ -227,7 +227,7 @@
227
  "special": true
228
  },
229
  "128028": {
230
- "content": "<|code_block_start|>",
231
  "lstrip": false,
232
  "normalized": false,
233
  "rstrip": false,
@@ -235,7 +235,7 @@
235
  "special": true
236
  },
237
  "128029": {
238
- "content": "<|code_block_end|>",
239
  "lstrip": false,
240
  "normalized": false,
241
  "rstrip": false,
@@ -243,7 +243,7 @@
243
  "special": true
244
  },
245
  "128030": {
246
- "content": "<|citation_start|>",
247
  "lstrip": false,
248
  "normalized": false,
249
  "rstrip": false,
@@ -251,7 +251,7 @@
251
  "special": true
252
  },
253
  "128031": {
254
- "content": "<|citation_end|>",
255
  "lstrip": false,
256
  "normalized": false,
257
  "rstrip": false,
 
83
  "special": true
84
  },
85
  "128010": {
86
+ "content": "<code>",
87
  "lstrip": false,
88
  "normalized": false,
89
  "rstrip": false,
 
91
  "special": true
92
  },
93
  "128011": {
94
+ "content": "</code>",
95
  "lstrip": false,
96
  "normalized": false,
97
  "rstrip": false,
 
99
  "special": true
100
  },
101
  "128012": {
102
+ "content": "<citation>",
103
  "lstrip": false,
104
  "normalized": false,
105
  "rstrip": false,
 
107
  "special": true
108
  },
109
  "128013": {
110
+ "content": "</citation>",
111
  "lstrip": false,
112
  "normalized": false,
113
  "rstrip": false,
 
115
  "special": true
116
  },
117
  "128014": {
118
+ "content": "<|conversation_title|>",
119
  "lstrip": false,
120
  "normalized": false,
121
  "rstrip": false,
 
123
  "special": true
124
  },
125
  "128015": {
126
+ "content": "<|object_ref_start|>",
127
  "lstrip": false,
128
  "normalized": false,
129
  "rstrip": false,
 
131
  "special": true
132
  },
133
  "128016": {
134
+ "content": "<|object_ref_end|>",
135
  "lstrip": false,
136
  "normalized": false,
137
  "rstrip": false,
 
139
  "special": true
140
  },
141
  "128017": {
142
+ "content": "<|box_start|>",
143
  "lstrip": false,
144
  "normalized": false,
145
  "rstrip": false,
 
147
  "special": true
148
  },
149
  "128018": {
150
+ "content": "<|box_end|>",
151
  "lstrip": false,
152
  "normalized": false,
153
  "rstrip": false,
 
155
  "special": true
156
  },
157
  "128019": {
158
+ "content": "<|quad_start|>",
159
  "lstrip": false,
160
  "normalized": false,
161
  "rstrip": false,
 
163
  "special": true
164
  },
165
  "128020": {
166
+ "content": "<|quad_end|>",
167
  "lstrip": false,
168
  "normalized": false,
169
  "rstrip": false,
 
171
  "special": true
172
  },
173
  "128021": {
174
+ "content": "<|vision_start|>",
175
  "lstrip": false,
176
  "normalized": false,
177
  "rstrip": false,
 
179
  "special": true
180
  },
181
  "128022": {
182
+ "content": "<|vision_end|>",
183
  "lstrip": false,
184
  "normalized": false,
185
  "rstrip": false,
 
187
  "special": true
188
  },
189
  "128023": {
190
+ "content": "<|vision_pad|>",
191
  "lstrip": false,
192
  "normalized": false,
193
  "rstrip": false,
 
195
  "special": true
196
  },
197
  "128024": {
198
+ "content": "<|image_pad|>",
199
  "lstrip": false,
200
  "normalized": false,
201
  "rstrip": false,
 
203
  "special": true
204
  },
205
  "128025": {
206
+ "content": "<|video_pad|>",
207
  "lstrip": false,
208
  "normalized": false,
209
  "rstrip": false,
 
211
  "special": true
212
  },
213
  "128026": {
214
+ "content": "<|fim_prefix|>",
215
  "lstrip": false,
216
  "normalized": false,
217
  "rstrip": false,
 
219
  "special": true
220
  },
221
  "128027": {
222
+ "content": "<|fim_middle|>",
223
  "lstrip": false,
224
  "normalized": false,
225
  "rstrip": false,
 
227
  "special": true
228
  },
229
  "128028": {
230
+ "content": "<|fim_suffix|>",
231
  "lstrip": false,
232
  "normalized": false,
233
  "rstrip": false,
 
235
  "special": true
236
  },
237
  "128029": {
238
+ "content": "<|fim_pad|>",
239
  "lstrip": false,
240
  "normalized": false,
241
  "rstrip": false,
 
243
  "special": true
244
  },
245
  "128030": {
246
+ "content": "<|repo_name|>",
247
  "lstrip": false,
248
  "normalized": false,
249
  "rstrip": false,
 
251
  "special": true
252
  },
253
  "128031": {
254
+ "content": "<|file_sep|>",
255
  "lstrip": false,
256
  "normalized": false,
257
  "rstrip": false,