hf-transformers-bot commited on
Commit
1f93be2
·
verified ·
1 Parent(s): 916edb5

Update tiny models for Lfm2MoeForCausalLM

Browse files
chat_template.jinja ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{- bos_token -}}
2
+ {%- macro format_arg_value(arg_value) -%}
3
+ {%- if arg_value is string -%}
4
+ {{- "'" + (arg_value | replace("\\", "\\\\") | replace("'", "\\'") | replace("\n", "\\n") | replace("\r", "\\r")) + "'" -}}
5
+ {%- elif arg_value is mapping or arg_value is iterable -%}
6
+ {{- arg_value | tojson -}}
7
+ {%- else -%}
8
+ {{- arg_value | string -}}
9
+ {%- endif -%}
10
+ {%- endmacro -%}
11
+ {%- macro render_tool_calls(tool_calls) -%}
12
+ {%- set tool_calls_ns = namespace(tool_calls=[]) -%}
13
+ {%- for tool_call in tool_calls -%}
14
+ {%- set func = tool_call["function"] if "function" in tool_call else tool_call -%}
15
+ {%- set func_name = func["name"] -%}
16
+ {%- set func_args = func.get("arguments") -%}
17
+ {%- set args_ns = namespace(arg_strings=[]) -%}
18
+ {%- if func_args is mapping -%}
19
+ {%- for arg_name, arg_value in func_args.items() -%}
20
+ {%- set args_ns.arg_strings = args_ns.arg_strings + [arg_name + "=" + format_arg_value(arg_value)] -%}
21
+ {%- endfor -%}
22
+ {%- elif func_args is string and (func_args | trim) not in ["", "{}", "null"] -%}
23
+ {{- raise_exception("Tool call arguments must be a mapping, got a JSON-encoded string: parse arguments with json.loads() before applying the chat template") -}}
24
+ {%- endif -%}
25
+ {%- set tool_calls_ns.tool_calls = tool_calls_ns.tool_calls + [func_name + "(" + (args_ns.arg_strings | join(", ")) + ")"] -%}
26
+ {%- endfor -%}
27
+ {{- "<|tool_call_start|>[" + (tool_calls_ns.tool_calls | join(", ")) + "]<|tool_call_end|>" -}}
28
+ {%- endmacro -%}
29
+ {%- set system_prompt = "" -%}
30
+ {%- set ns = namespace(system_prompt="") -%}
31
+ {%- if messages[0]["role"] == "system" -%}
32
+ {%- set ns.system_prompt = messages[0]["content"] -%}
33
+ {%- set messages = messages[1:] -%}
34
+ {%- endif -%}
35
+ {%- if tools -%}
36
+ {%- set ns.system_prompt = ns.system_prompt + ("\n" if ns.system_prompt else "") + "List of tools: <|tool_list_start|>[" -%}
37
+ {%- for tool in tools -%}
38
+ {%- if tool is not string -%}
39
+ {%- set tool = tool | tojson -%}
40
+ {%- endif -%}
41
+ {%- set ns.system_prompt = ns.system_prompt + tool -%}
42
+ {%- if not loop.last -%}
43
+ {%- set ns.system_prompt = ns.system_prompt + ", " -%}
44
+ {%- endif -%}
45
+ {%- endfor -%}
46
+ {%- set ns.system_prompt = ns.system_prompt + "]<|tool_list_end|>" -%}
47
+ {%- endif -%}
48
+ {%- if ns.system_prompt -%}
49
+ {{- "<|im_start|>system\n" + ns.system_prompt + "<|im_end|>\n" -}}
50
+ {%- endif -%}
51
+ {%- for message in messages -%}
52
+ {{- "<|im_start|>" + message["role"] + "\n" -}}
53
+ {%- set content = message.get("content") -%}
54
+ {%- if content is not string -%}
55
+ {%- set content = content | tojson -%}
56
+ {%- endif -%}
57
+ {%- if message["role"] == "tool" -%}
58
+ {%- set content = "<|tool_response_start|>" + content + "<|tool_response_end|>" -%}
59
+ {%- endif -%}
60
+ {%- if message["role"] == "assistant" and message.get("tool_calls") -%}
61
+ {%- if content and content != "null" -%}
62
+ {{- content -}}
63
+ {%- endif -%}
64
+ {{- render_tool_calls(message["tool_calls"]) -}}
65
+ {{- "<|im_end|>\n" -}}
66
+ {%- else -%}
67
+ {{- content + "<|im_end|>\n" -}}
68
+ {%- endif -%}
69
+ {%- endfor -%}
70
+ {%- if add_generation_prompt -%}
71
+ {{- "<|im_start|>assistant\n" -}}
72
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Lfm2MoeForCausalLM"
4
+ ],
5
+ "bos_token_id": 1,
6
+ "conv_L_cache": 3,
7
+ "conv_bias": false,
8
+ "dtype": "float32",
9
+ "eos_token_id": 7,
10
+ "hidden_size": 32,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 32,
13
+ "is_decoder": true,
14
+ "layer_types": [
15
+ "full_attention",
16
+ "conv"
17
+ ],
18
+ "max_position_embeddings": 512,
19
+ "model_type": "lfm2_moe",
20
+ "moe_intermediate_size": 16,
21
+ "norm_eps": 1e-05,
22
+ "norm_topk_prob": true,
23
+ "num_attention_heads": 2,
24
+ "num_dense_layers": 1,
25
+ "num_experts": 8,
26
+ "num_experts_per_tok": 2,
27
+ "num_hidden_layers": 2,
28
+ "num_key_value_heads": 2,
29
+ "pad_token_id": 0,
30
+ "rope_parameters": {
31
+ "rope_theta": 1000000.0,
32
+ "rope_type": "default"
33
+ },
34
+ "routed_scaling_factor": 1.0,
35
+ "tie_word_embeddings": false,
36
+ "transformers_version": "5.16.0.dev0",
37
+ "use_cache": true,
38
+ "use_expert_bias": true,
39
+ "vocab_size": 64400
40
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 7,
5
+ "output_attentions": false,
6
+ "output_hidden_states": false,
7
+ "pad_token_id": 0,
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:0aaa9790871bcc69969af5ced3dcb71ae19cab04ecce32e1950f1496c22b283a
3
+ size 16587832
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|startoftext|>",
4
+ "clean_up_tokenization_spaces": false,
5
+ "eos_token": "<|im_end|>",
6
+ "is_local": true,
7
+ "legacy": false,
8
+ "local_files_only": false,
9
+ "model_input_names": [
10
+ "input_ids",
11
+ "attention_mask"
12
+ ],
13
+ "model_max_length": 512,
14
+ "pad_token": "<|pad|>",
15
+ "sp_model_kwargs": {},
16
+ "spaces_between_special_tokens": false,
17
+ "tokenizer_class": "TokenizersBackend",
18
+ "use_default_system_prompt": false,
19
+ "use_fast": true
20
+ }