add chat template and tokens
Browse files- chat_template.jinja +383 -0
- config.json +2 -2
- generation_config.json +1 -1
- special_tokens_map.json +1 -1
- tokenizer.json +16 -16
- tokenizer.model +2 -2
- tokenizer.model.v3 +0 -0
- tokenizer_config.json +9 -9
chat_template.jinja
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set system_start = '<|im_start|>system\n' -%}
|
| 2 |
+
{%- set user_start = '<|im_start|>user\n' -%}
|
| 3 |
+
{%- set assistant_start = '<|im_start|>assistant\n' -%}
|
| 4 |
+
{%- set system_end = '<|im_end|>\n' -%}
|
| 5 |
+
{%- set user_end = '<|im_end|>\n' -%}
|
| 6 |
+
{%- set assistant_end = '<|im_end|>\n' -%}
|
| 7 |
+
{%- set tool_defs_start = '<|tools_start|>\n' -%}
|
| 8 |
+
{%- set tool_defs_end = '\n<|tools_end|>' -%}
|
| 9 |
+
{%- set tool_call_start = '\n<|tool_start|>\n' -%}
|
| 10 |
+
{%- set tool_call_end = '\n<|tool_end|>' -%}
|
| 11 |
+
{%- set tool_result_start = '<|im_start|>tool\n' -%}
|
| 12 |
+
{%- set tool_result_sep = '\n' -%}
|
| 13 |
+
{%- set tool_result_end = '\n<|im_end|>\n' -%}
|
| 14 |
+
{%- set reasoning_start = '<|thinking|>\n' -%}
|
| 15 |
+
{%- set reasoning_end = '\n<|thinking_end|>\n' -%}
|
| 16 |
+
{%- set default_system_prompt = "" -%}
|
| 17 |
+
{%- set tool_defs_preamble = "You are provided with function signatures within " + tool_defs_start.strip() + tool_defs_end.strip() + "\n" -%}
|
| 18 |
+
{%- set tool_defs_postamble = "\nFor each function call, call them within " + tool_call_start.strip() + tool_call_end.strip() + "." -%}
|
| 19 |
+
{%- set tool_defs_style = "python" -%}
|
| 20 |
+
{%- set tool_call_style = "python" -%}
|
| 21 |
+
|
| 22 |
+
{%- set content_ns = namespace(content='') %}
|
| 23 |
+
|
| 24 |
+
{%- if messages[0].role == 'system' %}
|
| 25 |
+
{%- if messages[0].content is string %}
|
| 26 |
+
{%- set content_ns.content = messages[0].content %}
|
| 27 |
+
{%- elif messages[0].content is iterable %}
|
| 28 |
+
{%- set content_ns.content = '' %}
|
| 29 |
+
{%- for part in messages[0].content %}
|
| 30 |
+
{%- set content_ns.content = content_ns.content + part.text %}
|
| 31 |
+
{%- endfor %}
|
| 32 |
+
{%- else %}
|
| 33 |
+
{%- set content_ns.content = '' %}
|
| 34 |
+
{%- endif %}
|
| 35 |
+
{%- set messages = messages[1:] %}
|
| 36 |
+
{%- else %}
|
| 37 |
+
{%- set content_ns.content = default_system_prompt %}
|
| 38 |
+
{%- endif %}
|
| 39 |
+
|
| 40 |
+
{%- macro json_to_python_type(json_spec) %}
|
| 41 |
+
{%- set basic_type_map = {
|
| 42 |
+
"string": "str",
|
| 43 |
+
"number": "float",
|
| 44 |
+
"integer": "int",
|
| 45 |
+
"boolean": "bool"
|
| 46 |
+
} %}
|
| 47 |
+
|
| 48 |
+
{%- if basic_type_map[json_spec.type] is defined %}
|
| 49 |
+
{{- basic_type_map[json_spec.type] }}
|
| 50 |
+
{%- elif json_spec.type == "array" %}
|
| 51 |
+
{{- "List[" + json_to_python_type(json_spec.items) + "]"}}
|
| 52 |
+
{%- elif json_spec.type == "object" %}
|
| 53 |
+
{{- "Dict[str, " + json_to_python_type(json_spec.additionalProperties) + ']'}}
|
| 54 |
+
{%- elif json_spec.type is iterable %}
|
| 55 |
+
{{- "Union[" }}
|
| 56 |
+
{%- for t in json_spec.type %}
|
| 57 |
+
{{- json_to_python_type({"type": t}) }}
|
| 58 |
+
{%- if not loop.last %}
|
| 59 |
+
{{- "," }}
|
| 60 |
+
{%- endif %}
|
| 61 |
+
{%- endfor %}
|
| 62 |
+
{{- "]" }}
|
| 63 |
+
{%- else %}
|
| 64 |
+
{{- "Any" }}
|
| 65 |
+
{%- endif %}
|
| 66 |
+
{%- endmacro %}
|
| 67 |
+
|
| 68 |
+
{%- macro json_to_python_value(json_value) %}
|
| 69 |
+
{%- if json_value is string %}
|
| 70 |
+
{{- json_value|tojson }}
|
| 71 |
+
{%- elif json_value is integer or json_value is float %}
|
| 72 |
+
{{- json_value|tojson }}
|
| 73 |
+
{%- elif json_value is boolean %}
|
| 74 |
+
{%- if json_value %}
|
| 75 |
+
{{- "True" }}
|
| 76 |
+
{%- else %}
|
| 77 |
+
{{- "False" }}
|
| 78 |
+
{%- endif %}
|
| 79 |
+
{%- elif json_value is iterable %}
|
| 80 |
+
{{- "[" }}
|
| 81 |
+
{%- for item in json_value %}
|
| 82 |
+
{{- json_to_python_value(item) }}
|
| 83 |
+
{%- if not loop.last %}
|
| 84 |
+
{{- ',' }}
|
| 85 |
+
{%- endif %}
|
| 86 |
+
{%- endfor %}
|
| 87 |
+
{{- "]" }}
|
| 88 |
+
{%- else %}
|
| 89 |
+
{{- "None" }}
|
| 90 |
+
{%- endif %}
|
| 91 |
+
{%- endmacro%}
|
| 92 |
+
|
| 93 |
+
{%- macro python_tools_parser(tools) %}
|
| 94 |
+
{%- for tool in tools %}
|
| 95 |
+
{%- if loop.index0 != 0 %}
|
| 96 |
+
{{- '\n\n'}}
|
| 97 |
+
{%- endif %}
|
| 98 |
+
{%- if tool.function is defined %}
|
| 99 |
+
{%- set tool = tool.function %}
|
| 100 |
+
{%- endif %}
|
| 101 |
+
{{-'def ' + tool.name + '('}}
|
| 102 |
+
{%- for param_name, param_fields in tool.parameters.properties|items %}
|
| 103 |
+
{%- if loop.index0 != 0 %}
|
| 104 |
+
{{- ', '}}
|
| 105 |
+
{%- endif %}
|
| 106 |
+
{{-param_name + ": "}}
|
| 107 |
+
{%- if not param_name in tool.parameters.required %}
|
| 108 |
+
{{-'Optional[' + json_to_python_type(param_fields) + '] = None'}}
|
| 109 |
+
{%- else %}
|
| 110 |
+
{{- json_to_python_type(param_fields) }}
|
| 111 |
+
{%- endif %}
|
| 112 |
+
{%- endfor %}
|
| 113 |
+
{{- ') -> str:\n """'}}
|
| 114 |
+
{{- tool.description }}
|
| 115 |
+
{%- if tool.parameters.properties|length != 0 %}
|
| 116 |
+
{{- '\n\n Args:\n '}}
|
| 117 |
+
{%- for param_name, param_fields in tool.parameters.properties|items %}
|
| 118 |
+
{%- if loop.index0 != 0 %}
|
| 119 |
+
{{- '\n ' }}
|
| 120 |
+
{%- endif %}
|
| 121 |
+
{{- param_name + ' ('}}
|
| 122 |
+
{%- if not param_name in tool.parameters.required %}
|
| 123 |
+
{{-'Optional[' + json_to_python_type(param_fields) + ']'}}
|
| 124 |
+
{%- else %}
|
| 125 |
+
{{- json_to_python_type(param_fields) }}
|
| 126 |
+
{%- endif %}
|
| 127 |
+
{{- ')' }}
|
| 128 |
+
{%- if param_fields.description %}
|
| 129 |
+
{{- ': ' + param_fields.description }}
|
| 130 |
+
{%- endif%}
|
| 131 |
+
{%- endfor %}
|
| 132 |
+
{%- endif %}
|
| 133 |
+
{{- '\n """\n pass' }}
|
| 134 |
+
{%- endfor %}
|
| 135 |
+
{%- endmacro %}
|
| 136 |
+
|
| 137 |
+
{%- macro python_tool_call_parser(tool_call) %}
|
| 138 |
+
{{- tool_call.name + '(' }}
|
| 139 |
+
{%- if tool_call.arguments is string %}
|
| 140 |
+
{{- raise_exception("Python tool call parser doesn't support arguments as a json string") }}
|
| 141 |
+
{%- endif %}
|
| 142 |
+
{%- for param_name, param_field in tool_call.arguments|items %}
|
| 143 |
+
{{- param_name + '= '}}
|
| 144 |
+
{{- json_to_python_value(param_field) }}
|
| 145 |
+
{%- if not loop.last %}
|
| 146 |
+
{{- ', '}}
|
| 147 |
+
{%- endif %}
|
| 148 |
+
{%- endfor %}
|
| 149 |
+
{{- ')' }}
|
| 150 |
+
{%- endmacro %}
|
| 151 |
+
|
| 152 |
+
{%- macro json_tools_parser(tools) %}
|
| 153 |
+
{%- for tool in tools %}
|
| 154 |
+
{%- if not loop.first %}
|
| 155 |
+
{{- "\n" }}
|
| 156 |
+
{%- endif %}
|
| 157 |
+
{{- tool | tojson }}
|
| 158 |
+
{%- endfor %}
|
| 159 |
+
{%- endmacro %}
|
| 160 |
+
|
| 161 |
+
{%- macro json_tool_call_parser(tool_call) %}
|
| 162 |
+
{{- '{"name": "' }}
|
| 163 |
+
{{- tool_call.name }}
|
| 164 |
+
{{- '", "arguments": ' }}
|
| 165 |
+
{%- if tool_call.arguments is string %}
|
| 166 |
+
{{- tool_call.arguments }}
|
| 167 |
+
{%- else %}
|
| 168 |
+
{{- tool_call.arguments | tojson }}
|
| 169 |
+
{%- endif %}
|
| 170 |
+
{{- '}' }}
|
| 171 |
+
{%- endmacro %}
|
| 172 |
+
|
| 173 |
+
{%- if tools %}
|
| 174 |
+
{{- system_start }}
|
| 175 |
+
{%- if content_ns.content | length > 0 %}
|
| 176 |
+
{{- content_ns.content + '\n\n' }}
|
| 177 |
+
{%- endif %}
|
| 178 |
+
{{- tool_defs_preamble + tool_defs_start }}
|
| 179 |
+
{%- if tool_defs_style == "json" %}
|
| 180 |
+
{{- json_tools_parser(tools) }}
|
| 181 |
+
{%- elif tool_defs_style == "python" %}
|
| 182 |
+
{{- python_tools_parser(tools) }}
|
| 183 |
+
{%- else %}
|
| 184 |
+
{{- raise_exception("Invalid tool definition style (" + tool_defs_style + "), must be 'json' or 'python'") }}
|
| 185 |
+
{%- endif %}
|
| 186 |
+
{{- tool_defs_end + tool_defs_postamble }}
|
| 187 |
+
{%- if (messages|length == 0) and not add_generation_prompt %}
|
| 188 |
+
{{- system_end.rstrip('\n') }}
|
| 189 |
+
{%- else %}
|
| 190 |
+
{{- system_end }}
|
| 191 |
+
{%- endif %}
|
| 192 |
+
{%- else %}
|
| 193 |
+
{%- if content_ns.content | length > 0 %}
|
| 194 |
+
{{- system_start + content_ns.content }}
|
| 195 |
+
{%- if (messages|length == 0) and not add_generation_prompt %}
|
| 196 |
+
{{- system_end.rstrip('\n') }}
|
| 197 |
+
{%- else %}
|
| 198 |
+
{{- system_end }}
|
| 199 |
+
{%- endif %}
|
| 200 |
+
{%- endif%}
|
| 201 |
+
{%- endif %}
|
| 202 |
+
|
| 203 |
+
{%- set ns = namespace(multi_step_tool=true, last_query_index=messages|length - 1) %}
|
| 204 |
+
{%- for message in messages[::-1] %}
|
| 205 |
+
{%- set index = (messages|length - 1) - loop.index0 %}
|
| 206 |
+
{%- if ns.multi_step_tool and message.role == "user" and message.content is string and not(message.content.startswith(tool_result_start) and message.content.endswith(tool_result_end)) %}
|
| 207 |
+
{%- set ns.multi_step_tool = false %}
|
| 208 |
+
{%- set ns.last_query_index = index %}
|
| 209 |
+
{%- endif %}
|
| 210 |
+
{%- endfor %}
|
| 211 |
+
{%- for message in messages %}
|
| 212 |
+
|
| 213 |
+
{%- if message.content is string %}
|
| 214 |
+
{%- set content_ns.content = message.content %}
|
| 215 |
+
{%- elif message.content is iterable %}
|
| 216 |
+
{%- set content_ns.content = '' %}
|
| 217 |
+
{%- for part in message.content %}
|
| 218 |
+
{%- set content_ns.content = content_ns.content + part.text %}
|
| 219 |
+
{%- endfor %}
|
| 220 |
+
{%- else %}
|
| 221 |
+
{%- set content_ns.content = '' %}
|
| 222 |
+
{%- endif %}
|
| 223 |
+
|
| 224 |
+
{%- if message.role == "system" %}
|
| 225 |
+
{{- system_start }}
|
| 226 |
+
|
| 227 |
+
{%- if loop.last and not add_generation_prompt %}
|
| 228 |
+
{%- set end_marker = system_end.rstrip('\n') %}
|
| 229 |
+
{%- else %}
|
| 230 |
+
{%- set end_marker = system_end %}
|
| 231 |
+
{%- endif %}
|
| 232 |
+
|
| 233 |
+
{%- if message.content is string %}
|
| 234 |
+
{{- content_ns.content + end_marker }}
|
| 235 |
+
{%- else %}
|
| 236 |
+
{%- for item in message.content %}
|
| 237 |
+
{%- if item.mask is defined and not item.mask %}
|
| 238 |
+
{%- generation %}
|
| 239 |
+
{{- item.text }}
|
| 240 |
+
{%- if loop.last %}
|
| 241 |
+
{{- end_marker }}
|
| 242 |
+
{%- endif %}
|
| 243 |
+
{%- endgeneration %}
|
| 244 |
+
{%- else %}
|
| 245 |
+
{{- item.text }}
|
| 246 |
+
{%- if loop.last %}
|
| 247 |
+
{{- end_marker }}
|
| 248 |
+
{%- endif %}
|
| 249 |
+
{%- endif %}
|
| 250 |
+
{%- endfor %}
|
| 251 |
+
{%- endif %}
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
{%- elif message.role == "user" %}
|
| 255 |
+
{{- user_start }}
|
| 256 |
+
|
| 257 |
+
{%- if loop.last and not add_generation_prompt %}
|
| 258 |
+
{%- set end_marker = user_end.rstrip('\n') %}
|
| 259 |
+
{%- else %}
|
| 260 |
+
{%- set end_marker = user_end %}
|
| 261 |
+
{%- endif %}
|
| 262 |
+
|
| 263 |
+
{%- if message.content is string %}
|
| 264 |
+
{{- content_ns.content + end_marker }}
|
| 265 |
+
{%- else %}
|
| 266 |
+
{%- for item in message.content %}
|
| 267 |
+
{%- if item.mask is defined and not item.mask %}
|
| 268 |
+
{%- generation %}
|
| 269 |
+
{{- item.text }}
|
| 270 |
+
{%- if loop.last %}
|
| 271 |
+
{{- end_marker }}
|
| 272 |
+
{%- endif %}
|
| 273 |
+
{%- endgeneration %}
|
| 274 |
+
{%- else %}
|
| 275 |
+
{{- item.text }}
|
| 276 |
+
{%- if loop.last %}
|
| 277 |
+
{{- end_marker }}
|
| 278 |
+
{%- endif %}
|
| 279 |
+
{%- endif %}
|
| 280 |
+
{%- endfor %}
|
| 281 |
+
{%- endif %}
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
{%- elif message.role == "assistant" %}
|
| 285 |
+
{%- set reasoning_content = none %}
|
| 286 |
+
{%- if message.reasoning_content is string %}
|
| 287 |
+
{%- set reasoning_content = message.reasoning_content %}
|
| 288 |
+
{%- else %}
|
| 289 |
+
{%- if reasoning_start in content_ns.content %}
|
| 290 |
+
{%- set reasoning_content = content_ns.content.split(reasoning_end)[0].rstrip('\n').split(reasoning_start)[-1].lstrip('\n') %}
|
| 291 |
+
{%- set content = content_ns.content.split(reasoning_end)[-1].lstrip('\n') %}
|
| 292 |
+
{%- endif %}
|
| 293 |
+
{%- endif %}
|
| 294 |
+
|
| 295 |
+
{{- assistant_start }}
|
| 296 |
+
|
| 297 |
+
{%- if loop.index0 > ns.last_query_index %}
|
| 298 |
+
{%- if loop.last and reasoning_content %}
|
| 299 |
+
{%- set reasoning_end_marker = reasoning_end %}
|
| 300 |
+
{%- if content_ns.content is string %}
|
| 301 |
+
{%- set content_ns.content = content_ns.content.lstrip('\n') %}
|
| 302 |
+
{%- if content_ns.content == '' %}
|
| 303 |
+
{%- set reasoning_end_marker = reasoning_end.rstrip('\n') %}
|
| 304 |
+
{%- endif %}
|
| 305 |
+
{%- endif %}
|
| 306 |
+
{%- generation %}
|
| 307 |
+
{{- reasoning_start + reasoning_content.strip('\n') + reasoning_end_marker }}
|
| 308 |
+
{%- endgeneration %}
|
| 309 |
+
{%- endif %}
|
| 310 |
+
{%- endif %}
|
| 311 |
+
|
| 312 |
+
{%- if message.content is string %}
|
| 313 |
+
{%- generation %}
|
| 314 |
+
{{- content_ns.content }}
|
| 315 |
+
{%- endgeneration %}
|
| 316 |
+
{%- else %}
|
| 317 |
+
{%- for item in message.content %}
|
| 318 |
+
{%- if not item.mask is defined or not item.mask %}
|
| 319 |
+
{%- generation %}
|
| 320 |
+
{{- item.text }}
|
| 321 |
+
{%- endgeneration %}
|
| 322 |
+
{%- else %}
|
| 323 |
+
{{- item.text }}
|
| 324 |
+
{%- endif %}
|
| 325 |
+
{%- endfor %}
|
| 326 |
+
{%- endif %}
|
| 327 |
+
{%- generation %}
|
| 328 |
+
{%- if message.tool_calls %}
|
| 329 |
+
{%- for tool_call in message.tool_calls %}
|
| 330 |
+
{%- if tool_call.function %}
|
| 331 |
+
{%- set tool_call = tool_call.function %}
|
| 332 |
+
{%- endif %}
|
| 333 |
+
{%- if (loop.first and content_ns.content) or (not loop.first) %}
|
| 334 |
+
{{- tool_call_start }}
|
| 335 |
+
{%- else %}
|
| 336 |
+
{{- tool_call_start.lstrip('\n') }}
|
| 337 |
+
{%- endif %}
|
| 338 |
+
{%- if tool_call_style == 'json' %}
|
| 339 |
+
{{- json_tool_call_parser(tool_call) }}
|
| 340 |
+
{%- elif tool_call_style == 'python' %}
|
| 341 |
+
{{- python_tool_call_parser(tool_call) }}
|
| 342 |
+
{%- endif %}
|
| 343 |
+
{{- tool_call_end }}
|
| 344 |
+
{%- endfor %}
|
| 345 |
+
{%- endif %}
|
| 346 |
+
{%- endgeneration %}
|
| 347 |
+
{%- if not continue_final_message %}
|
| 348 |
+
{%- if loop.last %}
|
| 349 |
+
{%- set end_marker = assistant_end.rstrip('\n') %}
|
| 350 |
+
{%- else %}
|
| 351 |
+
{%- set end_marker = assistant_end %}
|
| 352 |
+
{%- endif %}
|
| 353 |
+
{%- endif %}
|
| 354 |
+
{%- if message.content is string or (message.content is defined and (not message.content[message.content|length - 1].mask is defined or not message.content[message.content|length - 1].mask)) or (message.tool_calls) %}
|
| 355 |
+
{%- generation%}
|
| 356 |
+
{{- end_marker }}
|
| 357 |
+
{%- endgeneration %}
|
| 358 |
+
{%- else %}
|
| 359 |
+
{{- end_marker }}
|
| 360 |
+
{%- endif %}
|
| 361 |
+
|
| 362 |
+
{%- elif message.role == "tool" %}
|
| 363 |
+
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 364 |
+
{{- tool_result_start }}
|
| 365 |
+
{%- else %}
|
| 366 |
+
{{- tool_result_sep }}
|
| 367 |
+
{%- endif %}
|
| 368 |
+
{{- content_ns.content }}
|
| 369 |
+
{%- if loop.last %}
|
| 370 |
+
{{- tool_result_end.rstrip('\n') }}
|
| 371 |
+
{%- elif (messages[loop.index0 + 1].role != "tool") %}
|
| 372 |
+
{{- tool_result_end.rstrip('\n') }}
|
| 373 |
+
{%- endif %}
|
| 374 |
+
{%- endif %}
|
| 375 |
+
{%- endfor %}
|
| 376 |
+
{%- if add_generation_prompt %}
|
| 377 |
+
{{- assistant_start }}
|
| 378 |
+
{%- if enable_thinking is defined and enable_thinking is true %}
|
| 379 |
+
{%- generation %}
|
| 380 |
+
{{- reasoning_start }}
|
| 381 |
+
{%- endgeneration %}
|
| 382 |
+
{%- endif %}
|
| 383 |
+
{%- endif -%}
|
config.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
{
|
| 2 |
-
"_name_or_path": "
|
| 3 |
"architectures": [
|
| 4 |
"MistralForCausalLM"
|
| 5 |
],
|
| 6 |
"attention_dropout": 0.0,
|
| 7 |
"bos_token_id": 1,
|
| 8 |
-
"eos_token_id":
|
| 9 |
"head_dim": 128,
|
| 10 |
"hidden_act": "silu",
|
| 11 |
"hidden_size": 4096,
|
|
|
|
| 1 |
{
|
| 2 |
+
"_name_or_path": "NyxKrage/Mistral-7B-v0.3",
|
| 3 |
"architectures": [
|
| 4 |
"MistralForCausalLM"
|
| 5 |
],
|
| 6 |
"attention_dropout": 0.0,
|
| 7 |
"bos_token_id": 1,
|
| 8 |
+
"eos_token_id": 11,
|
| 9 |
"head_dim": 128,
|
| 10 |
"hidden_act": "silu",
|
| 11 |
"hidden_size": 4096,
|
generation_config.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 1,
|
| 4 |
-
"eos_token_id":
|
| 5 |
"max_length": 32768,
|
| 6 |
"pad_token_id": 770,
|
| 7 |
"transformers_version": "4.44.2"
|
|
|
|
| 1 |
{
|
| 2 |
"_from_model_config": true,
|
| 3 |
"bos_token_id": 1,
|
| 4 |
+
"eos_token_id": 11,
|
| 5 |
"max_length": 32768,
|
| 6 |
"pad_token_id": 770,
|
| 7 |
"transformers_version": "4.44.2"
|
special_tokens_map.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
| 7 |
"single_word": false
|
| 8 |
},
|
| 9 |
"eos_token": {
|
| 10 |
-
"content": "<
|
| 11 |
"lstrip": false,
|
| 12 |
"normalized": false,
|
| 13 |
"rstrip": false,
|
|
|
|
| 7 |
"single_word": false
|
| 8 |
},
|
| 9 |
"eos_token": {
|
| 10 |
+
"content": "<|im_end|>",
|
| 11 |
"lstrip": false,
|
| 12 |
"normalized": false,
|
| 13 |
"rstrip": false,
|
tokenizer.json
CHANGED
|
@@ -95,7 +95,7 @@
|
|
| 95 |
},
|
| 96 |
{
|
| 97 |
"id": 10,
|
| 98 |
-
"content": "
|
| 99 |
"single_word": false,
|
| 100 |
"lstrip": false,
|
| 101 |
"rstrip": false,
|
|
@@ -104,7 +104,7 @@
|
|
| 104 |
},
|
| 105 |
{
|
| 106 |
"id": 11,
|
| 107 |
-
"content": "
|
| 108 |
"single_word": false,
|
| 109 |
"lstrip": false,
|
| 110 |
"rstrip": false,
|
|
@@ -113,7 +113,7 @@
|
|
| 113 |
},
|
| 114 |
{
|
| 115 |
"id": 12,
|
| 116 |
-
"content": "
|
| 117 |
"single_word": false,
|
| 118 |
"lstrip": false,
|
| 119 |
"rstrip": false,
|
|
@@ -122,7 +122,7 @@
|
|
| 122 |
},
|
| 123 |
{
|
| 124 |
"id": 13,
|
| 125 |
-
"content": "
|
| 126 |
"single_word": false,
|
| 127 |
"lstrip": false,
|
| 128 |
"rstrip": false,
|
|
@@ -131,7 +131,7 @@
|
|
| 131 |
},
|
| 132 |
{
|
| 133 |
"id": 14,
|
| 134 |
-
"content": "
|
| 135 |
"single_word": false,
|
| 136 |
"lstrip": false,
|
| 137 |
"rstrip": false,
|
|
@@ -140,7 +140,7 @@
|
|
| 140 |
},
|
| 141 |
{
|
| 142 |
"id": 15,
|
| 143 |
-
"content": "
|
| 144 |
"single_word": false,
|
| 145 |
"lstrip": false,
|
| 146 |
"rstrip": false,
|
|
@@ -149,7 +149,7 @@
|
|
| 149 |
},
|
| 150 |
{
|
| 151 |
"id": 16,
|
| 152 |
-
"content": "
|
| 153 |
"single_word": false,
|
| 154 |
"lstrip": false,
|
| 155 |
"rstrip": false,
|
|
@@ -158,7 +158,7 @@
|
|
| 158 |
},
|
| 159 |
{
|
| 160 |
"id": 17,
|
| 161 |
-
"content": "
|
| 162 |
"single_word": false,
|
| 163 |
"lstrip": false,
|
| 164 |
"rstrip": false,
|
|
@@ -7048,14 +7048,14 @@
|
|
| 7048 |
"[/AVAILABLE_TOOLS]": 7,
|
| 7049 |
"[TOOL_RESULTS]": 8,
|
| 7050 |
"[/TOOL_RESULTS]": 9,
|
| 7051 |
-
"
|
| 7052 |
-
"
|
| 7053 |
-
"
|
| 7054 |
-
"
|
| 7055 |
-
"
|
| 7056 |
-
"
|
| 7057 |
-
"
|
| 7058 |
-
"
|
| 7059 |
"[control_16]": 18,
|
| 7060 |
"[control_17]": 19,
|
| 7061 |
"[control_18]": 20,
|
|
|
|
| 95 |
},
|
| 96 |
{
|
| 97 |
"id": 10,
|
| 98 |
+
"content": "<|im_start|>",
|
| 99 |
"single_word": false,
|
| 100 |
"lstrip": false,
|
| 101 |
"rstrip": false,
|
|
|
|
| 104 |
},
|
| 105 |
{
|
| 106 |
"id": 11,
|
| 107 |
+
"content": "<|im_end|>",
|
| 108 |
"single_word": false,
|
| 109 |
"lstrip": false,
|
| 110 |
"rstrip": false,
|
|
|
|
| 113 |
},
|
| 114 |
{
|
| 115 |
"id": 12,
|
| 116 |
+
"content": "<|tools_start|>",
|
| 117 |
"single_word": false,
|
| 118 |
"lstrip": false,
|
| 119 |
"rstrip": false,
|
|
|
|
| 122 |
},
|
| 123 |
{
|
| 124 |
"id": 13,
|
| 125 |
+
"content": "<|tools_end|>",
|
| 126 |
"single_word": false,
|
| 127 |
"lstrip": false,
|
| 128 |
"rstrip": false,
|
|
|
|
| 131 |
},
|
| 132 |
{
|
| 133 |
"id": 14,
|
| 134 |
+
"content": "<|tool_start|>",
|
| 135 |
"single_word": false,
|
| 136 |
"lstrip": false,
|
| 137 |
"rstrip": false,
|
|
|
|
| 140 |
},
|
| 141 |
{
|
| 142 |
"id": 15,
|
| 143 |
+
"content": "<|tool_end|>",
|
| 144 |
"single_word": false,
|
| 145 |
"lstrip": false,
|
| 146 |
"rstrip": false,
|
|
|
|
| 149 |
},
|
| 150 |
{
|
| 151 |
"id": 16,
|
| 152 |
+
"content": "<|thinking|>",
|
| 153 |
"single_word": false,
|
| 154 |
"lstrip": false,
|
| 155 |
"rstrip": false,
|
|
|
|
| 158 |
},
|
| 159 |
{
|
| 160 |
"id": 17,
|
| 161 |
+
"content": "<|thinking_end|>",
|
| 162 |
"single_word": false,
|
| 163 |
"lstrip": false,
|
| 164 |
"rstrip": false,
|
|
|
|
| 7048 |
"[/AVAILABLE_TOOLS]": 7,
|
| 7049 |
"[TOOL_RESULTS]": 8,
|
| 7050 |
"[/TOOL_RESULTS]": 9,
|
| 7051 |
+
"<|im_start|>": 10,
|
| 7052 |
+
"<|im_end|>": 11,
|
| 7053 |
+
"<|tools_start|>": 12,
|
| 7054 |
+
"<|tools_end|>": 13,
|
| 7055 |
+
"<|tool_start|>": 14,
|
| 7056 |
+
"<|tool_end|>": 15,
|
| 7057 |
+
"<|thinking|>": 16,
|
| 7058 |
+
"<|thinking_end|>": 17,
|
| 7059 |
"[control_16]": 18,
|
| 7060 |
"[control_17]": 19,
|
| 7061 |
"[control_18]": 20,
|
tokenizer.model
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:93e01cb5f215abfe797344a3b7bf0e874b49708177a8b115bbdde722983e3948
|
| 3 |
+
size 587414
|
tokenizer.model.v3
DELETED
|
Binary file (587 kB)
|
|
|
tokenizer_config.json
CHANGED
|
@@ -84,7 +84,7 @@
|
|
| 84 |
"special": true
|
| 85 |
},
|
| 86 |
"10": {
|
| 87 |
-
"content": "
|
| 88 |
"lstrip": false,
|
| 89 |
"normalized": false,
|
| 90 |
"rstrip": false,
|
|
@@ -92,7 +92,7 @@
|
|
| 92 |
"special": true
|
| 93 |
},
|
| 94 |
"11": {
|
| 95 |
-
"content": "
|
| 96 |
"lstrip": false,
|
| 97 |
"normalized": false,
|
| 98 |
"rstrip": false,
|
|
@@ -100,7 +100,7 @@
|
|
| 100 |
"special": true
|
| 101 |
},
|
| 102 |
"12": {
|
| 103 |
-
"content": "
|
| 104 |
"lstrip": false,
|
| 105 |
"normalized": false,
|
| 106 |
"rstrip": false,
|
|
@@ -108,7 +108,7 @@
|
|
| 108 |
"special": true
|
| 109 |
},
|
| 110 |
"13": {
|
| 111 |
-
"content": "
|
| 112 |
"lstrip": false,
|
| 113 |
"normalized": false,
|
| 114 |
"rstrip": false,
|
|
@@ -116,7 +116,7 @@
|
|
| 116 |
"special": true
|
| 117 |
},
|
| 118 |
"14": {
|
| 119 |
-
"content": "
|
| 120 |
"lstrip": false,
|
| 121 |
"normalized": false,
|
| 122 |
"rstrip": false,
|
|
@@ -124,7 +124,7 @@
|
|
| 124 |
"special": true
|
| 125 |
},
|
| 126 |
"15": {
|
| 127 |
-
"content": "
|
| 128 |
"lstrip": false,
|
| 129 |
"normalized": false,
|
| 130 |
"rstrip": false,
|
|
@@ -132,7 +132,7 @@
|
|
| 132 |
"special": true
|
| 133 |
},
|
| 134 |
"16": {
|
| 135 |
-
"content": "
|
| 136 |
"lstrip": false,
|
| 137 |
"normalized": false,
|
| 138 |
"rstrip": false,
|
|
@@ -140,7 +140,7 @@
|
|
| 140 |
"special": true
|
| 141 |
},
|
| 142 |
"17": {
|
| 143 |
-
"content": "
|
| 144 |
"lstrip": false,
|
| 145 |
"normalized": false,
|
| 146 |
"rstrip": false,
|
|
@@ -6174,7 +6174,7 @@
|
|
| 6174 |
},
|
| 6175 |
"bos_token": "<s>",
|
| 6176 |
"clean_up_tokenization_spaces": false,
|
| 6177 |
-
"eos_token": "<
|
| 6178 |
"legacy": false,
|
| 6179 |
"model_max_length": 1000000000000000019884624838656,
|
| 6180 |
"pad_token": "[control_768]",
|
|
|
|
| 84 |
"special": true
|
| 85 |
},
|
| 86 |
"10": {
|
| 87 |
+
"content": "<|im_start|>",
|
| 88 |
"lstrip": false,
|
| 89 |
"normalized": false,
|
| 90 |
"rstrip": false,
|
|
|
|
| 92 |
"special": true
|
| 93 |
},
|
| 94 |
"11": {
|
| 95 |
+
"content": "<|im_end|>",
|
| 96 |
"lstrip": false,
|
| 97 |
"normalized": false,
|
| 98 |
"rstrip": false,
|
|
|
|
| 100 |
"special": true
|
| 101 |
},
|
| 102 |
"12": {
|
| 103 |
+
"content": "<|tools_start|>",
|
| 104 |
"lstrip": false,
|
| 105 |
"normalized": false,
|
| 106 |
"rstrip": false,
|
|
|
|
| 108 |
"special": true
|
| 109 |
},
|
| 110 |
"13": {
|
| 111 |
+
"content": "<|tools_end|>",
|
| 112 |
"lstrip": false,
|
| 113 |
"normalized": false,
|
| 114 |
"rstrip": false,
|
|
|
|
| 116 |
"special": true
|
| 117 |
},
|
| 118 |
"14": {
|
| 119 |
+
"content": "<|tool_start|>",
|
| 120 |
"lstrip": false,
|
| 121 |
"normalized": false,
|
| 122 |
"rstrip": false,
|
|
|
|
| 124 |
"special": true
|
| 125 |
},
|
| 126 |
"15": {
|
| 127 |
+
"content": "<|tool_end|>",
|
| 128 |
"lstrip": false,
|
| 129 |
"normalized": false,
|
| 130 |
"rstrip": false,
|
|
|
|
| 132 |
"special": true
|
| 133 |
},
|
| 134 |
"16": {
|
| 135 |
+
"content": "<|thinking|>",
|
| 136 |
"lstrip": false,
|
| 137 |
"normalized": false,
|
| 138 |
"rstrip": false,
|
|
|
|
| 140 |
"special": true
|
| 141 |
},
|
| 142 |
"17": {
|
| 143 |
+
"content": "<|thinking_end|>",
|
| 144 |
"lstrip": false,
|
| 145 |
"normalized": false,
|
| 146 |
"rstrip": false,
|
|
|
|
| 6174 |
},
|
| 6175 |
"bos_token": "<s>",
|
| 6176 |
"clean_up_tokenization_spaces": false,
|
| 6177 |
+
"eos_token": "<|im_end|>",
|
| 6178 |
"legacy": false,
|
| 6179 |
"model_max_length": 1000000000000000019884624838656,
|
| 6180 |
"pad_token": "[control_768]",
|