warshanks commited on
Commit
37c2d35
·
verified ·
1 Parent(s): 04f7853

Upload folder using huggingface_hub

Browse files
README.md CHANGED
@@ -2,15 +2,15 @@
2
  license: other
3
  license_name: health-ai-developer-foundations
4
  license_link: https://developers.google.com/health-ai-developer-foundations/terms
5
- library_name: mlx
6
- pipeline_tag: text-generation
7
  extra_gated_heading: Access MedGemma on Hugging Face
8
  extra_gated_prompt: To access MedGemma on Hugging Face, you're required to review
9
  and agree to [Health AI Developer Foundation's terms of use](https://developers.google.com/health-ai-developer-foundations/terms).
10
  To do this, please ensure you're logged in to Hugging Face and click below. Requests
11
  are processed immediately.
12
  extra_gated_button_content: Acknowledge license
13
- base_model: google/medgemma-4b-it
14
  tags:
15
  - medical
16
  - radiology
@@ -23,29 +23,14 @@ tags:
23
  ---
24
 
25
  # mlx-community/medgemma-4b-it-8bit
26
-
27
- This model [mlx-community/medgemma-4b-it-8bit](https://huggingface.co/mlx-community/medgemma-4b-it-8bit) was
28
- converted to MLX format from [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it)
29
- using mlx-lm version **0.24.1**.
30
-
31
  ## Use with mlx
32
 
33
  ```bash
34
- pip install mlx-lm
35
  ```
36
 
37
- ```python
38
- from mlx_lm import load, generate
39
-
40
- model, tokenizer = load("mlx-community/medgemma-4b-it-8bit")
41
-
42
- prompt = "hello"
43
-
44
- if tokenizer.chat_template is not None:
45
- messages = [{"role": "user", "content": prompt}]
46
- prompt = tokenizer.apply_chat_template(
47
- messages, add_generation_prompt=True
48
- )
49
-
50
- response = generate(model, tokenizer, prompt=prompt, verbose=True)
51
  ```
 
2
  license: other
3
  license_name: health-ai-developer-foundations
4
  license_link: https://developers.google.com/health-ai-developer-foundations/terms
5
+ library_name: transformers
6
+ pipeline_tag: image-text-to-text
7
  extra_gated_heading: Access MedGemma on Hugging Face
8
  extra_gated_prompt: To access MedGemma on Hugging Face, you're required to review
9
  and agree to [Health AI Developer Foundation's terms of use](https://developers.google.com/health-ai-developer-foundations/terms).
10
  To do this, please ensure you're logged in to Hugging Face and click below. Requests
11
  are processed immediately.
12
  extra_gated_button_content: Acknowledge license
13
+ base_model: google/medgemma-4b-pt
14
  tags:
15
  - medical
16
  - radiology
 
23
  ---
24
 
25
  # mlx-community/medgemma-4b-it-8bit
26
+ This model was converted to MLX format from [`google/medgemma-4b-it`]() using mlx-vlm version **0.1.26**.
27
+ Refer to the [original model card](https://huggingface.co/google/medgemma-4b-it) for more details on the model.
 
 
 
28
  ## Use with mlx
29
 
30
  ```bash
31
+ pip install -U mlx-vlm
32
  ```
33
 
34
+ ```bash
35
+ python -m mlx_vlm.generate --model mlx-community/medgemma-4b-it-8bit --max-tokens 100 --temperature 0.0 --prompt "Describe this image." --image <path_to_image>
 
 
 
 
 
 
 
 
 
 
 
 
36
  ```
config.json CHANGED
@@ -1,55 +1,239 @@
1
  {
 
2
  "architectures": [
3
  "Gemma3ForConditionalGeneration"
4
  ],
 
 
5
  "boi_token_index": 255999,
 
 
 
 
 
 
 
 
6
  "eoi_token_index": 256000,
7
  "eos_token_id": [
8
  1,
9
  106
10
  ],
 
 
 
 
 
 
 
 
11
  "image_token_index": 262144,
12
  "initializer_range": 0.02,
 
 
 
 
 
 
 
 
 
13
  "mm_tokens_per_image": 256,
14
  "model_type": "gemma3",
 
 
 
 
 
 
 
 
 
 
 
15
  "quantization": {
16
  "group_size": 64,
17
  "bits": 8
18
  },
19
- "quantization_config": {
20
- "group_size": 64,
21
- "bits": 8
22
- },
 
 
 
 
23
  "text_config": {
24
- "attention_bias": false,
25
- "attention_dropout": 0.0,
26
- "attn_logit_softcapping": null,
27
- "cache_implementation": "hybrid",
28
- "final_logit_softcapping": null,
29
- "head_dim": 256,
30
- "hidden_activation": "gelu_pytorch_tanh",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  "hidden_size": 2560,
32
- "initializer_range": 0.02,
33
  "intermediate_size": 10240,
34
- "max_position_embeddings": 131072,
35
- "model_type": "gemma3_text",
36
- "num_attention_heads": 8,
37
  "num_hidden_layers": 34,
 
 
38
  "num_key_value_heads": 4,
39
- "query_pre_attn_scalar": 256,
40
  "rms_norm_eps": 1e-06,
 
 
 
 
 
 
 
 
 
 
41
  "rope_local_base_freq": 10000,
 
42
  "rope_scaling": {
43
  "factor": 8.0,
44
  "rope_type": "linear"
45
- },
46
- "rope_theta": 1000000,
47
- "sliding_window": 1024,
48
- "sliding_window_pattern": 6,
49
- "torch_dtype": "bfloat16",
50
- "use_cache": true,
51
- "vocab_size": 262208
52
  },
53
- "torch_dtype": "bfloat16",
54
- "transformers_version": "4.52.0.dev0"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
 
1
  {
2
+ "add_cross_attention": false,
3
  "architectures": [
4
  "Gemma3ForConditionalGeneration"
5
  ],
6
+ "bad_words_ids": null,
7
+ "begin_suppress_tokens": null,
8
  "boi_token_index": 255999,
9
+ "bos_token_id": null,
10
+ "chunk_size_feed_forward": 0,
11
+ "cross_attention_hidden_size": null,
12
+ "decoder_start_token_id": null,
13
+ "diversity_penalty": 0.0,
14
+ "do_sample": false,
15
+ "early_stopping": false,
16
+ "encoder_no_repeat_ngram_size": 0,
17
  "eoi_token_index": 256000,
18
  "eos_token_id": [
19
  1,
20
  106
21
  ],
22
+ "exponential_decay_length_penalty": null,
23
+ "finetuning_task": null,
24
+ "forced_bos_token_id": null,
25
+ "forced_eos_token_id": null,
26
+ "id2label": {
27
+ "0": "LABEL_0",
28
+ "1": "LABEL_1"
29
+ },
30
  "image_token_index": 262144,
31
  "initializer_range": 0.02,
32
+ "is_decoder": false,
33
+ "is_encoder_decoder": false,
34
+ "label2id": {
35
+ "LABEL_0": 0,
36
+ "LABEL_1": 1
37
+ },
38
+ "length_penalty": 1.0,
39
+ "max_length": 20,
40
+ "min_length": 0,
41
  "mm_tokens_per_image": 256,
42
  "model_type": "gemma3",
43
+ "no_repeat_ngram_size": 0,
44
+ "num_beam_groups": 1,
45
+ "num_beams": 1,
46
+ "num_return_sequences": 1,
47
+ "output_attentions": false,
48
+ "output_hidden_states": false,
49
+ "output_scores": false,
50
+ "pad_token_id": null,
51
+ "prefix": null,
52
+ "problem_type": null,
53
+ "pruned_heads": {},
54
  "quantization": {
55
  "group_size": 64,
56
  "bits": 8
57
  },
58
+ "remove_invalid_values": false,
59
+ "repetition_penalty": 1.0,
60
+ "return_dict": true,
61
+ "return_dict_in_generate": false,
62
+ "sep_token_id": null,
63
+ "suppress_tokens": null,
64
+ "task_specific_params": null,
65
+ "temperature": 1.0,
66
  "text_config": {
67
+ "return_dict": true,
68
+ "output_hidden_states": false,
69
+ "output_attentions": false,
70
+ "torchscript": false,
71
+ "torch_dtype": "bfloat16",
72
+ "use_bfloat16": false,
73
+ "tf_legacy_loss": false,
74
+ "pruned_heads": {},
75
+ "tie_word_embeddings": true,
76
+ "chunk_size_feed_forward": 0,
77
+ "is_encoder_decoder": false,
78
+ "is_decoder": false,
79
+ "cross_attention_hidden_size": null,
80
+ "add_cross_attention": false,
81
+ "tie_encoder_decoder": false,
82
+ "max_length": 20,
83
+ "min_length": 0,
84
+ "do_sample": false,
85
+ "early_stopping": false,
86
+ "num_beams": 1,
87
+ "num_beam_groups": 1,
88
+ "diversity_penalty": 0.0,
89
+ "temperature": 1.0,
90
+ "top_k": 50,
91
+ "top_p": 1.0,
92
+ "typical_p": 1.0,
93
+ "repetition_penalty": 1.0,
94
+ "length_penalty": 1.0,
95
+ "no_repeat_ngram_size": 0,
96
+ "encoder_no_repeat_ngram_size": 0,
97
+ "bad_words_ids": null,
98
+ "num_return_sequences": 1,
99
+ "output_scores": false,
100
+ "return_dict_in_generate": false,
101
+ "forced_bos_token_id": null,
102
+ "forced_eos_token_id": null,
103
+ "remove_invalid_values": false,
104
+ "exponential_decay_length_penalty": null,
105
+ "suppress_tokens": null,
106
+ "begin_suppress_tokens": null,
107
+ "architectures": null,
108
+ "finetuning_task": null,
109
+ "id2label": {
110
+ "0": "LABEL_0",
111
+ "1": "LABEL_1"
112
+ },
113
+ "label2id": {
114
+ "LABEL_0": 0,
115
+ "LABEL_1": 1
116
+ },
117
+ "tokenizer_class": null,
118
+ "prefix": null,
119
+ "bos_token_id": 2,
120
+ "pad_token_id": 0,
121
+ "eos_token_id": 1,
122
+ "sep_token_id": null,
123
+ "decoder_start_token_id": null,
124
+ "task_specific_params": null,
125
+ "problem_type": null,
126
+ "_name_or_path": "",
127
+ "model_type": "gemma3_text",
128
+ "vocab_size": 262208,
129
+ "max_position_embeddings": 131072,
130
  "hidden_size": 2560,
 
131
  "intermediate_size": 10240,
 
 
 
132
  "num_hidden_layers": 34,
133
+ "num_attention_heads": 8,
134
+ "head_dim": 256,
135
  "num_key_value_heads": 4,
136
+ "initializer_range": 0.02,
137
  "rms_norm_eps": 1e-06,
138
+ "use_cache": true,
139
+ "rope_theta": 1000000,
140
+ "attention_bias": false,
141
+ "attention_dropout": 0.0,
142
+ "hidden_activation": "gelu_pytorch_tanh",
143
+ "query_pre_attn_scalar": 256,
144
+ "sliding_window": 1024,
145
+ "final_logit_softcapping": null,
146
+ "attn_logit_softcapping": null,
147
+ "cache_implementation": "hybrid",
148
  "rope_local_base_freq": 10000,
149
+ "sliding_window_pattern": 6,
150
  "rope_scaling": {
151
  "factor": 8.0,
152
  "rope_type": "linear"
153
+ }
 
 
 
 
 
 
154
  },
155
+ "tf_legacy_loss": false,
156
+ "tie_encoder_decoder": false,
157
+ "tie_word_embeddings": true,
158
+ "tokenizer_class": null,
159
+ "top_k": 50,
160
+ "top_p": 1.0,
161
+ "torchscript": false,
162
+ "transformers_version": "4.52.1",
163
+ "typical_p": 1.0,
164
+ "use_bfloat16": false,
165
+ "vision_config": {
166
+ "return_dict": true,
167
+ "output_hidden_states": false,
168
+ "output_attentions": false,
169
+ "torchscript": false,
170
+ "torch_dtype": "bfloat16",
171
+ "use_bfloat16": false,
172
+ "tf_legacy_loss": false,
173
+ "pruned_heads": {},
174
+ "tie_word_embeddings": true,
175
+ "chunk_size_feed_forward": 0,
176
+ "is_encoder_decoder": false,
177
+ "is_decoder": false,
178
+ "cross_attention_hidden_size": null,
179
+ "add_cross_attention": false,
180
+ "tie_encoder_decoder": false,
181
+ "max_length": 20,
182
+ "min_length": 0,
183
+ "do_sample": false,
184
+ "early_stopping": false,
185
+ "num_beams": 1,
186
+ "num_beam_groups": 1,
187
+ "diversity_penalty": 0.0,
188
+ "temperature": 1.0,
189
+ "top_k": 50,
190
+ "top_p": 1.0,
191
+ "typical_p": 1.0,
192
+ "repetition_penalty": 1.0,
193
+ "length_penalty": 1.0,
194
+ "no_repeat_ngram_size": 0,
195
+ "encoder_no_repeat_ngram_size": 0,
196
+ "bad_words_ids": null,
197
+ "num_return_sequences": 1,
198
+ "output_scores": false,
199
+ "return_dict_in_generate": false,
200
+ "forced_bos_token_id": null,
201
+ "forced_eos_token_id": null,
202
+ "remove_invalid_values": false,
203
+ "exponential_decay_length_penalty": null,
204
+ "suppress_tokens": null,
205
+ "begin_suppress_tokens": null,
206
+ "architectures": null,
207
+ "finetuning_task": null,
208
+ "id2label": {
209
+ "0": "LABEL_0",
210
+ "1": "LABEL_1"
211
+ },
212
+ "label2id": {
213
+ "LABEL_0": 0,
214
+ "LABEL_1": 1
215
+ },
216
+ "tokenizer_class": null,
217
+ "prefix": null,
218
+ "bos_token_id": null,
219
+ "pad_token_id": null,
220
+ "eos_token_id": null,
221
+ "sep_token_id": null,
222
+ "decoder_start_token_id": null,
223
+ "task_specific_params": null,
224
+ "problem_type": null,
225
+ "_name_or_path": "",
226
+ "model_type": "siglip_vision_model",
227
+ "vision_use_head": false,
228
+ "hidden_size": 1152,
229
+ "intermediate_size": 4304,
230
+ "num_hidden_layers": 27,
231
+ "num_attention_heads": 16,
232
+ "num_channels": 3,
233
+ "patch_size": 14,
234
+ "image_size": 896,
235
+ "attention_dropout": 0.0,
236
+ "layer_norm_eps": 1e-06,
237
+ "hidden_act": "gelu_pytorch_tanh"
238
+ }
239
  }
model-00001-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:43cf33532452cb55caf9fb477e1262c40a5fd1f3aae1d77137c283e9df06ddac
3
+ size 5364030232
model-00002-of-00002.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5542c73b1575a246b8d19b26fd3989dee72328c3b52738f5717cd221328a5613
3
+ size 47854294
model.safetensors.index.json CHANGED
The diff for this file is too large to render. See raw diff
 
preprocessor_config.json ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "do_convert_rgb": null,
3
+ "do_normalize": true,
4
+ "do_pan_and_scan": null,
5
+ "do_rescale": true,
6
+ "do_resize": true,
7
+ "image_mean": [
8
+ 0.5,
9
+ 0.5,
10
+ 0.5
11
+ ],
12
+ "image_processor_type": "Gemma3ImageProcessor",
13
+ "image_seq_length": 256,
14
+ "image_std": [
15
+ 0.5,
16
+ 0.5,
17
+ 0.5
18
+ ],
19
+ "pan_and_scan_max_num_crops": null,
20
+ "pan_and_scan_min_crop_size": null,
21
+ "pan_and_scan_min_ratio_to_activate": null,
22
+ "processor_class": "Gemma3Processor",
23
+ "resample": 2,
24
+ "rescale_factor": 0.00392156862745098,
25
+ "size": {
26
+ "height": 896,
27
+ "width": 896
28
+ }
29
+ }
processor_config.json ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ {
2
+ "image_seq_length": 256,
3
+ "processor_class": "Gemma3Processor"
4
+ }