danielhanchen commited on
Commit
76256af
·
verified ·
1 Parent(s): 861dc4d

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. chat_template.jinja +10 -8
  2. config.json +2 -2
  3. tokenizer_config.json +1 -1
chat_template.jinja CHANGED
@@ -1,3 +1,4 @@
 
1
  [gMASK]<sop>
2
  {%- if tools -%}
3
  <|system|>
@@ -8,7 +9,7 @@ You may call one or more functions to assist with the user query.
8
  You are provided with function signatures within <tools></tools> XML tags:
9
  <tools>
10
  {% for tool in tools %}
11
- {{ tool | tojson|string }}
12
  {% endfor %}
13
  </tools>
14
 
@@ -53,8 +54,8 @@ For each function call, output the function name and arguments within the follow
53
  {%- set reasoning_content = m.reasoning_content %}
54
  {%- else %}
55
  {%- if '</think>' in content %}
56
- {%- set reasoning_content = ((content.split('</think>')|first).rstrip('\n').split('<think>')|last).lstrip('\n') %}
57
- {%- set content = (content.split('</think>')|last).lstrip('\n') %}
58
  {%- endif %}
59
  {%- endif %}
60
  {%- if loop.index0 > ns.last_user_index and reasoning_content -%}
@@ -71,11 +72,11 @@ For each function call, output the function name and arguments within the follow
71
  {%- set tc = tc.function %}
72
  {%- endif %}
73
  {{ '\n<tool_call>' + tc.name }}
74
- {% set _args = tc.arguments %}
75
- {% for k, v in _args.items() %}
76
  <arg_key>{{ k }}</arg_key>
77
- <arg_value>{{ v | tojson|string if v is not string else v }}</arg_value>
78
- {% endfor %}
79
  </tool_call>{% endfor %}
80
  {% endif %}
81
  {%- elif m.role == 'tool' -%}
@@ -100,4 +101,5 @@ For each function call, output the function name and arguments within the follow
100
  {%- endfor -%}
101
  {%- if add_generation_prompt -%}
102
  <|assistant|>{{- '\n<think></think>' if (enable_thinking is defined and not enable_thinking) else '' -}}
103
- {%- endif -%}
 
 
1
+ {# Unsloth template fixes #}
2
  [gMASK]<sop>
3
  {%- if tools -%}
4
  <|system|>
 
9
  You are provided with function signatures within <tools></tools> XML tags:
10
  <tools>
11
  {% for tool in tools %}
12
+ {{ tool | tojson(ensure_ascii=False) }}
13
  {% endfor %}
14
  </tools>
15
 
 
54
  {%- set reasoning_content = m.reasoning_content %}
55
  {%- else %}
56
  {%- if '</think>' in content %}
57
+ {%- set reasoning_content = content.split('</think>')[0].rstrip('\n').split('<think>')[-1].lstrip('\n') %}
58
+ {%- set content = content.split('</think>')[-1].lstrip('\n') %}
59
  {%- endif %}
60
  {%- endif %}
61
  {%- if loop.index0 > ns.last_user_index and reasoning_content -%}
 
72
  {%- set tc = tc.function %}
73
  {%- endif %}
74
  {{ '\n<tool_call>' + tc.name }}
75
+ {% set _args = tc.arguments %}{% if _args is mapping %}
76
+ {% for k, v in _args|items %}
77
  <arg_key>{{ k }}</arg_key>
78
+ <arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>
79
+ {% endfor %}{%- endif %}
80
  </tool_call>{% endfor %}
81
  {% endif %}
82
  {%- elif m.role == 'tool' -%}
 
101
  {%- endfor -%}
102
  {%- if add_generation_prompt -%}
103
  <|assistant|>{{- '\n<think></think>' if (enable_thinking is defined and not enable_thinking) else '' -}}
104
+ {%- endif -%}
105
+ {# Copyright 2025-present Unsloth. Apache 2.0 License. #}
config.json CHANGED
@@ -4,6 +4,7 @@
4
  ],
5
  "attention_bias": true,
6
  "attention_dropout": 0.0,
 
7
  "eos_token_id": [
8
  151329,
9
  151336,
@@ -35,8 +36,7 @@
35
  "routed_scaling_factor": 1.0,
36
  "tie_word_embeddings": false,
37
  "topk_group": 1,
38
- "torch_dtype": "bfloat16",
39
- "transformers_version": "4.54.1",
40
  "unsloth_fixed": true,
41
  "use_cache": true,
42
  "use_qk_norm": false,
 
4
  ],
5
  "attention_bias": true,
6
  "attention_dropout": 0.0,
7
+ "torch_dtype": "bfloat16",
8
  "eos_token_id": [
9
  151329,
10
  151336,
 
36
  "routed_scaling_factor": 1.0,
37
  "tie_word_embeddings": false,
38
  "topk_group": 1,
39
+ "transformers_version": "4.57.3",
 
40
  "unsloth_fixed": true,
41
  "use_cache": true,
42
  "use_qk_norm": false,
tokenizer_config.json CHANGED
@@ -324,5 +324,5 @@
324
  "remove_space": false,
325
  "tokenizer_class": "PreTrainedTokenizerFast",
326
  "unk_token": null,
327
- "chat_template": "[gMASK]<sop>\n{%- if tools -%}\n<|system|>\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{{ tool | tojson|string }}\n{% endfor %}\n</tools>\n\nFor each function call, output the function name and arguments within the following XML format:\n<tool_call>{function-name}\n<arg_key>{arg-key-1}</arg_key>\n<arg_value>{arg-value-1}</arg_value>\n<arg_key>{arg-key-2}</arg_key>\n<arg_value>{arg-value-2}</arg_value>\n...\n</tool_call>{%- endif -%}\n{%- macro visible_text(content) -%}\n {%- if content is string -%}\n {{- content }}\n {%- elif content is iterable and content is not mapping -%}\n {%- for item in content -%}\n {%- if item is mapping and item.type == 'text' -%}\n {{- item.text }}\n {%- elif item is string -%}\n {{- item }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{- content }}\n {%- endif -%}\n{%- endmacro -%}\n{%- set ns = namespace(last_user_index=-1) %}\n{%- for m in messages %}\n {%- if m.role == 'user' %}\n {% set ns.last_user_index = loop.index0 -%}\n {%- endif %}\n{%- endfor %}\n{% for m in messages %}\n{%- if m.role == 'user' -%}<|user|>\n{{ visible_text(m.content) }}\n{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith(\"/nothink\")) else '' -}}\n{%- elif m.role == 'assistant' -%}\n<|assistant|>\n{%- set reasoning_content = '' %}\n{%- set content = visible_text(m.content) %}\n{%- if m.reasoning_content is string %}\n {%- set reasoning_content = m.reasoning_content %}\n{%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = ((content.split('</think>')|first).rstrip('\\n').split('<think>')|last).lstrip('\\n') %}\n {%- set content = (content.split('</think>')|last).lstrip('\\n') %}\n {%- endif %}\n{%- endif %}\n{%- if loop.index0 > ns.last_user_index and reasoning_content -%}\n{{ '\\n<think>' + reasoning_content.strip() + '</think>'}}\n{%- else -%}\n{{ '\\n<think></think>' }}\n{%- endif -%}\n{%- if content.strip() -%}\n{{ '\\n' + content.strip() }}\n{%- endif -%}\n{% if m.tool_calls %}\n{% for tc in m.tool_calls %}\n{%- if tc.function %}\n {%- set tc = tc.function %}\n{%- endif %}\n{{ '\\n<tool_call>' + tc.name }}\n{% set _args = tc.arguments %}\n{% for k, v in _args.items() %}\n<arg_key>{{ k }}</arg_key>\n<arg_value>{{ v | tojson|string if v is not string else v }}</arg_value>\n{% endfor %}\n</tool_call>{% endfor %}\n{% endif %}\n{%- elif m.role == 'tool' -%}\n{%- if m.content is string -%}\n{%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|observation|>' }}\n{%- endif %}\n{{- '\\n<tool_response>\\n' }}\n{{- m.content }}\n{{- '\\n</tool_response>' }}\n{%- else -%}\n<|observation|>{% for tr in m.content %}\n\n<tool_response>\n{{ tr.output if tr.output is defined else tr }}\n</tool_response>{% endfor -%}\n{% endif -%}\n{%- elif m.role == 'system' -%}\n<|system|>\n{{ visible_text(m.content) }}\n{%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n <|assistant|>{{- '\\n<think></think>' if (enable_thinking is defined and not enable_thinking) else '' -}}\n{%- endif -%}"
328
  }
 
324
  "remove_space": false,
325
  "tokenizer_class": "PreTrainedTokenizerFast",
326
  "unk_token": null,
327
+ "chat_template": "{# Unsloth template fixes #}\n[gMASK]<sop>\n{%- if tools -%}\n<|system|>\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{{ tool | tojson(ensure_ascii=False) }}\n{% endfor %}\n</tools>\n\nFor each function call, output the function name and arguments within the following XML format:\n<tool_call>{function-name}\n<arg_key>{arg-key-1}</arg_key>\n<arg_value>{arg-value-1}</arg_value>\n<arg_key>{arg-key-2}</arg_key>\n<arg_value>{arg-value-2}</arg_value>\n...\n</tool_call>{%- endif -%}\n{%- macro visible_text(content) -%}\n {%- if content is string -%}\n {{- content }}\n {%- elif content is iterable and content is not mapping -%}\n {%- for item in content -%}\n {%- if item is mapping and item.type == 'text' -%}\n {{- item.text }}\n {%- elif item is string -%}\n {{- item }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{- content }}\n {%- endif -%}\n{%- endmacro -%}\n{%- set ns = namespace(last_user_index=-1) %}\n{%- for m in messages %}\n {%- if m.role == 'user' %}\n {% set ns.last_user_index = loop.index0 -%}\n {%- endif %}\n{%- endfor %}\n{% for m in messages %}\n{%- if m.role == 'user' -%}<|user|>\n{{ visible_text(m.content) }}\n{{- '/nothink' if (enable_thinking is defined and not enable_thinking and not visible_text(m.content).endswith(\"/nothink\")) else '' -}}\n{%- elif m.role == 'assistant' -%}\n<|assistant|>\n{%- set reasoning_content = '' %}\n{%- set content = visible_text(m.content) %}\n{%- if m.reasoning_content is string %}\n {%- set reasoning_content = m.reasoning_content %}\n{%- else %}\n {%- if '</think>' in content %}\n {%- set reasoning_content = content.split('</think>')[0].rstrip('\\n').split('<think>')[-1].lstrip('\\n') %}\n {%- set content = content.split('</think>')[-1].lstrip('\\n') %}\n {%- endif %}\n{%- endif %}\n{%- if loop.index0 > ns.last_user_index and reasoning_content -%}\n{{ '\\n<think>' + reasoning_content.strip() + '</think>'}}\n{%- else -%}\n{{ '\\n<think></think>' }}\n{%- endif -%}\n{%- if content.strip() -%}\n{{ '\\n' + content.strip() }}\n{%- endif -%}\n{% if m.tool_calls %}\n{% for tc in m.tool_calls %}\n{%- if tc.function %}\n {%- set tc = tc.function %}\n{%- endif %}\n{{ '\\n<tool_call>' + tc.name }}\n{% set _args = tc.arguments %}{% if _args is mapping %}\n{% for k, v in _args|items %}\n<arg_key>{{ k }}</arg_key>\n<arg_value>{{ v | tojson(ensure_ascii=False) if v is not string else v }}</arg_value>\n{% endfor %}{%- endif %}\n</tool_call>{% endfor %}\n{% endif %}\n{%- elif m.role == 'tool' -%}\n{%- if m.content is string -%}\n{%- if loop.first or (messages[loop.index0 - 1].role != \"tool\") %}\n {{- '<|observation|>' }}\n{%- endif %}\n{{- '\\n<tool_response>\\n' }}\n{{- m.content }}\n{{- '\\n</tool_response>' }}\n{%- else -%}\n<|observation|>{% for tr in m.content %}\n\n<tool_response>\n{{ tr.output if tr.output is defined else tr }}\n</tool_response>{% endfor -%}\n{% endif -%}\n{%- elif m.role == 'system' -%}\n<|system|>\n{{ visible_text(m.content) }}\n{%- endif -%}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n <|assistant|>{{- '\\n<think></think>' if (enable_thinking is defined and not enable_thinking) else '' -}}\n{%- endif -%}\n{# Copyright 2025-present Unsloth. Apache 2.0 License. #}"
328
  }