huseyincavus commited on
Commit
d8fe789
·
verified ·
1 Parent(s): b4e5d18

Add files using upload-large-folder tool

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,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: gemma
3
+ library_name: mlx
4
+ pipeline_tag: text-generation
5
+ extra_gated_heading: Access Gemma on Hugging Face
6
+ extra_gated_prompt: To access Gemma on Hugging Face, you’re required to review and
7
+ agree to Google’s usage license. To do this, please ensure you’re logged in to Hugging
8
+ Face and click below. Requests are processed immediately.
9
+ extra_gated_button_content: Acknowledge license
10
+ tags:
11
+ - automatic-speech-recognition
12
+ - automatic-speech-translation
13
+ - audio-text-to-text
14
+ - video-text-to-text
15
+ - mlx
16
+ base_model: google/gemma-3n-E4B
17
+ ---
18
+
19
+ # huseyincavus/gemma-3n-E4B-it-4bit-mlx
20
+
21
+ This model [huseyincavus/gemma-3n-E4B-it-4bit-mlx](https://huggingface.co/huseyincavus/gemma-3n-E4B-it-4bit-mlx) was
22
+ converted to MLX format from [google/gemma-3n-E4B](https://huggingface.co/google/gemma-3n-E4B)
23
+ using mlx-lm version **0.26.2**.
24
+
25
+ ## Use with mlx
26
+
27
+ ```bash
28
+ pip install mlx-lm
29
+ ```
30
+
31
+ ```python
32
+ from mlx_lm import load, generate
33
+
34
+ model, tokenizer = load("huseyincavus/gemma-3n-E4B-it-4bit-mlx")
35
+
36
+ prompt = "hello"
37
+
38
+ if tokenizer.chat_template is not None:
39
+ messages = [{"role": "user", "content": prompt}]
40
+ prompt = tokenizer.apply_chat_template(
41
+ messages, add_generation_prompt=True
42
+ )
43
+
44
+ response = generate(model, tokenizer, prompt=prompt, verbose=True)
45
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{ bos_token }}
2
+ {%- if messages[0]['role'] == 'system' -%}
3
+ {%- if messages[0]['content'] is string -%}
4
+ {%- set first_user_prefix = messages[0]['content'] + '
5
+
6
+ ' -%}
7
+ {%- else -%}
8
+ {%- set first_user_prefix = messages[0]['content'][0]['text'] + '
9
+
10
+ ' -%}
11
+ {%- endif -%}
12
+ {%- set loop_messages = messages[1:] -%}
13
+ {%- else -%}
14
+ {%- set first_user_prefix = "" -%}
15
+ {%- set loop_messages = messages -%}
16
+ {%- endif -%}
17
+ {%- for message in loop_messages -%}
18
+ {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
19
+ {{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
20
+ {%- endif -%}
21
+ {%- if (message['role'] == 'assistant') -%}
22
+ {%- set role = "model" -%}
23
+ {%- else -%}
24
+ {%- set role = message['role'] -%}
25
+ {%- endif -%}
26
+ {{ '<start_of_turn>' + role + '
27
+ ' + (first_user_prefix if loop.first else "") }}
28
+ {%- if message['content'] is string -%}
29
+ {{ message['content'] | trim }}
30
+ {%- elif message['content'] is iterable -%}
31
+ {%- for item in message['content'] -%}
32
+ {%- if item['type'] == 'audio' -%}
33
+ {{ '<audio_soft_token>' }}
34
+ {%- elif item['type'] == 'image' -%}
35
+ {{ '<image_soft_token>' }}
36
+ {%- elif item['type'] == 'text' -%}
37
+ {{ item['text'] | trim }}
38
+ {%- endif -%}
39
+ {%- endfor -%}
40
+ {%- else -%}
41
+ {{ raise_exception("Invalid content type") }}
42
+ {%- endif -%}
43
+ {{ '<end_of_turn>
44
+ ' }}
45
+ {%- endfor -%}
46
+ {%- if add_generation_prompt -%}
47
+ {{'<start_of_turn>model
48
+ '}}
49
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Gemma3nForConditionalGeneration"
4
+ ],
5
+ "audio_config": {
6
+ "conf_attention_chunk_size": 12,
7
+ "conf_attention_context_left": 13,
8
+ "conf_attention_context_right": 0,
9
+ "conf_attention_logit_cap": 50.0,
10
+ "conf_conv_kernel_size": 5,
11
+ "conf_num_attention_heads": 8,
12
+ "conf_num_hidden_layers": 12,
13
+ "conf_reduction_factor": 4,
14
+ "conf_residual_weight": 0.5,
15
+ "gradient_clipping": 10000000000.0,
16
+ "hidden_size": 1536,
17
+ "input_feat_size": 128,
18
+ "model_type": "gemma3n_audio",
19
+ "rms_norm_eps": 1e-06,
20
+ "sscp_conv_channel_size": [
21
+ 128,
22
+ 32
23
+ ],
24
+ "sscp_conv_group_norm_eps": 0.001,
25
+ "sscp_conv_kernel_size": [
26
+ [
27
+ 3,
28
+ 3
29
+ ],
30
+ [
31
+ 3,
32
+ 3
33
+ ]
34
+ ],
35
+ "sscp_conv_stride_size": [
36
+ [
37
+ 2,
38
+ 2
39
+ ],
40
+ [
41
+ 2,
42
+ 2
43
+ ]
44
+ ],
45
+ "torch_dtype": "bfloat16",
46
+ "vocab_offset": 262272,
47
+ "vocab_size": 128
48
+ },
49
+ "audio_soft_tokens_per_image": 188,
50
+ "audio_token_id": 262273,
51
+ "boa_token_id": 256000,
52
+ "boi_token_id": 255999,
53
+ "eoa_token_id": 262272,
54
+ "eoi_token_id": 262144,
55
+ "eos_token_id": [
56
+ 1,
57
+ 106
58
+ ],
59
+ "image_token_id": 262145,
60
+ "initializer_range": 0.02,
61
+ "model_type": "gemma3n",
62
+ "quantization": {
63
+ "group_size": 128,
64
+ "bits": 4
65
+ },
66
+ "quantization_config": {
67
+ "group_size": 128,
68
+ "bits": 4
69
+ },
70
+ "text_config": {
71
+ "activation_sparsity_pattern": [
72
+ 0.95,
73
+ 0.95,
74
+ 0.95,
75
+ 0.95,
76
+ 0.95,
77
+ 0.95,
78
+ 0.95,
79
+ 0.95,
80
+ 0.95,
81
+ 0.95,
82
+ 0.0,
83
+ 0.0,
84
+ 0.0,
85
+ 0.0,
86
+ 0.0,
87
+ 0.0,
88
+ 0.0,
89
+ 0.0,
90
+ 0.0,
91
+ 0.0,
92
+ 0.0,
93
+ 0.0,
94
+ 0.0,
95
+ 0.0,
96
+ 0.0,
97
+ 0.0,
98
+ 0.0,
99
+ 0.0,
100
+ 0.0,
101
+ 0.0,
102
+ 0.0,
103
+ 0.0,
104
+ 0.0,
105
+ 0.0,
106
+ 0.0
107
+ ],
108
+ "altup_active_idx": 0,
109
+ "altup_coef_clip": 120.0,
110
+ "altup_correct_scale": true,
111
+ "altup_num_inputs": 4,
112
+ "attention_bias": false,
113
+ "attention_dropout": 0.0,
114
+ "final_logit_softcapping": 30.0,
115
+ "head_dim": 256,
116
+ "hidden_activation": "gelu_pytorch_tanh",
117
+ "hidden_size": 2048,
118
+ "hidden_size_per_layer_input": 256,
119
+ "initializer_range": 0.02,
120
+ "intermediate_size": [
121
+ 16384,
122
+ 16384,
123
+ 16384,
124
+ 16384,
125
+ 16384,
126
+ 16384,
127
+ 16384,
128
+ 16384,
129
+ 16384,
130
+ 16384,
131
+ 16384,
132
+ 16384,
133
+ 16384,
134
+ 16384,
135
+ 16384,
136
+ 16384,
137
+ 16384,
138
+ 16384,
139
+ 16384,
140
+ 16384,
141
+ 16384,
142
+ 16384,
143
+ 16384,
144
+ 16384,
145
+ 16384,
146
+ 16384,
147
+ 16384,
148
+ 16384,
149
+ 16384,
150
+ 16384,
151
+ 16384,
152
+ 16384,
153
+ 16384,
154
+ 16384,
155
+ 16384
156
+ ],
157
+ "laurel_rank": 64,
158
+ "layer_types": [
159
+ "sliding_attention",
160
+ "sliding_attention",
161
+ "sliding_attention",
162
+ "sliding_attention",
163
+ "full_attention",
164
+ "sliding_attention",
165
+ "sliding_attention",
166
+ "sliding_attention",
167
+ "sliding_attention",
168
+ "full_attention",
169
+ "sliding_attention",
170
+ "sliding_attention",
171
+ "sliding_attention",
172
+ "sliding_attention",
173
+ "full_attention",
174
+ "sliding_attention",
175
+ "sliding_attention",
176
+ "sliding_attention",
177
+ "sliding_attention",
178
+ "full_attention",
179
+ "sliding_attention",
180
+ "sliding_attention",
181
+ "sliding_attention",
182
+ "sliding_attention",
183
+ "full_attention",
184
+ "sliding_attention",
185
+ "sliding_attention",
186
+ "sliding_attention",
187
+ "sliding_attention",
188
+ "full_attention",
189
+ "sliding_attention",
190
+ "sliding_attention",
191
+ "sliding_attention",
192
+ "sliding_attention",
193
+ "full_attention"
194
+ ],
195
+ "max_position_embeddings": 32768,
196
+ "model_type": "gemma3n_text",
197
+ "num_attention_heads": 8,
198
+ "num_hidden_layers": 35,
199
+ "num_key_value_heads": 2,
200
+ "num_kv_shared_layers": 15,
201
+ "rms_norm_eps": 1e-06,
202
+ "rope_local_base_freq": 10000.0,
203
+ "rope_scaling": null,
204
+ "rope_theta": 1000000.0,
205
+ "sliding_window": 512,
206
+ "torch_dtype": "bfloat16",
207
+ "use_cache": true,
208
+ "vocab_size": 262400,
209
+ "vocab_size_per_layer_input": 262144
210
+ },
211
+ "torch_dtype": "bfloat16",
212
+ "transformers_version": "4.53.0.dev0",
213
+ "vision_soft_tokens_per_image": 256
214
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "cache_implementation": "hybrid",
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 1,
7
+ 106
8
+ ],
9
+ "pad_token_id": 0,
10
+ "top_k": 64,
11
+ "top_p": 0.95,
12
+ "transformers_version": "4.54.0.dev0"
13
+ }
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cdb2552d677df16d2d61903cf4c9435b8fe224d8eda9a59d67e087a1a94f9ee1
3
+ size 3655761240
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
special_tokens_map.json ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "audio_token": "<audio_soft_token>",
3
+ "boa_token": "<start_of_audio>",
4
+ "boi_token": "<start_of_image>",
5
+ "bos_token": {
6
+ "content": "<bos>",
7
+ "lstrip": false,
8
+ "normalized": false,
9
+ "rstrip": false,
10
+ "single_word": false
11
+ },
12
+ "eoa_token": "<end_of_audio>",
13
+ "eoi_token": "<end_of_image>",
14
+ "eos_token": {
15
+ "content": "<eos>",
16
+ "lstrip": false,
17
+ "normalized": false,
18
+ "rstrip": false,
19
+ "single_word": false
20
+ },
21
+ "image_token": "<image_soft_token>",
22
+ "pad_token": {
23
+ "content": "<pad>",
24
+ "lstrip": false,
25
+ "normalized": false,
26
+ "rstrip": false,
27
+ "single_word": false
28
+ },
29
+ "unk_token": {
30
+ "content": "<unk>",
31
+ "lstrip": false,
32
+ "normalized": false,
33
+ "rstrip": false,
34
+ "single_word": false
35
+ }
36
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b6c35ee648c07754b44cd9e371c75d4caa05c4504910b7ad29b1847ee9d8ba5d
3
+ size 33442553
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff