andosen commited on
Commit
d9bb05d
·
verified ·
1 Parent(s): 41b2f81

Upload folder using huggingface_hub

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,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
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
+ language: en
8
+ extra_gated_heading: Access MedGemma on Hugging Face
9
+ extra_gated_prompt: To access MedGemma on Hugging Face, you're required to review
10
+ and agree to [Health AI Developer Foundation's terms of use](https://developers.google.com/health-ai-developer-foundations/terms).
11
+ To do this, please ensure you're logged in to Hugging Face and click below. Requests
12
+ are processed immediately.
13
+ extra_gated_button_content: Acknowledge license
14
+ tags:
15
+ - medical
16
+ - x-ray
17
+ - pathology
18
+ - dermatology
19
+ - fundus
20
+ - radiology report generation
21
+ - chest-x-ray
22
+ - medical-embeddings
23
+ - image-classification
24
+ - zero-shot-image-classification
25
+ - image-feature-extraction
26
+ - image-text-to-text
27
+ - mlx
28
+ - mlx-my-repo
29
+ base_model: google/medgemma-27b-it
30
+ ---
31
+
32
+ # andosen/medgemma-27b-it-mlx-5Bit
33
+
34
+ The Model [andosen/medgemma-27b-it-mlx-5Bit](https://huggingface.co/andosen/medgemma-27b-it-mlx-5Bit) was converted to MLX format from [google/medgemma-27b-it](https://huggingface.co/google/medgemma-27b-it) using mlx-lm version **0.31.2**.
35
+
36
+ ## Use with mlx
37
+
38
+ ```bash
39
+ pip install mlx-lm
40
+ ```
41
+
42
+ ```python
43
+ from mlx_lm import load, generate
44
+
45
+ model, tokenizer = load("andosen/medgemma-27b-it-mlx-5Bit")
46
+
47
+ prompt="hello"
48
+
49
+ if hasattr(tokenizer, "apply_chat_template") and tokenizer.chat_template is not None:
50
+ messages = [{"role": "user", "content": prompt}]
51
+ prompt = tokenizer.apply_chat_template(
52
+ messages, tokenize=False, add_generation_prompt=True
53
+ )
54
+
55
+ response = generate(model, tokenizer, prompt=prompt, verbose=True)
56
+ ```
chat_template.jinja ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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'] == 'image' -%}
33
+ {{ '<start_of_image>' }}
34
+ {%- elif item['type'] == 'text' -%}
35
+ {{ item['text'] | trim }}
36
+ {%- endif -%}
37
+ {%- endfor -%}
38
+ {%- else -%}
39
+ {{ raise_exception("Invalid content type") }}
40
+ {%- endif -%}
41
+ {{ '<end_of_turn>
42
+ ' }}
43
+ {%- endfor -%}
44
+ {%- if add_generation_prompt -%}
45
+ {{'<start_of_turn>model
46
+ '}}
47
+ {%- endif -%}
config.json ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": 5,
18
+ "mode": "affine"
19
+ },
20
+ "quantization_config": {
21
+ "group_size": 64,
22
+ "bits": 5,
23
+ "mode": "affine"
24
+ },
25
+ "text_config": {
26
+ "attention_bias": false,
27
+ "attention_dropout": 0.0,
28
+ "attn_logit_softcapping": null,
29
+ "final_logit_softcapping": null,
30
+ "head_dim": 128,
31
+ "hidden_activation": "gelu_pytorch_tanh",
32
+ "hidden_size": 5376,
33
+ "initializer_range": 0.02,
34
+ "intermediate_size": 21504,
35
+ "layer_types": [
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "sliding_attention",
40
+ "sliding_attention",
41
+ "full_attention",
42
+ "sliding_attention",
43
+ "sliding_attention",
44
+ "sliding_attention",
45
+ "sliding_attention",
46
+ "sliding_attention",
47
+ "full_attention",
48
+ "sliding_attention",
49
+ "sliding_attention",
50
+ "sliding_attention",
51
+ "sliding_attention",
52
+ "sliding_attention",
53
+ "full_attention",
54
+ "sliding_attention",
55
+ "sliding_attention",
56
+ "sliding_attention",
57
+ "sliding_attention",
58
+ "sliding_attention",
59
+ "full_attention",
60
+ "sliding_attention",
61
+ "sliding_attention",
62
+ "sliding_attention",
63
+ "sliding_attention",
64
+ "sliding_attention",
65
+ "full_attention",
66
+ "sliding_attention",
67
+ "sliding_attention",
68
+ "sliding_attention",
69
+ "sliding_attention",
70
+ "sliding_attention",
71
+ "full_attention",
72
+ "sliding_attention",
73
+ "sliding_attention",
74
+ "sliding_attention",
75
+ "sliding_attention",
76
+ "sliding_attention",
77
+ "full_attention",
78
+ "sliding_attention",
79
+ "sliding_attention",
80
+ "sliding_attention",
81
+ "sliding_attention",
82
+ "sliding_attention",
83
+ "full_attention",
84
+ "sliding_attention",
85
+ "sliding_attention",
86
+ "sliding_attention",
87
+ "sliding_attention",
88
+ "sliding_attention",
89
+ "full_attention",
90
+ "sliding_attention",
91
+ "sliding_attention",
92
+ "sliding_attention",
93
+ "sliding_attention",
94
+ "sliding_attention",
95
+ "full_attention",
96
+ "sliding_attention",
97
+ "sliding_attention"
98
+ ],
99
+ "max_position_embeddings": 131072,
100
+ "model_type": "gemma3_text",
101
+ "num_attention_heads": 32,
102
+ "num_hidden_layers": 62,
103
+ "num_key_value_heads": 16,
104
+ "query_pre_attn_scalar": 168,
105
+ "rms_norm_eps": 1e-06,
106
+ "rope_local_base_freq": 10000,
107
+ "rope_scaling": {
108
+ "factor": 8.0,
109
+ "rope_type": "linear"
110
+ },
111
+ "rope_theta": 1000000,
112
+ "sliding_window": 1024,
113
+ "torch_dtype": "bfloat16",
114
+ "use_cache": true,
115
+ "vocab_size": 262208
116
+ },
117
+ "torch_dtype": "bfloat16",
118
+ "transformers_version": "4.54.0.dev0"
119
+ }
generation_config.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_from_model_config": true,
3
+ "bos_token_id": 2,
4
+ "eos_token_id": [
5
+ 1,
6
+ 106
7
+ ],
8
+ "pad_token_id": 0,
9
+ "transformers_version": "4.54.0.dev0"
10
+ }
model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9a0b7d9d36cc6658c30662b3558da1cc3b99d474f54b797dd61208b1a73ab001
3
+ size 5352516209
model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5ebebb9a611f57863300700506198bcb1b8244333d15b728598c931bdc8ce02f
3
+ size 5314617572
model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8189d0817bc7b227dbc578ee9d22c7334f6fa6953ec672dd8b992373d9468eb4
3
+ size 5363817216
model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aebc8c2603d26a1ad27a845f4a9d8bc04128f7bca18565b87cdeea610ac7aa75
3
+ size 2539970006
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:daab2354f8a74e70d70b4d1f804939b68a8c9624dd06cb7858e52dd8970e9726
3
+ size 33384567
tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "boi_token": "<start_of_image>",
4
+ "bos_token": "<bos>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eoi_token": "<end_of_image>",
7
+ "eos_token": "<eos>",
8
+ "image_token": "<image_soft_token>",
9
+ "is_local": true,
10
+ "mask_token": "<mask>",
11
+ "model_max_length": 1000000000000000019884624838656,
12
+ "model_specific_special_tokens": {
13
+ "boi_token": "<start_of_image>",
14
+ "eoi_token": "<end_of_image>",
15
+ "image_token": "<image_soft_token>"
16
+ },
17
+ "pad_token": "<pad>",
18
+ "processor_class": "Gemma3Processor",
19
+ "sp_model_kwargs": null,
20
+ "spaces_between_special_tokens": false,
21
+ "tokenizer_class": "GemmaTokenizer",
22
+ "unk_token": "<unk>",
23
+ "use_default_system_prompt": false
24
+ }