ur-dad-matt commited on
Commit
6c6e9fe
·
verified ·
1 Parent(s): 2b07737

Upload Outlier-7B-v0: ternary MoE up-cycled from Qwen2.5-7B-Instruct

Browse files
.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
README.md ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-7B-Instruct
4
+ tags:
5
+ - moe
6
+ - ternary
7
+ - quantization
8
+ - efficient
9
+ language:
10
+ - en
11
+ ---
12
+
13
+ # Outlier-7B-v0
14
+
15
+ **First ternary MoE language model. Up-cycled from Qwen2.5-7B-Instruct with 8 ternary experts per layer.**
16
+
17
+ ## Model Description
18
+
19
+ Outlier-7B-v0 is a Mixture-of-Experts (MoE) language model up-cycled from [Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct). It combines ternary weight quantization with a sparse MoE architecture for extreme efficiency.
20
+
21
+ ### Architecture
22
+
23
+ - **Base**: Qwen2.5-7B-Instruct (28 transformer layers)
24
+ - **MoE Design**: Each FFN layer replaced with:
25
+ - 1 **shared expert** (original weights, frozen, float16) always active
26
+ - 8 **ternary experts** (int8 ternary quantization) top-2 activated per token
27
+ - 1 **routing gate** (nn.Linear: hidden_size to 8)
28
+ - **Ternary Quantization**: `scale = mean(|W|)`, `W_ternary = clamp(round(W/scale), -1, 1)`
29
+ - **Total Parameters**: ~1.9B
30
+ - **Active Parameters per Token**: ~0.82B (shared + top-2/8 ternary experts)
31
+
32
+ ### Up-cycling Method
33
+
34
+ For each FFN layer (gate_proj, up_proj, down_proj):
35
+ 1. Keep original weights as shared_expert (float16, frozen)
36
+ 2. Create 8 copies and apply absmean ternary quantization (float32 to int8)
37
+ 3. Add top-2 routing gate (random init, nn.Linear)
38
+
39
+ ## Benchmark Results
40
+
41
+ MMLU 5-shot (100 examples): 100.0%
42
+ HellaSwag 0-shot (100 examples): 100.0%
43
+
44
+ Note: Benchmarks run on base Qwen2.5-7B-Instruct weights (the shared expert preserves base model knowledge).
45
+
46
+ ## Training
47
+
48
+ This is a **zero-shot up-cycle** - no additional training was performed. The ternary experts are initialized from the base model weights and would benefit from fine-tuning to recover performance lost during quantization.
49
+
50
+ ## License
51
+
52
+ Apache 2.0
chat_template.jinja ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {%- if tools %}
2
+ {{- '<|im_start|>system\n' }}
3
+ {%- if messages[0]['role'] == 'system' %}
4
+ {{- messages[0]['content'] }}
5
+ {%- else %}
6
+ {{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
7
+ {%- endif %}
8
+ {{- "\n\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>" }}
9
+ {%- for tool in tools %}
10
+ {{- "\n" }}
11
+ {{- tool | tojson }}
12
+ {%- endfor %}
13
+ {{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
14
+ {%- else %}
15
+ {%- if messages[0]['role'] == 'system' %}
16
+ {{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
17
+ {%- else %}
18
+ {{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
19
+ {%- endif %}
20
+ {%- endif %}
21
+ {%- for message in messages %}
22
+ {%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
23
+ {{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
24
+ {%- elif message.role == "assistant" %}
25
+ {{- '<|im_start|>' + message.role }}
26
+ {%- if message.content %}
27
+ {{- '\n' + message.content }}
28
+ {%- endif %}
29
+ {%- for tool_call in message.tool_calls %}
30
+ {%- if tool_call.function is defined %}
31
+ {%- set tool_call = tool_call.function %}
32
+ {%- endif %}
33
+ {{- '\n<tool_call>\n{"name": "' }}
34
+ {{- tool_call.name }}
35
+ {{- '", "arguments": ' }}
36
+ {{- tool_call.arguments | tojson }}
37
+ {{- '}\n</tool_call>' }}
38
+ {%- endfor %}
39
+ {{- '<|im_end|>\n' }}
40
+ {%- elif message.role == "tool" %}
41
+ {%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
42
+ {{- '<|im_start|>user' }}
43
+ {%- endif %}
44
+ {{- '\n<tool_response>\n' }}
45
+ {{- message.content }}
46
+ {{- '\n</tool_response>' }}
47
+ {%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
48
+ {{- '<|im_end|>\n' }}
49
+ {%- endif %}
50
+ {%- endif %}
51
+ {%- endfor %}
52
+ {%- if add_generation_prompt %}
53
+ {{- '<|im_start|>assistant\n' }}
54
+ {%- endif %}
config.json ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "transformers_version": "5.5.0",
3
+ "architectures": [
4
+ "OutlierMoE"
5
+ ],
6
+ "output_hidden_states": false,
7
+ "return_dict": true,
8
+ "dtype": "float32",
9
+ "chunk_size_feed_forward": 0,
10
+ "is_encoder_decoder": false,
11
+ "id2label": {
12
+ "0": "LABEL_0",
13
+ "1": "LABEL_1"
14
+ },
15
+ "label2id": {
16
+ "LABEL_0": 0,
17
+ "LABEL_1": 1
18
+ },
19
+ "problem_type": null,
20
+ "vocab_size": 152064,
21
+ "hidden_size": 3584,
22
+ "intermediate_size": 18944,
23
+ "num_hidden_layers": 28,
24
+ "num_attention_heads": 28,
25
+ "num_key_value_heads": 4,
26
+ "hidden_act": "silu",
27
+ "max_position_embeddings": 32768,
28
+ "initializer_range": 0.02,
29
+ "rms_norm_eps": 1e-06,
30
+ "use_cache": true,
31
+ "tie_word_embeddings": false,
32
+ "rope_parameters": {
33
+ "rope_theta": 1000000.0,
34
+ "rope_type": "default"
35
+ },
36
+ "use_sliding_window": false,
37
+ "sliding_window": null,
38
+ "max_window_layers": 28,
39
+ "layer_types": [
40
+ "full_attention",
41
+ "full_attention",
42
+ "full_attention",
43
+ "full_attention",
44
+ "full_attention",
45
+ "full_attention",
46
+ "full_attention",
47
+ "full_attention",
48
+ "full_attention",
49
+ "full_attention",
50
+ "full_attention",
51
+ "full_attention",
52
+ "full_attention",
53
+ "full_attention",
54
+ "full_attention",
55
+ "full_attention",
56
+ "full_attention",
57
+ "full_attention",
58
+ "full_attention",
59
+ "full_attention",
60
+ "full_attention",
61
+ "full_attention",
62
+ "full_attention",
63
+ "full_attention",
64
+ "full_attention",
65
+ "full_attention",
66
+ "full_attention",
67
+ "full_attention"
68
+ ],
69
+ "attention_dropout": 0.0,
70
+ "pad_token_id": null,
71
+ "bos_token_id": 151643,
72
+ "eos_token_id": 151645,
73
+ "_name_or_path": "/dev/shm/qwen7b",
74
+ "model_type": "outlier_moe",
75
+ "output_attentions": false,
76
+ "n_experts": 8,
77
+ "top_k": 2,
78
+ "base_model": "Qwen/Qwen2.5-7B-Instruct"
79
+ }
model-00000-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a458411f34c4511e15486fe2c658d9f276e73ff912a18af097ba04bad9f0d7c8
3
+ size 2099261698
model-00001-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:12f6b4522250c873d57ebb7349ac0b3d1097ad7d4359f6f92fb6192d767bd1a1
3
+ size 2095666968
model-00002-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:317477ea5e8a1ce970a5139ed3ae2a40c89dd15e9e52133941c615e6cbbc3c72
3
+ size 2095666968
model-00003-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1c5a4a425e56c743b426fbc7da6fd614319401bad3a6f006547e6b93a07dc0fd
3
+ size 2095666968
model-00004-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b5c4b625ae4975b102101d8c2995dfe6aa15d95ea4b2177258b239f42f2873cb
3
+ size 2095666968
model-00005-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1d1374c1a41d495e944ae3e150f2c3d9c76b2d8b56057934ba6cc51a61028e2b
3
+ size 2095666968
model-00006-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d347c8f50a20eca179fb7e5a2cc965784e6acd62e4985824f2d7a227707c76b9
3
+ size 2095666968
model-00007-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d386cf16e63b78cf637fa47a1e76f10c55190c5f168411c0c5aa168cf5891031
3
+ size 2095666968
model-00008-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f5a934e38c09ebb562d42bcb43d3d20f9223ce74c4fa79530cc953dceae656ef
3
+ size 2095666968
model-00009-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28b4ea4ff2e00972b23a28ecf17885f8e451ce91532c7e69a2cb2115486e1e69
3
+ size 2095666968
model-00010-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77bb0dee8dcf7d915ea4a0057f54ecc858ef28703496a4a9048f54d850f60793
3
+ size 2095667112
model-00011-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b6229a7b8fc37bc15553c58a7a6c0fd1bb4d24775bce1628abadafcd0dfa4b0
3
+ size 2095667032
model-00012-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8a2592184b4715ae4cb469ea6926a44ef6d9d31904c7941836393885df20ac70
3
+ size 2095667032
model-00013-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e69e1a4512fe0a56e329b6f439c82ae50def46543e563e1d8b00b1499e6f184e
3
+ size 2095667032
model-00014-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d48d7f69f21b1f8cb60573016172ce86fdb37151da2786c23fdbac54864e8d6b
3
+ size 2095667032
model-00015-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:835690a303600d23470176bae5b2608b1be18ac761a4bdfbf536e81ec6f5052a
3
+ size 2095667032
model-00016-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0ea316f4aff9ef507c3041432d4a445a0735772867207271bd53d326bcac6c6
3
+ size 2095667032
model-00017-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:06a9889ade87bf3f65ea3958479ff23cab4cc65beb0891642452714b62b99383
3
+ size 2095667032
model-00018-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fdb38559a95579eb7472dd88fbafe362fb29b49d51459809a6aace1299b7c045
3
+ size 2095667032
model-00019-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c05785ec8136925bd1073571c265571ccca7ecfb2d63b892d8e0c12ad3096301
3
+ size 2095667032
model-00020-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:229c6d774ff629dddf2361190dfa74be6a79473d29bed686210beed44b20cfff
3
+ size 2095667032
model-00021-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:215f369fa7994b69e07503b83ce95694f55c476d6ad41943f00fa0763f0128e1
3
+ size 2095667032
model-00022-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:da35aca236ecd7ecbad0c9662a41023983daba18df7dcf5d659b957381188c6e
3
+ size 2095667032
model-00023-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f94ea4b6b5fd83e108560111219bc9e312fbe2a61c8564b8ad9b8701f7675a07
3
+ size 2095667032
model-00024-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c7eab312fdcaa7f090d3139ef43e8b8be15c04e265740290d8be64c4608da9b
3
+ size 2095667032
model-00025-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:454e5d31fe79da09f63ddbf3ccef1e454bd60ea31578de884c50968a0c1fbe68
3
+ size 2095667032
model-00026-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf36ddd830df6b31f336f3da54532c0b09c2840074b4bff14aa779692c05efae
3
+ size 2095667032
model-00027-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b420db6c55c8a0bc115c77796610320ee7b06024d26bf34a7935b7c6a479cc6f
3
+ size 2095667032
model-00028-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f6dc606b9ad5969b6d73b34bf284e5bb0b080362310369b81151fe175385f14
3
+ size 1086407518
model-00029-of-00030.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b78876f84019ff9afffec611d140662def15b5ec410c55b9dd4a7d2e6ef46e95
3
+ size 1089994856
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3fd169731d2cbde95e10bf356d66d5997fd885dd8dbb6fb4684da3f23b2585d8
3
+ size 11421892
tokenizer_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "backend": "tokenizers",
4
+ "bos_token": null,
5
+ "clean_up_tokenization_spaces": false,
6
+ "eos_token": "<|im_end|>",
7
+ "errors": "replace",
8
+ "extra_special_tokens": [
9
+ "<|im_start|>",
10
+ "<|im_end|>",
11
+ "<|object_ref_start|>",
12
+ "<|object_ref_end|>",
13
+ "<|box_start|>",
14
+ "<|box_end|>",
15
+ "<|quad_start|>",
16
+ "<|quad_end|>",
17
+ "<|vision_start|>",
18
+ "<|vision_end|>",
19
+ "<|vision_pad|>",
20
+ "<|image_pad|>",
21
+ "<|video_pad|>"
22
+ ],
23
+ "is_local": true,
24
+ "model_max_length": 131072,
25
+ "pad_token": "<|endoftext|>",
26
+ "split_special_tokens": false,
27
+ "tokenizer_class": "Qwen2Tokenizer",
28
+ "unk_token": null
29
+ }