fbaldassarri commited on
Commit
3db29cb
1 Parent(s): 78c8154

Initial Upload

Browse files
README.md CHANGED
@@ -1,3 +1,93 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ - de
5
+ - fr
6
+ - it
7
+ - pt
8
+ - hi
9
+ - es
10
+ - th
11
+ license: apache-2.0
12
+ library_name: transformers
13
+ tags:
14
+ - autoround
15
+ - auto-round
16
+ - intel
17
+ - gptq
18
+ - awq
19
+ - auto-awq
20
+ - autoawq
21
+ - woq
22
+ - meta
23
+ - pytorch
24
+ - transformers
25
+ model_name: SmolLM2 1.7B Instruct
26
+ base_model: HuggingFaceTB/SmolLM2-1.7B-Instruct
27
+ inference: false
28
+ model_creator: HuggingFaceTB
29
+ pipeline_tag: text-generation
30
+ prompt_template: '{prompt}
31
+ '
32
+ quantized_by: fbaldassarri
33
+ ---
34
+
35
+ ## Model Information
36
+
37
+ Quantized version of [HuggingFaceTB/SmolLM2-1.7B-Instruct](HuggingFaceTB/SmolLM2-1.7B-Instruct) using torch.float32 for quantization tuning.
38
+ - 4 bits (INT4)
39
+ - group size = 128
40
+ - Symmetrical Quantization
41
+ - Method AutoAWQ
42
+
43
+ Quantization framework: [Intel AutoRound](https://github.com/intel/auto-round)
44
+
45
+ Note: this INT4 version of SmolLM2-1.7B-Instruct has been quantized to run inference through CPU.
46
+
47
+ ## Replication Recipe
48
+
49
+ ### Step 1 Install Requirements
50
+
51
+ I suggest to install requirements into a dedicated python-virtualenv or a conda enviroment.
52
+
53
+ ```
54
+ python -m pip install <package> --upgrade
55
+ ```
56
+
57
+ - accelerate==1.0.1
58
+ - auto_gptq==0.7.1
59
+ - neural_compressor==3.1
60
+ - torch==2.3.0+cpu
61
+ - torchaudio==2.5.0+cpu
62
+ - torchvision==0.18.0+cpu
63
+ - transformers==4.45.2
64
+
65
+ ### Step 2 Build Intel Autoround wheel from sources
66
+
67
+ ```
68
+ python -m pip install git+https://github.com/intel/auto-round.git
69
+ ```
70
+
71
+ ### Step 3 Script for Quantization
72
+
73
+ ```
74
+ from transformers import AutoModelForCausalLM, AutoTokenizer
75
+ model_name = "HuggingFaceTB/SmolLM2-1.7B-Instruct"
76
+ model = AutoModelForCausalLM.from_pretrained(model_name)
77
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
78
+ from auto_round import AutoRound
79
+ bits, group_size, sym, device, amp = 4, 128, True, 'cpu', False
80
+ autoround = AutoRound(model, tokenizer, nsamples=128, iters=200, seqlen=512, batch_size=4, bits=bits, group_size=group_size, sym=sym, device=device, amp=amp)
81
+ autoround.quantize()
82
+ output_dir = "./AutoRound/HuggingFaceTB_SmolLM2-1.7B-Instruct-auto_awq-int4-gs128-sym"
83
+ autoround.save_quantized(output_dir, format='auto_awq', inplace=True)
84
+ ```
85
+
86
+ ## License
87
+
88
+ [Apache 2.0 License](https://choosealicense.com/licenses/apache-2.0/)
89
+
90
+ ## Disclaimer
91
+
92
+ This quantized model comes with no warrenty. It has been developed only for research purposes.
93
+
config.json ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "HuggingFaceTB/SmolLM2-1.7B-Instruct",
3
+ "architectures": [
4
+ "LlamaForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "bos_token_id": 1,
9
+ "eos_token_id": 2,
10
+ "head_dim": 64,
11
+ "hidden_act": "silu",
12
+ "hidden_size": 2048,
13
+ "initializer_range": 0.02,
14
+ "intermediate_size": 8192,
15
+ "max_position_embeddings": 8192,
16
+ "mlp_bias": false,
17
+ "model_type": "llama",
18
+ "num_attention_heads": 32,
19
+ "num_hidden_layers": 24,
20
+ "num_key_value_heads": 32,
21
+ "pad_token_id": 2,
22
+ "pretraining_tp": 1,
23
+ "quantization_config": {
24
+ "amp": false,
25
+ "autoround_version": "0.4.2",
26
+ "batch_size": 4,
27
+ "bits": 4,
28
+ "data_type": "int",
29
+ "dataset": "NeelNanda/pile-10k",
30
+ "enable_minmax_tuning": true,
31
+ "enable_norm_bias_tuning": false,
32
+ "enable_quanted_input": true,
33
+ "gradient_accumulate_steps": 1,
34
+ "group_size": 128,
35
+ "iters": 200,
36
+ "low_gpu_mem_usage": false,
37
+ "lr": 0.005,
38
+ "minmax_lr": 0.005,
39
+ "modules_to_not_convert": [
40
+ "lm_head"
41
+ ],
42
+ "nsamples": 128,
43
+ "quant_method": "awq",
44
+ "scale_dtype": "torch.float16",
45
+ "seqlen": 512,
46
+ "sym": true,
47
+ "to_quant_block_names": null,
48
+ "version": "gemm",
49
+ "zero_point": false
50
+ },
51
+ "rms_norm_eps": 1e-05,
52
+ "rope_scaling": null,
53
+ "rope_theta": 130000,
54
+ "tie_word_embeddings": true,
55
+ "torch_dtype": "float32",
56
+ "transformers.js_config": {
57
+ "kv_cache_dtype": {
58
+ "fp16": "float16",
59
+ "q4f16": "float16"
60
+ }
61
+ },
62
+ "transformers_version": "4.47.0",
63
+ "use_cache": true,
64
+ "vocab_size": 49152
65
+ }
generation_config.json ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 1,
4
+ "eos_token_id": 2,
5
+ "pad_token_id": 2,
6
+ "transformers_version": "4.47.0"
7
+ }
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:11b229f654bd8d5f93d26d5a5d38e60831006c9222f6e34205a086f2a598d23f
3
+ size 1239880632
quantization_config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bits": 4,
3
+ "group_size": 128,
4
+ "sym": true,
5
+ "data_type": "int",
6
+ "enable_quanted_input": true,
7
+ "enable_minmax_tuning": true,
8
+ "seqlen": 512,
9
+ "batch_size": 4,
10
+ "scale_dtype": "torch.float16",
11
+ "lr": 0.005,
12
+ "minmax_lr": 0.005,
13
+ "gradient_accumulate_steps": 1,
14
+ "iters": 200,
15
+ "amp": false,
16
+ "nsamples": 128,
17
+ "low_gpu_mem_usage": false,
18
+ "to_quant_block_names": null,
19
+ "enable_norm_bias_tuning": false,
20
+ "dataset": "NeelNanda/pile-10k",
21
+ "autoround_version": "0.4.2",
22
+ "quant_method": "awq",
23
+ "zero_point": false,
24
+ "version": "gemm",
25
+ "modules_to_not_convert": [
26
+ "lm_head"
27
+ ]
28
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>"
5
+ ],
6
+ "bos_token": {
7
+ "content": "<|im_start|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "eos_token": {
14
+ "content": "<|im_end|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ },
20
+ "pad_token": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false
26
+ },
27
+ "unk_token": {
28
+ "content": "<|endoftext|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ }
34
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "0": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "1": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "2": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ },
28
+ "3": {
29
+ "content": "<repo_name>",
30
+ "lstrip": false,
31
+ "normalized": false,
32
+ "rstrip": false,
33
+ "single_word": false,
34
+ "special": true
35
+ },
36
+ "4": {
37
+ "content": "<reponame>",
38
+ "lstrip": false,
39
+ "normalized": false,
40
+ "rstrip": false,
41
+ "single_word": false,
42
+ "special": true
43
+ },
44
+ "5": {
45
+ "content": "<file_sep>",
46
+ "lstrip": false,
47
+ "normalized": false,
48
+ "rstrip": false,
49
+ "single_word": false,
50
+ "special": true
51
+ },
52
+ "6": {
53
+ "content": "<filename>",
54
+ "lstrip": false,
55
+ "normalized": false,
56
+ "rstrip": false,
57
+ "single_word": false,
58
+ "special": true
59
+ },
60
+ "7": {
61
+ "content": "<gh_stars>",
62
+ "lstrip": false,
63
+ "normalized": false,
64
+ "rstrip": false,
65
+ "single_word": false,
66
+ "special": true
67
+ },
68
+ "8": {
69
+ "content": "<issue_start>",
70
+ "lstrip": false,
71
+ "normalized": false,
72
+ "rstrip": false,
73
+ "single_word": false,
74
+ "special": true
75
+ },
76
+ "9": {
77
+ "content": "<issue_comment>",
78
+ "lstrip": false,
79
+ "normalized": false,
80
+ "rstrip": false,
81
+ "single_word": false,
82
+ "special": true
83
+ },
84
+ "10": {
85
+ "content": "<issue_closed>",
86
+ "lstrip": false,
87
+ "normalized": false,
88
+ "rstrip": false,
89
+ "single_word": false,
90
+ "special": true
91
+ },
92
+ "11": {
93
+ "content": "<jupyter_start>",
94
+ "lstrip": false,
95
+ "normalized": false,
96
+ "rstrip": false,
97
+ "single_word": false,
98
+ "special": true
99
+ },
100
+ "12": {
101
+ "content": "<jupyter_text>",
102
+ "lstrip": false,
103
+ "normalized": false,
104
+ "rstrip": false,
105
+ "single_word": false,
106
+ "special": true
107
+ },
108
+ "13": {
109
+ "content": "<jupyter_code>",
110
+ "lstrip": false,
111
+ "normalized": false,
112
+ "rstrip": false,
113
+ "single_word": false,
114
+ "special": true
115
+ },
116
+ "14": {
117
+ "content": "<jupyter_output>",
118
+ "lstrip": false,
119
+ "normalized": false,
120
+ "rstrip": false,
121
+ "single_word": false,
122
+ "special": true
123
+ },
124
+ "15": {
125
+ "content": "<jupyter_script>",
126
+ "lstrip": false,
127
+ "normalized": false,
128
+ "rstrip": false,
129
+ "single_word": false,
130
+ "special": true
131
+ },
132
+ "16": {
133
+ "content": "<empty_output>",
134
+ "lstrip": false,
135
+ "normalized": false,
136
+ "rstrip": false,
137
+ "single_word": false,
138
+ "special": true
139
+ }
140
+ },
141
+ "additional_special_tokens": [
142
+ "<|im_start|>",
143
+ "<|im_end|>"
144
+ ],
145
+ "bos_token": "<|im_start|>",
146
+ "chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful AI assistant named SmolLM, trained by Hugging Face<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
147
+ "clean_up_tokenization_spaces": false,
148
+ "eos_token": "<|im_end|>",
149
+ "extra_special_tokens": {},
150
+ "model_max_length": 2048,
151
+ "pad_token": "<|im_end|>",
152
+ "tokenizer_class": "GPT2Tokenizer",
153
+ "unk_token": "<|endoftext|>",
154
+ "vocab_size": 49152
155
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff