hf-transformers-bot commited on
Commit
41b014d
·
verified ·
1 Parent(s): f9ac72a

Update tiny models for HYV3ForCausalLM

Browse files
chat_template.jinja ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {#- ----------‑‑‑ special token variables ‑‑‑---------- -#}
2
+ {%- set bos_token = '<|hy_begin▁of▁sentence|>' %}
3
+ {%- set pad_token = '<|hy_▁pad▁|>' %}
4
+ {%- set user_token = '<|hy_User|>' %}
5
+ {%- set assistant_token = '<|hy_Assistant|>' %}
6
+ {%- set eos_token = '<|hy_eos|>' %}
7
+ {%- set think_begin_token = '<think>' %}
8
+ {%- set think_end_token = '</think>' %}
9
+ {%- set toolcalls_begin_token = '<tool_calls>' %}
10
+ {%- set toolcalls_end_token = '</tool_calls>' %}
11
+ {%- set toolcall_begin_token = '<tool_call>' %}
12
+ {%- set toolcall_end_token = '</tool_call>' %}
13
+ {%- set toolsep_token = '<tool_sep>' %}
14
+ {%- set argkey_begin_token = '<arg_key>' %}
15
+ {%- set argkey_end_token = '</arg_key>' %}
16
+ {%- set argvalue_begin_token = '<arg_value>' %}
17
+ {%- set argvalue_end_token = '</arg_value>' %}
18
+ {%- set toolresponses_begin_token = '<tool_responses>' %}
19
+ {%- set toolresponses_end_token = '</tool_responses>' %}
20
+ {%- set toolresponse_begin_token = '<tool_response>' %}
21
+ {%- set toolresponse_end_token = '</tool_response>' %}
22
+ {%- set reasoning_mode_token = '<|reasoning_mode|>' %}
23
+ {#- ----------‑‑‑ hyperparameters variables ‑‑‑---------- -#}
24
+ {%- if not add_generation_prompt is defined %}
25
+ {%- set add_generation_prompt = false %}
26
+ {%- endif %}
27
+ {%- if not interleaved_thinking is defined %}
28
+ {%- set interleaved_thinking = false %}
29
+ {%- endif %}
30
+ {%- if not tools %}
31
+ {%- set interleaved_thinking = false %}
32
+ {%- endif %}
33
+ {%- if not is_training is defined %}
34
+ {%- set is_training = false %}
35
+ {%- endif %}
36
+ {%- if not reasoning_effort is defined or reasoning_effort not in ['high', 'low', 'no_think'] %}
37
+ {%- set reasoning_effort = 'no_think' %}
38
+ {%- endif %}
39
+
40
+ {%- macro visible_text(content) -%}
41
+ {%- if content is string -%}
42
+ {{- content }}
43
+ {%- elif content is iterable and content is not mapping -%}
44
+ {%- for item in content -%}
45
+ {%- if item is mapping and item.type == 'text' -%}
46
+ {{- item.text }}
47
+ {%- elif item is string -%}
48
+ {{- item }}
49
+ {%- endif -%}
50
+ {%- endfor -%}
51
+ {%- elif content is none -%}
52
+ {{- '' }}
53
+ {%- else -%}
54
+ {{- content }}
55
+ {%- endif -%}
56
+ {%- endmacro -%}
57
+
58
+ {%- set ns = namespace(last_user_index=-1) %}
59
+ {%- set sp_ns = namespace(system_prompt='', is_first_sp=true) %}
60
+ {%- for message in messages %}
61
+ {%- if message['role'] == 'system' %}
62
+ {%- set sp_ns.system_prompt = sp_ns.system_prompt + visible_text(message['content']) %}
63
+ {%- endif %}
64
+ {%- if message['role'] == 'user' %}
65
+ {%- set ns.last_user_index = loop.index0 %}
66
+ {%- endif %}
67
+ {%- endfor %}
68
+ {%- if reasoning_effort is defined and reasoning_effort is string and reasoning_effort != '' and not tools %}
69
+ {%- set sp_ns.system_prompt = sp_ns.system_prompt + reasoning_mode_token + 'reasoning_effort:' + reasoning_effort %}
70
+ {%- endif %}
71
+ {{- bos_token }}
72
+ {{- sp_ns.system_prompt }}
73
+ {%- if tools %}
74
+ {%- if sp_ns.system_prompt != '' %}
75
+ {{- '\n\n# Tools\n\nYou may call one or more functions to assist with the user query.' }}
76
+ {%- else %}
77
+ {{- '# Tools\n\nYou may call one or more functions to assist with the user query.' }}
78
+ {%- endif %}
79
+ {{- '\n\nYou are provided with function signatures within <tools></tools> XML tags:' }}
80
+ {{- '\n<tools>\n' }}
81
+ {%- for tool in tools %}
82
+ {%- if loop.index0 > 0 %}
83
+ {{- '\n' }}
84
+ {%- endif %}
85
+ {{- tool | tojson }}
86
+ {%- endfor %}
87
+ {{- '\n</tools>\n\n' }}
88
+ {{- 'For function call returns, you should first print ' + toolcalls_begin_token + '\n' }}
89
+ {{- 'For each function call, you should return object like:\n' }}
90
+ {{- toolcall_begin_token + '{function-name}' + toolsep_token + '\n' }}
91
+ {{- argkey_begin_token + '{arg-key-1}' + argkey_end_token + '\n' }}
92
+ {{- argvalue_begin_token + '{arg-value-1}' + argvalue_end_token + '\n' }}
93
+ {{- argkey_begin_token + '{arg-key-2}' + argkey_end_token + '\n' }}
94
+ {{- argvalue_begin_token + '{arg-value-2}' + argvalue_end_token + '\n' }}
95
+ {{- '...\n' }}
96
+ {{- toolcall_end_token + '\n' }}
97
+ {%- if reasoning_effort is defined and reasoning_effort is string and reasoning_effort != '' %}
98
+ {{- 'At the end of function call returns, you should print ' + toolcalls_end_token + reasoning_mode_token + 'reasoning_effort:' + reasoning_effort }}
99
+ {%- else %}
100
+ {{- 'At the end of function call returns, you should print ' + toolcalls_end_token }}
101
+ {%- endif %}
102
+ {%- endif %}
103
+
104
+ {%- set prev_ns = namespace(is_tool=false, is_tool_first=true) %}
105
+ {%- set last_ns = namespace(last_is_assistant=false) %}
106
+ {%- for message in messages %}
107
+ {%- if message['role'] == 'user' %}
108
+ {%- if prev_ns.is_tool %}
109
+ {{- toolresponses_end_token }}
110
+ {%- endif %}
111
+ {{- user_token + visible_text(message['content']) }}
112
+ {%- set prev_ns.is_tool = false %}
113
+ {%- endif %}
114
+ {%- if message['role'] == 'assistant' %}
115
+ {%- if 'reasoning_content' in message and message['reasoning_content'] is string %}
116
+ {%- set rc = message['reasoning_content'] %}
117
+ {%- elif 'reasoning' in message and message['reasoning'] is string %}
118
+ {%- set rc = message['reasoning'] %}
119
+ {%- else %}
120
+ {%- set rc = none %}
121
+ {%- endif %}
122
+ {%- if is_training %}
123
+ {%- if rc is not none %}
124
+ {%- set content = think_begin_token + rc + think_end_token + visible_text(message['content']) %}
125
+ {%- else %}
126
+ {%- set content = think_begin_token + think_end_token + visible_text(message['content']) %}
127
+ {%- endif %}
128
+ {%- else %}
129
+ {%- if interleaved_thinking %}
130
+ {%- if loop.index0 > ns.last_user_index and rc is not none %}
131
+ {%- set content = think_begin_token + rc + think_end_token + visible_text(message['content']) %}
132
+ {%- else %}
133
+ {%- set content = think_begin_token + think_end_token + visible_text(message['content']) %}
134
+ {%- endif %}
135
+ {%- else %}
136
+ {%- set content = think_begin_token + think_end_token + visible_text(message['content']) %}
137
+ {%- endif %}
138
+ {%- endif %}
139
+ {%- if prev_ns.is_tool %}
140
+ {{- toolresponses_end_token }}
141
+ {%- endif %}
142
+ {{- assistant_token }}
143
+ {%- if message['tool_calls'] is defined and message['tool_calls'] %}
144
+ {%- set prev_ns.is_tool_first = true %}
145
+ {{- content }}
146
+ {{- toolcalls_begin_token + '\n' }}
147
+ {%- for tool in message['tool_calls'] %}
148
+ {%- set arguments = tool['function']['arguments'] %}
149
+ {{- toolcall_begin_token + tool['function']['name'] + toolsep_token + '\n' }}
150
+ {%- for key, value in arguments.items() %}
151
+ {{- argkey_begin_token + key + argkey_end_token + '\n' }}
152
+ {%- if value is not string %}
153
+ {%- set value = value | tojson(ensure_ascii=False) %}
154
+ {%- endif %}
155
+ {{- argvalue_begin_token + value + argvalue_end_token + '\n' }}
156
+ {%- endfor %}
157
+ {{- toolcall_end_token + '\n' }}
158
+ {%- endfor %}
159
+ {{- toolcalls_end_token + eos_token }}
160
+ {%- else %}
161
+ {%- if not loop.last or is_training %}
162
+ {{- content + eos_token }}
163
+ {%- else %}
164
+ {{- content }}
165
+ {%- endif %}
166
+ {%- endif %}
167
+ {%- set prev_ns.is_tool = false %}
168
+ {%- endif %}
169
+ {%- if message['role'] == 'tool' %}
170
+ {%- set prev_ns.is_tool = true %}
171
+ {%- if prev_ns.is_tool_first %}
172
+ {{- toolresponses_begin_token + '\n' }}
173
+ {%- set prev_ns.is_tool_first = false %}
174
+ {%- endif %}
175
+ {{- toolresponse_begin_token + '\n' + visible_text(message['content']) + '\n' + toolresponse_end_token + '\n' }}
176
+ {%- endif %}
177
+ {%- if loop.last and message['role'] == 'assistant' %}
178
+ {%- set last_ns.last_is_assistant = true %}
179
+ {%- endif %}
180
+
181
+ {%- endfor %}
182
+ {%- if prev_ns.is_tool %}
183
+ {{- toolresponses_end_token }}
184
+ {%- endif %}
185
+ {%- if add_generation_prompt %}
186
+ {%- if not last_ns.last_is_assistant %}
187
+ {%- if reasoning_effort is defined and reasoning_effort in ['low', 'high'] %}
188
+ {{- assistant_token + think_begin_token }}
189
+ {%- elif reasoning_effort is defined and reasoning_effort == 'no_think' %}
190
+ {{- assistant_token + think_begin_token + think_end_token }}
191
+ {%- else %}
192
+ {{- assistant_token }}
193
+ {%- endif %}
194
+ {%- endif %}
195
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "HYV3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 120000,
8
+ "dtype": "float32",
9
+ "enable_moe_fp32_combine": true,
10
+ "eos_token_id": 120025,
11
+ "head_dim": 16,
12
+ "hidden_act": "gelu",
13
+ "hidden_size": 32,
14
+ "initializer_range": 0.02,
15
+ "intermediate_size": 32,
16
+ "is_decoder": true,
17
+ "max_position_embeddings": 512,
18
+ "mlp_bias": false,
19
+ "mlp_layer_types": [
20
+ "dense",
21
+ "sparse"
22
+ ],
23
+ "model_type": "hy_v3",
24
+ "moe_intermediate_size": 16,
25
+ "num_attention_heads": 2,
26
+ "num_experts": 8,
27
+ "num_experts_per_tok": 2,
28
+ "num_hidden_layers": 2,
29
+ "num_key_value_heads": 2,
30
+ "num_shared_experts": 1,
31
+ "output_router_logits": false,
32
+ "pad_token_id": 120002,
33
+ "rms_norm_eps": 1e-05,
34
+ "rope_parameters": {
35
+ "rope_theta": 11158840.0,
36
+ "rope_type": "default"
37
+ },
38
+ "router_scaling_factor": 2.826,
39
+ "tie_word_embeddings": false,
40
+ "transformers_version": "5.16.0.dev0",
41
+ "use_cache": true,
42
+ "vocab_size": 120818
43
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 120000,
4
+ "eos_token_id": 120025,
5
+ "output_attentions": false,
6
+ "output_hidden_states": false,
7
+ "pad_token_id": 120002,
8
+ "transformers_version": "5.16.0.dev0",
9
+ "use_cache": true
10
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4df0b83a88147ebd1ecfc5326d464f35a96b6e20d3ba12c7dd69a9d219dc8190
3
+ size 31037344
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|hy_begin▁of▁sentence|>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "eos_token": "<|hy_eos|>",
6
+ "is_local": true,
7
+ "local_files_only": false,
8
+ "model_max_length": 512,
9
+ "pad_token": "<|hy_▁pad▁|>",
10
+ "tokenizer_class": "TokenizersBackend"
11
+ }