Rainnighttram commited on
Commit
9056755
·
verified ·
1 Parent(s): 1ec24ae

4 bit quantization of GLM-4.1V-9B model using bitsandbytes

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
chat_template.jinja ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [gMASK]<sop>
2
+ {%- for msg in messages %}
3
+ {%- if msg.role == 'system' %}
4
+ <|system|>
5
+ {{ msg.content }}
6
+ {%- elif msg.role == 'user' %}
7
+ <|user|>{{ '\n' }}
8
+
9
+ {%- if msg.content is string %}
10
+ {{ msg.content }}
11
+ {%- else %}
12
+ {%- for item in msg.content %}
13
+ {%- if item.type == 'video' or 'video' in item %}
14
+ <|begin_of_video|><|video|><|end_of_video|>
15
+ {%- elif item.type == 'image' or 'image' in item %}
16
+ <|begin_of_image|><|image|><|end_of_image|>
17
+ {%- elif item.type == 'text' %}
18
+ {{ item.text }}
19
+ {%- endif %}
20
+ {%- endfor %}
21
+ {%- endif %}
22
+ {%- elif msg.role == 'assistant' %}
23
+ {%- if msg.metadata %}
24
+ <|assistant|>{{ msg.metadata }}
25
+ {{ msg.content }}
26
+ {%- else %}
27
+ <|assistant|>
28
+ {{ msg.content }}
29
+ {%- endif %}
30
+ {%- endif %}
31
+ {%- endfor %}
32
+ {% if add_generation_prompt %}<|assistant|>
33
+ {% endif %}
config.json ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Glm4vForConditionalGeneration"
4
+ ],
5
+ "attention_bias": true,
6
+ "attention_dropout": 0.0,
7
+ "eos_token_id": [
8
+ 151329,
9
+ 151336,
10
+ 151338,
11
+ 151348
12
+ ],
13
+ "hidden_act": "silu",
14
+ "hidden_size": 4096,
15
+ "image_end_token_id": 151340,
16
+ "image_start_token_id": 151339,
17
+ "image_token_id": 151343,
18
+ "initializer_range": 0.02,
19
+ "intermediate_size": 13696,
20
+ "max_position_embeddings": 32768,
21
+ "model_type": "glm4v",
22
+ "num_attention_heads": 32,
23
+ "num_hidden_layers": 40,
24
+ "num_key_value_heads": 2,
25
+ "pad_token_id": 151329,
26
+ "partial_rotary_factor": 0.5,
27
+ "quantization_config": {
28
+ "_load_in_4bit": true,
29
+ "_load_in_8bit": false,
30
+ "bnb_4bit_compute_dtype": "bfloat16",
31
+ "bnb_4bit_quant_storage": "uint8",
32
+ "bnb_4bit_quant_type": "nf4",
33
+ "bnb_4bit_use_double_quant": true,
34
+ "llm_int8_enable_fp32_cpu_offload": false,
35
+ "llm_int8_has_fp16_weight": false,
36
+ "llm_int8_skip_modules": null,
37
+ "llm_int8_threshold": 6.0,
38
+ "load_in_4bit": true,
39
+ "load_in_8bit": false,
40
+ "quant_method": "bitsandbytes"
41
+ },
42
+ "rms_norm_eps": 1e-05,
43
+ "rope_scaling": {
44
+ "mrope_section": [
45
+ 8,
46
+ 12,
47
+ 12
48
+ ],
49
+ "rope_type": "default",
50
+ "type": "default"
51
+ },
52
+ "rope_theta": 10000.0,
53
+ "text_config": {
54
+ "architectures": [
55
+ "Glm4vForConditionalGeneration"
56
+ ],
57
+ "attention_bias": true,
58
+ "attention_dropout": 0.0,
59
+ "eos_token_id": [
60
+ 151329,
61
+ 151336,
62
+ 151338,
63
+ 151348
64
+ ],
65
+ "hidden_act": "silu",
66
+ "hidden_size": 4096,
67
+ "image_token_id": null,
68
+ "initializer_range": 0.02,
69
+ "intermediate_size": 13696,
70
+ "max_position_embeddings": 32768,
71
+ "model_type": "glm4v_text",
72
+ "num_attention_heads": 32,
73
+ "num_hidden_layers": 40,
74
+ "num_key_value_heads": 2,
75
+ "pad_token_id": 151329,
76
+ "partial_rotary_factor": 0.5,
77
+ "rms_norm_eps": 1e-05,
78
+ "rope_scaling": {
79
+ "mrope_section": [
80
+ 8,
81
+ 12,
82
+ 12
83
+ ],
84
+ "rope_type": "default",
85
+ "type": "default"
86
+ },
87
+ "rope_theta": 10000.0,
88
+ "torch_dtype": "float16",
89
+ "use_cache": true,
90
+ "video_token_id": null,
91
+ "vocab_size": 151552
92
+ },
93
+ "tie_word_embeddings": false,
94
+ "torch_dtype": "float16",
95
+ "transformers_version": "4.54.0.dev0",
96
+ "use_cache": true,
97
+ "video_end_token_id": 151342,
98
+ "video_start_token_id": 151341,
99
+ "video_token_id": 151344,
100
+ "vision_config": {
101
+ "attention_bias": false,
102
+ "attention_dropout": 0.0,
103
+ "depth": 24,
104
+ "hidden_act": "silu",
105
+ "hidden_dropout_prob": 0.0,
106
+ "hidden_size": 1536,
107
+ "image_size": 336,
108
+ "in_channels": 3,
109
+ "initializer_range": 0.02,
110
+ "intermediate_size": 13696,
111
+ "model_type": "glm4v",
112
+ "num_heads": 12,
113
+ "out_hidden_size": 4096,
114
+ "patch_size": 14,
115
+ "rms_norm_eps": 1e-05,
116
+ "spatial_merge_size": 2,
117
+ "temporal_patch_size": 2,
118
+ "torch_dtype": "float16"
119
+ },
120
+ "vocab_size": 151552
121
+ }
generation_config.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "eos_token_id": [
4
+ 151329,
5
+ 151336,
6
+ 151338,
7
+ 151348
8
+ ],
9
+ "pad_token_id": 151329,
10
+ "transformers_version": "4.54.0.dev0"
11
+ }
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b603b6ac6105d5d21696557756d73529767466d07943368cc6e42753bddd430b
3
+ size 4977923096
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5388630de1aca5676d43dba7b3eadffd8d895c2b9a7dfeebe7ae52d116535507
3
+ size 2217889619
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
preprocessor_config.json ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": null,
3
+ "data_format": "channels_first",
4
+ "default_to_square": true,
5
+ "device": null,
6
+ "disable_grouping": null,
7
+ "do_center_crop": null,
8
+ "do_convert_rgb": true,
9
+ "do_normalize": true,
10
+ "do_rescale": true,
11
+ "do_resize": true,
12
+ "image_mean": [
13
+ 0.48145466,
14
+ 0.4578275,
15
+ 0.40821073
16
+ ],
17
+ "image_processor_type": "Glm4vImageProcessorFast",
18
+ "image_std": [
19
+ 0.26862954,
20
+ 0.26130258,
21
+ 0.27577711
22
+ ],
23
+ "input_data_format": null,
24
+ "merge_size": 2,
25
+ "patch_size": 14,
26
+ "processor_class": "Glm4vProcessor",
27
+ "resample": 3,
28
+ "rescale_factor": 0.00392156862745098,
29
+ "return_tensors": null,
30
+ "size": {
31
+ "longest_edge": 11760000,
32
+ "shortest_edge": 12544
33
+ },
34
+ "temporal_patch_size": 2
35
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|endoftext|>",
4
+ "[MASK]",
5
+ "[gMASK]",
6
+ "[sMASK]",
7
+ "<sop>",
8
+ "<eop>",
9
+ "<|system|>",
10
+ "<|user|>",
11
+ "<|assistant|>",
12
+ "<|observation|>",
13
+ "<|begin_of_image|>",
14
+ "<|end_of_image|>",
15
+ "<|begin_of_video|>",
16
+ "<|end_of_video|>",
17
+ "<|image|>",
18
+ "<|video|>"
19
+ ],
20
+ "eos_token": {
21
+ "content": "<|endoftext|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false
26
+ },
27
+ "pad_token": {
28
+ "content": "<|endoftext|>",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false
33
+ }
34
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bcc742fc44db1f0870d7320b495e6240cc40e202565fc96786220fa0d9ddb41c
3
+ size 19968183
tokenizer_config.json ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "added_tokens_decoder": {
3
+ "151329": {
4
+ "content": "<|endoftext|>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false,
9
+ "special": true
10
+ },
11
+ "151330": {
12
+ "content": "[MASK]",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false,
17
+ "special": true
18
+ },
19
+ "151331": {
20
+ "content": "[gMASK]",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false,
25
+ "special": true
26
+ },
27
+ "151332": {
28
+ "content": "[sMASK]",
29
+ "lstrip": false,
30
+ "normalized": false,
31
+ "rstrip": false,
32
+ "single_word": false,
33
+ "special": true
34
+ },
35
+ "151333": {
36
+ "content": "<sop>",
37
+ "lstrip": false,
38
+ "normalized": false,
39
+ "rstrip": false,
40
+ "single_word": false,
41
+ "special": true
42
+ },
43
+ "151334": {
44
+ "content": "<eop>",
45
+ "lstrip": false,
46
+ "normalized": false,
47
+ "rstrip": false,
48
+ "single_word": false,
49
+ "special": true
50
+ },
51
+ "151335": {
52
+ "content": "<|system|>",
53
+ "lstrip": false,
54
+ "normalized": false,
55
+ "rstrip": false,
56
+ "single_word": false,
57
+ "special": true
58
+ },
59
+ "151336": {
60
+ "content": "<|user|>",
61
+ "lstrip": false,
62
+ "normalized": false,
63
+ "rstrip": false,
64
+ "single_word": false,
65
+ "special": true
66
+ },
67
+ "151337": {
68
+ "content": "<|assistant|>",
69
+ "lstrip": false,
70
+ "normalized": false,
71
+ "rstrip": false,
72
+ "single_word": false,
73
+ "special": true
74
+ },
75
+ "151338": {
76
+ "content": "<|observation|>",
77
+ "lstrip": false,
78
+ "normalized": false,
79
+ "rstrip": false,
80
+ "single_word": false,
81
+ "special": true
82
+ },
83
+ "151339": {
84
+ "content": "<|begin_of_image|>",
85
+ "lstrip": false,
86
+ "normalized": false,
87
+ "rstrip": false,
88
+ "single_word": false,
89
+ "special": true
90
+ },
91
+ "151340": {
92
+ "content": "<|end_of_image|>",
93
+ "lstrip": false,
94
+ "normalized": false,
95
+ "rstrip": false,
96
+ "single_word": false,
97
+ "special": true
98
+ },
99
+ "151341": {
100
+ "content": "<|begin_of_video|>",
101
+ "lstrip": false,
102
+ "normalized": false,
103
+ "rstrip": false,
104
+ "single_word": false,
105
+ "special": true
106
+ },
107
+ "151342": {
108
+ "content": "<|end_of_video|>",
109
+ "lstrip": false,
110
+ "normalized": false,
111
+ "rstrip": false,
112
+ "single_word": false,
113
+ "special": true
114
+ },
115
+ "151343": {
116
+ "content": "<|image|>",
117
+ "lstrip": false,
118
+ "normalized": false,
119
+ "rstrip": false,
120
+ "single_word": false,
121
+ "special": true
122
+ },
123
+ "151344": {
124
+ "content": "<|video|>",
125
+ "lstrip": false,
126
+ "normalized": false,
127
+ "rstrip": false,
128
+ "single_word": false,
129
+ "special": true
130
+ },
131
+ "151345": {
132
+ "content": "<think>",
133
+ "lstrip": false,
134
+ "normalized": false,
135
+ "rstrip": false,
136
+ "single_word": false,
137
+ "special": false
138
+ },
139
+ "151346": {
140
+ "content": "</think>",
141
+ "lstrip": false,
142
+ "normalized": false,
143
+ "rstrip": false,
144
+ "single_word": false,
145
+ "special": false
146
+ },
147
+ "151347": {
148
+ "content": "<answer>",
149
+ "lstrip": false,
150
+ "normalized": false,
151
+ "rstrip": false,
152
+ "single_word": false,
153
+ "special": false
154
+ },
155
+ "151348": {
156
+ "content": "</answer>",
157
+ "lstrip": false,
158
+ "normalized": false,
159
+ "rstrip": false,
160
+ "single_word": false,
161
+ "special": false
162
+ },
163
+ "151349": {
164
+ "content": "<|begin_of_box|>",
165
+ "lstrip": false,
166
+ "normalized": false,
167
+ "rstrip": false,
168
+ "single_word": false,
169
+ "special": false
170
+ },
171
+ "151350": {
172
+ "content": "<|end_of_box|>",
173
+ "lstrip": false,
174
+ "normalized": false,
175
+ "rstrip": false,
176
+ "single_word": false,
177
+ "special": false
178
+ },
179
+ "151351": {
180
+ "content": "<|sep|>",
181
+ "lstrip": false,
182
+ "normalized": false,
183
+ "rstrip": false,
184
+ "single_word": false,
185
+ "special": false
186
+ }
187
+ },
188
+ "additional_special_tokens": [
189
+ "<|endoftext|>",
190
+ "[MASK]",
191
+ "[gMASK]",
192
+ "[sMASK]",
193
+ "<sop>",
194
+ "<eop>",
195
+ "<|system|>",
196
+ "<|user|>",
197
+ "<|assistant|>",
198
+ "<|observation|>",
199
+ "<|begin_of_image|>",
200
+ "<|end_of_image|>",
201
+ "<|begin_of_video|>",
202
+ "<|end_of_video|>",
203
+ "<|image|>",
204
+ "<|video|>"
205
+ ],
206
+ "clean_up_tokenization_spaces": false,
207
+ "do_lower_case": false,
208
+ "eos_token": "<|endoftext|>",
209
+ "extra_special_tokens": {},
210
+ "model_input_names": [
211
+ "input_ids",
212
+ "attention_mask"
213
+ ],
214
+ "model_max_length": 64000,
215
+ "pad_token": "<|endoftext|>",
216
+ "padding_side": "left",
217
+ "processor_class": "Glm4vProcessor",
218
+ "remove_space": false,
219
+ "tokenizer_class": "PreTrainedTokenizerFast",
220
+ "use_fast": true
221
+ }
video_preprocessor_config.json ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "crop_size": null,
3
+ "data_format": "channels_first",
4
+ "default_to_square": true,
5
+ "device": null,
6
+ "do_center_crop": null,
7
+ "do_convert_rgb": true,
8
+ "do_normalize": true,
9
+ "do_pad": null,
10
+ "do_rescale": true,
11
+ "do_resize": true,
12
+ "do_sample_frames": true,
13
+ "fps": 2,
14
+ "image_mean": [
15
+ 0.48145466,
16
+ 0.4578275,
17
+ 0.40821073
18
+ ],
19
+ "image_std": [
20
+ 0.26862954,
21
+ 0.26130258,
22
+ 0.27577711
23
+ ],
24
+ "input_data_format": null,
25
+ "max_image_size": {
26
+ "longest_edge": 47040000
27
+ },
28
+ "merge_size": 2,
29
+ "num_frames": 16,
30
+ "patch_size": 14,
31
+ "processor_class": "Glm4vProcessor",
32
+ "resample": 3,
33
+ "rescale_factor": 0.00392156862745098,
34
+ "size": {
35
+ "longest_edge": 47040000,
36
+ "shortest_edge": 12544
37
+ },
38
+ "size_divisor": null,
39
+ "temporal_patch_size": 2,
40
+ "video_metadata": null,
41
+ "video_processor_type": "Glm4vVideoProcessor"
42
+ }