Upload model trained with Unsloth
Browse filesUpload model trained with Unsloth 2x faster
- .gitattributes +1 -0
- chat_template.jinja +206 -0
- special_tokens_map.json +24 -0
- tokenizer.json +3 -0
- tokenizer_config.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{# Unsloth template fixes #}
|
| 2 |
+
{% macro render_extra_keys(json_dict, handled_keys) %}
|
| 3 |
+
{%- if json_dict is mapping %}
|
| 4 |
+
{%- for json_key in json_dict if json_key not in handled_keys %}
|
| 5 |
+
{%- if json_dict[json_key] is mapping or (json_dict[json_key] is sequence and json_dict[json_key] is not string) %}
|
| 6 |
+
{{- '\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | tojson | safe) ~ '</' ~ json_key ~ '>' }}
|
| 7 |
+
{%- else %}
|
| 8 |
+
{{-'\n<' ~ json_key ~ '>' ~ (json_dict[json_key] | string) ~ '</' ~ json_key ~ '>' }}
|
| 9 |
+
{%- endif %}
|
| 10 |
+
{%- endfor %}
|
| 11 |
+
{%- endif %}
|
| 12 |
+
{% endmacro %}
|
| 13 |
+
{%- set enable_thinking = enable_thinking if enable_thinking is defined else True %}
|
| 14 |
+
{%- set truncate_history_thinking = truncate_history_thinking if truncate_history_thinking is defined else True %}
|
| 15 |
+
|
| 16 |
+
{%- set ns = namespace(last_user_idx = -1) %}
|
| 17 |
+
{%- set loop_messages = messages %}
|
| 18 |
+
{%- for m in loop_messages %}
|
| 19 |
+
{%- if m["role"] == "user" %}
|
| 20 |
+
{%- set ns.last_user_idx = loop.index0 %}
|
| 21 |
+
{%- endif %}
|
| 22 |
+
{%- endfor %}
|
| 23 |
+
|
| 24 |
+
{%- if messages[0]["role"] == "system" %}
|
| 25 |
+
{%- set system_message = messages[0]["content"] %}
|
| 26 |
+
{%- set loop_messages = messages[1:] %}
|
| 27 |
+
{%- else %}
|
| 28 |
+
{%- set system_message = "" %}
|
| 29 |
+
{%- set loop_messages = messages %}
|
| 30 |
+
{%- endif %}
|
| 31 |
+
{%- if not tools is defined %}
|
| 32 |
+
{%- set tools = [] %}
|
| 33 |
+
{%- endif %}
|
| 34 |
+
{# Recompute last_user_idx relative to loop_messages after handling system #}
|
| 35 |
+
{%- set ns = namespace(last_user_idx = -1) %}
|
| 36 |
+
{%- for m in loop_messages %}
|
| 37 |
+
{%- if m["role"] == "user" %}
|
| 38 |
+
{%- set ns.last_user_idx = loop.index0 %}
|
| 39 |
+
{%- endif %}
|
| 40 |
+
{%- endfor %}
|
| 41 |
+
{%- if system_message is defined %}
|
| 42 |
+
{{- "<|im_start|>system\n" + system_message }}
|
| 43 |
+
{%- else %}
|
| 44 |
+
{%- if tools is iterable and tools | length > 0 %}
|
| 45 |
+
{{- "<|im_start|>system\n" }}
|
| 46 |
+
{%- endif %}
|
| 47 |
+
{%- endif %}
|
| 48 |
+
{%- if tools is iterable and tools | length > 0 %}
|
| 49 |
+
{%- if system_message is defined and system_message | length > 0 %}
|
| 50 |
+
{{- "\n\n" }}
|
| 51 |
+
{%- endif %}
|
| 52 |
+
{{- "# Tools\n\nYou have access to the following functions:\n\n" }}
|
| 53 |
+
{{- "<tools>" }}
|
| 54 |
+
{%- for tool in tools %}
|
| 55 |
+
{%- if tool.function is defined %}
|
| 56 |
+
{%- set tool = tool.function %}
|
| 57 |
+
{%- endif %}
|
| 58 |
+
{{- "\n<function>\n<name>" ~ tool.name ~ "</name>" }}
|
| 59 |
+
{%- if tool.description is defined %}
|
| 60 |
+
{{- '\n<description>' ~ (tool.description | trim) ~ '</description>' }}
|
| 61 |
+
{%- endif %}
|
| 62 |
+
{{- '\n<parameters>' }}
|
| 63 |
+
{%- if tool.parameters is defined and tool.parameters is mapping and tool.parameters.properties is defined and tool.parameters.properties is mapping %}
|
| 64 |
+
{%- for param_name, param_fields in tool.parameters.properties|items %}
|
| 65 |
+
{{- '\n<parameter>' }}
|
| 66 |
+
{{- '\n<name>' ~ param_name ~ '</name>' }}
|
| 67 |
+
{%- if param_fields.type is defined %}
|
| 68 |
+
{{- '\n<type>' ~ (param_fields.type | string) ~ '</type>' }}
|
| 69 |
+
{%- endif %}
|
| 70 |
+
{%- if param_fields.description is defined %}
|
| 71 |
+
{{- '\n<description>' ~ (param_fields.description | trim) ~ '</description>' }}
|
| 72 |
+
{%- endif %}
|
| 73 |
+
{%- if param_fields.enum is defined %}
|
| 74 |
+
{{- '\n<enum>' ~ (param_fields.enum | tojson | safe) ~ '</enum>' }}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- set handled_keys = ['name', 'type', 'description', 'enum'] %}
|
| 77 |
+
{{- render_extra_keys(param_fields, handled_keys) }}
|
| 78 |
+
{{- '\n</parameter>' }}
|
| 79 |
+
{%- endfor %}
|
| 80 |
+
{%- endif %}
|
| 81 |
+
{% set handled_keys = ['type', 'properties', 'required'] %}
|
| 82 |
+
{{- render_extra_keys(tool.parameters, handled_keys) }}
|
| 83 |
+
{%- if tool.parameters is defined and tool.parameters.required is defined %}
|
| 84 |
+
{{- '\n<required>' ~ (tool.parameters.required | tojson | safe) ~ '</required>' }}
|
| 85 |
+
{%- endif %}
|
| 86 |
+
{{- '\n</parameters>' }}
|
| 87 |
+
{%- set handled_keys = ['type', 'name', 'description', 'parameters'] %}
|
| 88 |
+
{{- render_extra_keys(tool, handled_keys) }}
|
| 89 |
+
{{- '\n</function>' }}
|
| 90 |
+
{%- endfor %}
|
| 91 |
+
{{- "\n</tools>" }}
|
| 92 |
+
|
| 93 |
+
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 94 |
+
{%- endif %}
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
{%- if system_message is defined %}
|
| 98 |
+
{{- '<|im_end|>\n' }}
|
| 99 |
+
{%- else %}
|
| 100 |
+
{%- if tools is iterable and tools | length > 0 %}
|
| 101 |
+
{{- '<|im_end|>\n' }}
|
| 102 |
+
{%- endif %}
|
| 103 |
+
{%- endif %}
|
| 104 |
+
|
| 105 |
+
{%- for message in loop_messages %}
|
| 106 |
+
{%- if message.role == "assistant" %}
|
| 107 |
+
{# Add reasoning content in to content field for unified processing below. #}
|
| 108 |
+
{%- if message.reasoning_content is defined and message.reasoning_content is string and message.reasoning_content | trim | length > 0 %}
|
| 109 |
+
{%- set content = "<think>\n" ~ message.reasoning_content ~ "\n</think>\n" ~ (message.content | default('', true)) %}
|
| 110 |
+
{%- else %}
|
| 111 |
+
{%- set content = message.content | default('', true) %}
|
| 112 |
+
{%- if content is string -%}
|
| 113 |
+
{# Allow downstream logic to to take care of broken thought, only handle coherent reasoning here. #}
|
| 114 |
+
{%- if '<think>' not in content and '</think>' not in content -%}
|
| 115 |
+
{%- set content = "<think></think>" ~ content -%}
|
| 116 |
+
{%- endif -%}
|
| 117 |
+
{%- else -%}
|
| 118 |
+
{%- set content = content -%}
|
| 119 |
+
{%- endif -%}
|
| 120 |
+
{%- endif %}
|
| 121 |
+
{%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
|
| 122 |
+
{# Assistant message has tool calls. #}
|
| 123 |
+
{{- '<|im_start|>assistant\n' }}
|
| 124 |
+
{%- set include_content = not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
|
| 125 |
+
{%- if content is string and content | trim | length > 0 %}
|
| 126 |
+
{%- if include_content %}
|
| 127 |
+
{{- (content | trim) ~ '\n' -}}
|
| 128 |
+
{%- else %}
|
| 129 |
+
{%- set c = (content | string) %}
|
| 130 |
+
{%- if '</think>' in c %}
|
| 131 |
+
{# Keep only content after the last closing think. Also generation prompt causes this. #}
|
| 132 |
+
{%- set c = (c.split('</think>')|last) %}
|
| 133 |
+
{%- elif '<think>' in c %}
|
| 134 |
+
{# If <think> was opened but never closed, drop the trailing think segment #}
|
| 135 |
+
{%- set c = (c.split('<think>')|first) %}
|
| 136 |
+
{%- endif %}
|
| 137 |
+
{%- set c = "<think></think>" ~ c | trim %}
|
| 138 |
+
{%- if c | length > 0 %}
|
| 139 |
+
{{- c ~ '\n' -}}
|
| 140 |
+
{%- endif %}
|
| 141 |
+
{%- endif %}
|
| 142 |
+
{%- else %}
|
| 143 |
+
{{- "<think></think>" -}}
|
| 144 |
+
{%- endif %}
|
| 145 |
+
{%- for tool_call in message.tool_calls %}
|
| 146 |
+
{%- if tool_call.function is defined %}
|
| 147 |
+
{%- set tool_call = tool_call.function %}
|
| 148 |
+
{%- endif %}
|
| 149 |
+
{{- '<tool_call>\n<function=' ~ tool_call.name ~ '>\n' -}}
|
| 150 |
+
{%- if tool_call.arguments is defined %}{%- if tool_call.arguments is mapping %}
|
| 151 |
+
{%- for args_name, args_value in tool_call.arguments|items %}
|
| 152 |
+
{{- '<parameter=' ~ args_name ~ '>\n' -}}
|
| 153 |
+
{%- set args_value = args_value | tojson | safe if args_value is mapping or (args_value is sequence and args_value is not string) else args_value | string %}
|
| 154 |
+
{{- args_value ~ '\n</parameter>\n' -}}
|
| 155 |
+
{%- endfor %}{%- endif %}
|
| 156 |
+
{%- endif %}
|
| 157 |
+
{{- '</function>\n</tool_call>\n' -}}
|
| 158 |
+
{%- endfor %}
|
| 159 |
+
{{- '<|im_end|>\n' }}
|
| 160 |
+
{%- else %}
|
| 161 |
+
{# Assistant message doesn't have tool calls. #}
|
| 162 |
+
{%- if not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
|
| 163 |
+
{{- '<|im_start|>assistant\n' ~ (content | default('', true) | string | trim) ~ '<|im_end|>\n' }}
|
| 164 |
+
{%- else %}
|
| 165 |
+
{%- set c = (content | default('', true) | string) %}
|
| 166 |
+
{%- if '<think>' in c and '</think>' in c %}
|
| 167 |
+
{%- set c = "<think></think>" ~ (c.split('</think>')|last) %}
|
| 168 |
+
{%- endif %}
|
| 169 |
+
{%- set c = c | trim %}
|
| 170 |
+
{%- if c | length > 0 %}
|
| 171 |
+
{{- '<|im_start|>assistant\n' ~ c ~ '<|im_end|>\n' }}
|
| 172 |
+
{%- else %}
|
| 173 |
+
{{- '<|im_start|>assistant\n<|im_end|>\n' }}
|
| 174 |
+
{%- endif %}
|
| 175 |
+
{%- endif %}
|
| 176 |
+
{%- endif %}
|
| 177 |
+
{%- elif message.role == "user" or message.role == "system" %}
|
| 178 |
+
{{- '<|im_start|>' + message.role + '\n' }}
|
| 179 |
+
{%- set content = message.content | string %}
|
| 180 |
+
{{- content }}
|
| 181 |
+
{{- '<|im_end|>\n' }}
|
| 182 |
+
{%- elif message.role == "tool" %}
|
| 183 |
+
{%- if loop.previtem and loop.previtem.role != "tool" %}
|
| 184 |
+
{{- '<|im_start|>user\n' }}
|
| 185 |
+
{%- endif %}
|
| 186 |
+
{{- '<tool_response>\n' }}
|
| 187 |
+
{{- message.content }}
|
| 188 |
+
{{- '\n</tool_response>\n' }}
|
| 189 |
+
{%- if not loop.last and loop.nextitem.role != "tool" %}
|
| 190 |
+
{{- '<|im_end|>\n' }}
|
| 191 |
+
{%- elif loop.last %}
|
| 192 |
+
{{- '<|im_end|>\n' }}
|
| 193 |
+
{%- endif %}
|
| 194 |
+
{%- else %}
|
| 195 |
+
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
|
| 196 |
+
{%- endif %}
|
| 197 |
+
{%- endfor %}
|
| 198 |
+
|
| 199 |
+
{%- if add_generation_prompt %}
|
| 200 |
+
{%- if enable_thinking %}
|
| 201 |
+
{{- '<|im_start|>assistant\n<think>\n' }}
|
| 202 |
+
{%- else %}
|
| 203 |
+
{{- '<|im_start|>assistant\n<think></think>' }}
|
| 204 |
+
{%- endif %}
|
| 205 |
+
{%- endif %}
|
| 206 |
+
{# Copyright 2025-present Unsloth. Apache 2.0 License. #}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "<|im_end|>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": "<SPECIAL_999>",
|
| 17 |
+
"unk_token": {
|
| 18 |
+
"content": "<unk>",
|
| 19 |
+
"lstrip": false,
|
| 20 |
+
"normalized": false,
|
| 21 |
+
"rstrip": false,
|
| 22 |
+
"single_word": false
|
| 23 |
+
}
|
| 24 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:623c34567aebb18582765289fbe23d901c62704d6518d71866e0e58db892b5b7
|
| 3 |
+
size 17077484
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|