danielhanchen commited on
Commit
c3017ea
·
verified ·
1 Parent(s): dd66a57

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,546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ extra_gated_heading: Access MedGemma on Hugging Face
8
+ extra_gated_prompt: >-
9
+ To access MedGemma on Hugging Face, you're required to review and agree to
10
+ [Health AI Developer Foundation's terms of
11
+ use](https://developers.google.com/health-ai-developer-foundations/terms). To
12
+ do this, please ensure you're logged in to Hugging Face and click below.
13
+ Requests are processed immediately.
14
+ extra_gated_button_content: Acknowledge license
15
+ base_model:
16
+ - google/medgemma-27b-text-it
17
+ tags:
18
+ - medical
19
+ - unsloth
20
+ - unsloth
21
+ - clinical-reasoning
22
+ - thinking
23
+ ---
24
+ <div>
25
+ <p style="margin-top: 0;margin-bottom: 0;">
26
+ <em><a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>
27
+ </p>
28
+ <div style="display: flex; gap: 5px; align-items: center; ">
29
+ <a href="https://github.com/unslothai/unsloth/">
30
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
31
+ </a>
32
+ <a href="https://discord.gg/unsloth">
33
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
34
+ </a>
35
+ <a href="https://docs.unsloth.ai/basics/qwen3-how-to-run-and-fine-tune">
36
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
37
+ </a>
38
+ </div>
39
+ </div>
40
+
41
+ <div>
42
+ <p style="margin-top: 0;margin-bottom: 0;">
43
+ <em><a href="https://docs.unsloth.ai/basics/unsloth-dynamic-v2.0-gguf">Unsloth Dynamic 2.0</a> achieves superior accuracy & outperforms other leading quants.</em>
44
+ </p>
45
+ <div style="display: flex; gap: 5px; align-items: center; ">
46
+ <a href="https://github.com/unslothai/unsloth/">
47
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/unsloth%20new%20logo.png" width="133">
48
+ </a>
49
+ <a href="https://discord.gg/unsloth">
50
+ <img src="https://github.com/unslothai/unsloth/raw/main/images/Discord%20button.png" width="173">
51
+ </a>
52
+ <a href="https://docs.unsloth.ai/basics/qwen3-how-to-run-and-fine-tune">
53
+ <img src="https://raw.githubusercontent.com/unslothai/unsloth/refs/heads/main/images/documentation%20green%20button.png" width="143">
54
+ </a>
55
+ </div>
56
+ </div>
57
+
58
+
59
+ # MedGemma model card
60
+
61
+ **Model documentation:** [MedGemma](https://developers.google.com/health-ai-developer-foundations/medgemma)
62
+
63
+ **Resources:**
64
+
65
+ * Model on Google Cloud Model Garden: [MedGemma](https://console.cloud.google.com/vertex-ai/publishers/google/model-garden/medgemma)
66
+ * Model on Hugging Face: [MedGemma](https://huggingface.co/collections/google/medgemma-release-680aade845f90bec6a3f60c4)
67
+ * GitHub repository (supporting code, Colab notebooks, discussions, and
68
+ issues): [MedGemma](https://github.com/google-health/medgemma)
69
+ * Quick start notebook: [GitHub](https://github.com/google-health/medgemma/blob/main/notebooks/quick_start_with_hugging_face.ipynb)
70
+ * Fine-tuning notebook: [GitHub](https://github.com/google-health/medgemma/blob/main/notebooks/fine_tune_with_hugging_face.ipynb)
71
+ * [Patient Education Demo built using MedGemma](https://huggingface.co/spaces/google/rad_explain)
72
+ * Support: See [Contact](https://developers.google.com/health-ai-developer-foundations/medgemma/get-started.md#contact)
73
+ * License: The use of MedGemma is governed by the [Health AI Developer
74
+ Foundations terms of
75
+ use](https://developers.google.com/health-ai-developer-foundations/terms).
76
+
77
+ **Author:** Google
78
+
79
+ ## Model information
80
+
81
+ This section describes the MedGemma model and how to use it.
82
+
83
+ ### Description
84
+
85
+ MedGemma is a collection of [Gemma 3](https://ai.google.dev/gemma/docs/core)
86
+ variants that are trained for performance on medical text and image
87
+ comprehension. Developers can use MedGemma to accelerate building
88
+ healthcare-based AI applications. MedGemma currently comes in two variants: a 4B
89
+ multimodal version and a 27B text-only version.
90
+
91
+ MedGemma 27B has been trained exclusively on medical text and optimized for
92
+ inference-time computation. MedGemma 27B is only available as an
93
+ instruction-tuned model.
94
+
95
+ MedGemma variants have been evaluated on a range of clinically relevant
96
+ benchmarks to illustrate their baseline performance. These include both open
97
+ benchmark datasets and curated datasets. Developers can fine-tune MedGemma
98
+ variants for improved performance. Consult the Intended Use section below for
99
+ more details.
100
+
101
+ A full technical report will be available soon.
102
+
103
+ ### How to use
104
+
105
+ Below are some example code snippets to help you quickly get started running the
106
+ model locally on GPU. If you want to use the model at scale, we recommend that
107
+ you create a production version using [Model
108
+ Garden](https://cloud.google.com/model-garden).
109
+
110
+ First, install the Transformers library. Gemma 3 is supported starting from
111
+ transformers 4.50.0.
112
+
113
+ ```sh
114
+ $ pip install -U transformers
115
+ ```
116
+
117
+ **Run model with the `pipeline` API**
118
+
119
+ ```python
120
+ from transformers import pipeline
121
+ import torch
122
+
123
+ pipe = pipeline(
124
+ "text-generation",
125
+ model="google/medgemma-27b-text-it",
126
+ torch_dtype=torch.bfloat16,
127
+ device="cuda",
128
+ )
129
+
130
+ messages = [
131
+ {
132
+ "role": "system",
133
+ "content": "You are a helpful medical assistant."
134
+ },
135
+ {
136
+ "role": "user",
137
+ "content": "How do you differentiate bacterial from viral pneumonia?"
138
+ }
139
+ ]
140
+
141
+ output = pipe(text=messages, max_new_tokens=200)
142
+ print(output[0]["generated_text"][-1]["content"])
143
+ ```
144
+
145
+ **Run the model directly**
146
+
147
+ ```python
148
+ # pip install accelerate
149
+ from transformers import AutoTokenizer, AutoModelForCausalLM
150
+ import torch
151
+
152
+ model_id = "google/medgemma-27b-text-it"
153
+
154
+ model = AutoModelForCausalLM.from_pretrained(
155
+ model_id,
156
+ torch_dtype=torch.bfloat16,
157
+ device_map="auto",
158
+ )
159
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
160
+
161
+ messages = [
162
+ {
163
+ "role": "system",
164
+ "content": "You are a helpful medical assistant."
165
+ },
166
+ {
167
+ "role": "user",
168
+ "content": "How do you differentiate bacterial from viral pneumonia?"
169
+ }
170
+ ]
171
+
172
+ inputs = tokenizer.apply_chat_template(
173
+ messages,
174
+ add_generation_prompt=True,
175
+ tokenize=True,
176
+ return_dict=True,
177
+ return_tensors="pt",
178
+ ).to(model.device)
179
+
180
+ input_len = inputs["input_ids"].shape[-1]
181
+
182
+ with torch.inference_mode():
183
+ generation = model.generate(**inputs, max_new_tokens=200, do_sample=False)
184
+ generation = generation[0][input_len:]
185
+
186
+ decoded = tokenizer.decode(generation, skip_special_tokens=True)
187
+ print(decoded)
188
+ ```
189
+
190
+ ### Examples
191
+
192
+ See the following Colab notebooks for examples of how to use MedGemma:
193
+
194
+ * To give the model a quick try, running it locally with weights from Hugging
195
+ Face, see [Quick start notebook in
196
+ Colab](https://colab.research.google.com/github/google-health/medgemma/blob/main/notebooks/quick_start_with_hugging_face.ipynb). Note that you will need to use Colab
197
+ Enterprise to run the 27B model without quantization.
198
+
199
+ * For an example of fine-tuning the model, see the [Fine-tuning notebook in
200
+ Colab](https://colab.research.google.com/github/google-health/medgemma/blob/main/notebooks/fine_tune_with_hugging_face.ipynb).
201
+
202
+ ### Model architecture overview
203
+
204
+ The MedGemma model is built based on [Gemma 3](https://ai.google.dev/gemma/) and
205
+ uses the same decoder-only transformer architecture as Gemma 3. To read more
206
+ about the architecture, consult the Gemma 3 [model
207
+ card](https://ai.google.dev/gemma/docs/core/model_card_3).
208
+
209
+ ### Technical specifications
210
+
211
+ * **Model type**: Decoder-only Transformer architecture, see the [Gemma 3
212
+ technical
213
+ report](https://storage.googleapis.com/deepmind-media/gemma/Gemma3Report.pdf)
214
+ * **Modalities**: **4B**: Text, vision; **27B**: Text only
215
+ * **Attention mechanism**: Utilizes grouped-query attention (GQA)
216
+ * **Context length**: Supports long context, at least 128K tokens
217
+ * **Key publication**: Coming soon
218
+ * **Model created**: May 20, 2025
219
+ * **Model version**: 1.0.0
220
+
221
+ ### Citation
222
+
223
+ A technical report is coming soon. In the meantime, if you publish using this
224
+ model, please cite the Hugging Face model page:
225
+
226
+ ```none
227
+ @misc{medgemma-hf,
228
+ author = {Google},
229
+ title = {MedGemma Hugging Face}
230
+ howpublished = {\url{https://huggingface.co/collections/google/medgemma-release-680aade845f90bec6a3f60c4}},
231
+ year = {2025},
232
+ note = {Accessed: [Insert Date Accessed, e.g., 2025-05-20]}
233
+ }
234
+ ```
235
+
236
+ ### Inputs and outputs
237
+
238
+ **Input**:
239
+
240
+ * Text string, such as a question or prompt
241
+ * Total input length of 128K tokens
242
+
243
+ **Output**:
244
+
245
+ * Generated text in response to the input, such as an answer to a question,
246
+ analysis of image content, or a summary of a document
247
+ * Total output length of 8192 tokens
248
+
249
+ ### Performance and validation
250
+
251
+ MedGemma was evaluated across a range of different multimodal classification,
252
+ report generation, visual question answering, and text-based tasks.
253
+
254
+ ### Key performance metrics
255
+
256
+ #### Text evaluations
257
+
258
+ MedGemma 4B and text-only MedGemma 27B were evaluated across a range of
259
+ text-only benchmarks for medical knowledge and reasoning.
260
+
261
+ The MedGemma models outperform their respective base Gemma models across all
262
+ tested text-only health benchmarks.
263
+
264
+ | Metric | MedGemma 27B | Gemma 3 27B | MedGemma 4B | Gemma 3 4B |
265
+ | :---- | :---- | :---- | :---- | :---- |
266
+ | MedQA (4-op) | 89.8 (best-of-5) 87.7 (0-shot) | 74.9 | 64.4 | 50.7 |
267
+ | MedMCQA | 74.2 | 62.6 | 55.7 | 45.4 |
268
+ | PubMedQA | 76.8 | 73.4 | 73.4 | 68.4 |
269
+ | MMLU Med (text only) | 87.0 | 83.3 | 70.0 | 67.2 |
270
+ | MedXpertQA (text only) | 26.7 | 15.7 | 14.2 | 11.6 |
271
+ | AfriMed-QA | 84.0 | 72.0 | 52.0 | 48.0 |
272
+
273
+ For all MedGemma 27B results, [test-time
274
+ scaling](https://arxiv.org/abs/2501.19393) is used to improve performance.
275
+
276
+ ### Ethics and safety evaluation
277
+
278
+ #### Evaluation approach
279
+
280
+ Our evaluation methods include structured evaluations and internal red-teaming
281
+ testing of relevant content policies. Red-teaming was conducted by a number of
282
+ different teams, each with different goals and human evaluation metrics. These
283
+ models were evaluated against a number of different categories relevant to
284
+ ethics and safety, including:
285
+
286
+ * **Child safety**: Evaluation of text-to-text and image-to-text prompts
287
+ covering child safety policies, including child sexual abuse and
288
+ exploitation.
289
+ * **Content safety:** Evaluation of text-to-text and image-to-text prompts
290
+ covering safety policies, including harassment, violence and gore, and hate
291
+ speech.
292
+ * **Representational harms**: Evaluation of text-to-text and image-to-text
293
+ prompts covering safety policies, including bias, stereotyping, and harmful
294
+ associations or inaccuracies.
295
+ * **General medical harms:** Evaluation of text-to-text and image-to-text
296
+ prompts covering safety policies, including information quality and harmful
297
+ associations or inaccuracies.
298
+
299
+ In addition to development level evaluations, we conduct "assurance evaluations"
300
+ which are our "arms-length" internal evaluations for responsibility governance
301
+ decision making. They are conducted separately from the model development team,
302
+ to inform decision making about release. High-level findings are fed back to the
303
+ model team, but prompt sets are held out to prevent overfitting and preserve the
304
+ results' ability to inform decision making. Notable assurance evaluation results
305
+ are reported to our Responsibility & Safety Council as part of release review.
306
+
307
+ #### Evaluation results
308
+
309
+ For all areas of safety testing, we saw safe levels of performance across the
310
+ categories of child safety, content safety, and representational harms. All
311
+ testing was conducted without safety filters to evaluate the model capabilities
312
+ and behaviors. For text-to-text, image-to-text, and audio-to-text, and across
313
+ both MedGemma model sizes, the model produced minimal policy violations. A
314
+ limitation of our evaluations was that they included primarily English language
315
+ prompts.
316
+
317
+ ## Data card
318
+
319
+ ### Dataset overview
320
+
321
+ #### Training
322
+
323
+ The base Gemma models are pre-trained on a large corpus of text and code data.
324
+ MedGemma 4B utilizes a [SigLIP](https://arxiv.org/abs/2303.15343) image encoder
325
+ that has been specifically pre-trained on a variety of de-identified medical
326
+ data, including radiology images, histopathology images, ophthalmology images,
327
+ and dermatology images. Its LLM component is trained on a diverse set of medical
328
+ data, including medical text relevant to radiology images, chest-x rays,
329
+ histopathology patches, ophthalmology images and dermatology images.
330
+
331
+ #### Evaluation
332
+
333
+ MedGemma models have been evaluated on a comprehensive set of clinically
334
+ relevant benchmarks, including over 22 datasets across 5 different tasks and 6
335
+ medical image modalities. These include both open benchmark datasets and curated
336
+ datasets, with a focus on expert human evaluations for tasks like CXR report
337
+ generation and radiology VQA.
338
+
339
+ #### Source
340
+
341
+ MedGemma utilizes a combination of public and private datasets.
342
+
343
+ This model was trained on diverse public datasets including MIMIC-CXR (chest
344
+ X-rays and reports), Slake-VQA (multimodal medical images and questions),
345
+ PAD-UFES-20 (skin lesion images and data), SCIN (dermatology images), TCGA
346
+ (cancer genomics data), CAMELYON (lymph node histopathology images), PMC-OA
347
+ (biomedical literature with images), and Mendeley Digital Knee X-Ray (knee
348
+ X-rays).
349
+
350
+ Additionally, multiple diverse proprietary datasets were licensed and
351
+ incorporated (described next).
352
+
353
+ ### Data Ownership and Documentation
354
+
355
+ * [Mimic-CXR](https://physionet.org/content/mimic-cxr/2.1.0/): MIT Laboratory
356
+ for Computational Physiology and Beth Israel Deaconess Medical Center
357
+ (BIDMC).
358
+ * [Slake-VQA](https://www.med-vqa.com/slake/): The Hong Kong Polytechnic
359
+ University (PolyU), with collaborators including West China Hospital of
360
+ Sichuan University and Sichuan Academy of Medical Sciences / Sichuan
361
+ Provincial People's Hospital.
362
+ * [PAD-UFES-20](https://pmc.ncbi.nlm.nih.gov/articles/PMC7479321/): Federal
363
+ University of Espírito Santo (UFES), Brazil, through its Dermatological and
364
+ Surgical Assistance Program (PAD).
365
+ * [SCIN](https://github.com/google-research-datasets/scin): A collaboration
366
+ between Google Health and Stanford Medicine.
367
+ * [TCGA](https://portal.gdc.cancer.gov/) (The Cancer Genome Atlas): A joint
368
+ effort of National Cancer Institute and National Human Genome Research
369
+ Institute. Data from TCGA are available via the Genomic Data Commons (GDC)
370
+ * [CAMELYON](https://camelyon17.grand-challenge.org/Data/): The data was
371
+ collected from Radboud University Medical Center and University Medical
372
+ Center Utrecht in the Netherlands.
373
+ * [PMC-OA (PubMed Central Open Access
374
+ Subset)](https://catalog.data.gov/dataset/pubmed-central-open-access-subset-pmc-oa):
375
+ Maintained by the National Library of Medicine (NLM) and National Center for
376
+ Biotechnology Information (NCBI), which are part of the NIH.
377
+ * [MedQA](https://arxiv.org/pdf/2009.13081): This dataset was created by a
378
+ team of researchers led by Di Jin, Eileen Pan, Nassim Oufattole, Wei-Hung
379
+ Weng, Hanyi Fang, and Peter Szolovits
380
+ * [Mendeley Digital Knee
381
+ X-Ray](https://data.mendeley.com/datasets/t9ndx37v5h/1): This dataset is
382
+ from Rani Channamma University, and is hosted on Mendeley Data.
383
+ * [AfriMed-QA](https://afrimedqa.com/): This data was developed and led by
384
+ multiple collaborating organizations and researchers include key
385
+ contributors: Intron Health, SisonkeBiotik, BioRAMP, Georgia Institute of
386
+ Technology, and MasakhaneNLP.
387
+ * [VQA-RAD](https://www.nature.com/articles/sdata2018251): This dataset was
388
+ created by a research team led by Jason J. Lau, Soumya Gayen, Asma Ben
389
+ Abacha, and Dina Demner-Fushman and their affiliated institutions (the US
390
+ National Library of Medicine and National Institutes of Health)
391
+ * [MedExpQA](https://www.sciencedirect.com/science/article/pii/S0933365724001805):
392
+ This dataset was created by researchers at the HiTZ Center (Basque Center
393
+ for Language Technology and Artificial Intelligence).
394
+ * [MedXpertQA](https://huggingface.co/datasets/TsinghuaC3I/MedXpertQA): This
395
+ dataset was developed by researchers at Tsinghua University (Beijing, China)
396
+ and Shanghai Artificial Intelligence Laboratory (Shanghai, China).
397
+
398
+ In addition to the public datasets listed above, MedGemma was also trained on
399
+ de-identified datasets licensed for research or collected internally at Google
400
+ from consented participants.
401
+
402
+ * Radiology dataset 1: De-identified dataset of different CT studies across
403
+ body parts from a US-based radiology outpatient diagnostic center network.
404
+ * Ophthalmology dataset 1: De-identified dataset of fundus images from
405
+ diabetic retinopathy screening.
406
+ * Dermatology dataset 1: De-identified dataset of teledermatology skin
407
+ condition images (both clinical and dermatoscopic) from Colombia.
408
+ * Dermatology dataset 2: De-identified dataset of skin cancer images (both
409
+ clinical and dermatoscopic) from Australia.
410
+ * Dermatology dataset 3: De-identified dataset of non-diseased skin images
411
+ from an internal data collection effort.
412
+ * Pathology dataset 1: De-identified dataset of histopathology H&E whole slide
413
+ images created in collaboration with an academic research hospital and
414
+ biobank in Europe. Comprises de-identified colon, prostate, and lymph nodes.
415
+ * Pathology dataset 2: De-identified dataset of lung histopathology H&E and
416
+ IHC whole slide images created by a commercial biobank in the United States.
417
+ * Pathology dataset 3: De-identified dataset of prostate and lymph node H&E
418
+ and IHC histopathology whole slide images created by a contract research
419
+ organization in the United States.
420
+ * Pathology dataset 4: De-identified dataset of histopathology, predominantly
421
+ H\&E whole slide images created in collaboration with a large, tertiary
422
+ teaching hospital in the United States. Comprises a diverse set of tissue
423
+ and stain types, predominantly H&E.
424
+
425
+ ### Data citation
426
+
427
+ * MIMIC-CXR Johnson, A., Pollard, T., Mark, R., Berkowitz, S., & Horng, S.
428
+ (2024). MIMIC-CXR Database (version 2.1.0). PhysioNet.
429
+ * Johnson, A.E.W., Pollard, T.J., Berkowitz, S.J. et al. [MIMIC-CXR, a
430
+ de-identified publicly available database of chest radiographs with
431
+ free-text reports. Sci Data 6, 317
432
+ (2019).](https://doi.org/10.1038/s41597-019-0322-0)
433
+ * Available on Physionet Goldberger, A., Amaral, L., Glass, L., Hausdorff, J.,
434
+ Ivanov, P. C., Mark, R., ... & Stanley, H. E. (2000). [PhysioBank,
435
+ PhysioToolkit, and PhysioNet: Components of a new research resource for
436
+ complex physiologic signals. Circulation \[Online\]. 101 (23), pp.
437
+ E215–e220.](https://pubmed.ncbi.nlm.nih.gov/10851218/)
438
+ * Bo Liu, Li-Ming Zhan, etc. [SLAKE: A Semantically-Labeled Knowledge-Enhanced
439
+ Dataset for Medical Visual Question
440
+ Answering](https://arxiv.org/abs/2102.09542).
441
+ * [PAD-UFES-20: A skin lesion dataset composed of patient data and clinical
442
+ images collected from
443
+ smartphones](https://pmc.ncbi.nlm.nih.gov/articles/PMC7479321/)
444
+ * [The Cancer Genome Atlas Program (TCGA)](https://www.cancer.gov/ccg/research/genome-sequencing/tcga)
445
+ * Babak Ehteshami Bejnordi, etc.: [Diagnostic Assessment of Deep Learning
446
+ Algorithms for Detection of Lymph Node Metastases in Women With Breast
447
+ Cancer](https://jamanetwork.com/journals/jama/fullarticle/2665774)
448
+ * MedQA: [https://arxiv.org/abs/2009.13081](https://arxiv.org/abs/2009.13081)
449
+ * Mendeley Digital Knee X-Ray: Gornale, Shivanand; Patravali, Pooja (2020),
450
+ "Digital Knee X-ray Images", Mendeley Data, V1, doi: 10.17632/t9ndx37v5h.1
451
+ * AfriMed-QA: [https://arxiv.org/abs/2411.15640](https://arxiv.org/abs/2411.15640)
452
+ * VQA-RAD: [Lau, J., Gayen, S., Ben Abacha, A. et al. A dataset of clinically
453
+ generated visual questions and answers about radiology images. Sci Data 5,
454
+ 180251 (2018).
455
+ https://doi.org/10.1038/sdata.2018.251](https://doi.org/10.1038/sdata.2018.251)
456
+ * [MedExpQA: Multilingual benchmarking of Large Language Models for
457
+ Medical Question
458
+ Answering](https://www.sciencedirect.com/science/article/pii/S0933365724001805)
459
+ * MedXpertQA: [arXiv:2501.18362v2](https://arxiv.org/abs/2501.18362)
460
+
461
+ ### De-identification/anonymization:
462
+
463
+ Google and partnerships utilize datasets that have been rigorously anonymized or
464
+ de-identified to ensure the protection of individual research participants and
465
+ patient privacy
466
+
467
+ ## Implementation information
468
+
469
+ Details about the model internals.
470
+
471
+ ### Software
472
+
473
+ Training was done using [JAX](https://github.com/jax-ml/jax).
474
+
475
+ JAX allows researchers to take advantage of the latest generation of hardware,
476
+ including TPUs, for faster and more efficient training of large models.
477
+
478
+ ## Use and limitations
479
+
480
+ ### Intended use
481
+
482
+ MedGemma is an open multimodal generative AI model intended to be used as a
483
+ starting point that enables more efficient development of downstream healthcare
484
+ applications involving medical text and images. MedGemma is intended for
485
+ developers in the life sciences and healthcare space. Developers are responsible
486
+ for training, adapting and making meaningful changes to MedGemma to accomplish
487
+ their specific intended use. MedGemma models can be fine-tuned by developers
488
+ using their own proprietary data for their specific tasks or solutions.
489
+
490
+ MedGemma is based on Gemma 3 and has been further trained on medical images and
491
+ text. MedGemma enables further development in any medical context (image and
492
+ textual), however the model was pre-trained using chest X-ray, pathology,
493
+ dermatology, and fundus images. Examples of tasks within MedGemma's training
494
+ include visual question answering pertaining to medical images, such as
495
+ radiographs, or providing answers to textual medical questions. Full details of
496
+ all the tasks MedGemma has been evaluated can be found in an upcoming technical
497
+ report.
498
+
499
+ ### Benefits
500
+
501
+ * Provides strong baseline medical image and text comprehension for models of
502
+ its size.
503
+ * This strong performance makes it efficient to adapt for downstream
504
+ healthcare-based use cases, compared to models of similar size without
505
+ medical data pre-training.
506
+ * This adaptation may involve prompt engineering, grounding, agentic
507
+ orchestration or fine-tuning depending on the use case, baseline validation
508
+ requirements, and desired performance characteristics.
509
+
510
+ ### Limitations
511
+
512
+ MedGemma is not intended to be used without appropriate validation, adaptation
513
+ and/or making meaningful modification by developers for their specific use case.
514
+ The outputs generated by MedGemma are not intended to directly inform clinical
515
+ diagnosis, patient management decisions, treatment recommendations, or any other
516
+ direct clinical practice applications. Performance benchmarks highlight baseline
517
+ capabilities on relevant benchmarks, but even for image and text domains that
518
+ constitute a substantial portion of training data, inaccurate model output is
519
+ possible. All outputs from MedGemma should be considered preliminary and require
520
+ independent verification, clinical correlation, and further investigation
521
+ through established research and development methodologies.
522
+
523
+ MedGemma's multimodal capabilities have been primarily evaluated on single-image
524
+ tasks. MedGemma has not been evaluated in use cases that involve comprehension
525
+ of multiple images.
526
+
527
+ MedGemma has not been evaluated or optimized for multi-turn applications.
528
+
529
+ MedGemma's training may make it more sensitive to the specific prompt used than
530
+ Gemma 3.
531
+
532
+ When adapting MedGemma developer should consider the following:
533
+
534
+ * **Bias in validation data:** As with any research, developers should ensure
535
+ that any downstream application is validated to understand performance using
536
+ data that is appropriately representative of the intended use setting for
537
+ the specific application (e.g., age, sex, gender, condition, imaging device,
538
+ etc).
539
+ * **Data contamination concerns**: When evaluating the generalization
540
+ capabilities of a large model like MedGemma in a medical context, there is a
541
+ risk of data contamination, where the model might have inadvertently seen
542
+ related medical information during its pre-training, potentially
543
+ overestimating its true ability to generalize to novel medical concepts.
544
+ Developers should validate MedGemma on datasets not publicly available or
545
+ otherwise made available to non-institutional researchers to mitigate this
546
+ risk.
added_tokens.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "<image_soft_token>": 262144
3
+ }
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,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Gemma3ForCausalLM"
4
+ ],
5
+ "attention_bias": false,
6
+ "attention_dropout": 0.0,
7
+ "attn_logit_softcapping": null,
8
+ "bos_token_id": 2,
9
+ "cache_implementation": "hybrid",
10
+ "eos_token_id": 106,
11
+ "final_logit_softcapping": null,
12
+ "head_dim": 128,
13
+ "hidden_activation": "gelu_pytorch_tanh",
14
+ "hidden_size": 5376,
15
+ "initializer_range": 0.02,
16
+ "intermediate_size": 21504,
17
+ "max_position_embeddings": 131072,
18
+ "model_type": "gemma3_text",
19
+ "num_attention_heads": 32,
20
+ "num_hidden_layers": 62,
21
+ "num_key_value_heads": 16,
22
+ "pad_token_id": 0,
23
+ "quantization_config": {
24
+ "_load_in_4bit": true,
25
+ "_load_in_8bit": false,
26
+ "bnb_4bit_compute_dtype": "bfloat16",
27
+ "bnb_4bit_quant_storage": "uint8",
28
+ "bnb_4bit_quant_type": "nf4",
29
+ "bnb_4bit_use_double_quant": true,
30
+ "llm_int8_enable_fp32_cpu_offload": false,
31
+ "llm_int8_has_fp16_weight": false,
32
+ "llm_int8_skip_modules": [
33
+ "lm_head",
34
+ "multi_modal_projector",
35
+ "merger",
36
+ "modality_projection",
37
+ "model.layers.55.mlp"
38
+ ],
39
+ "llm_int8_threshold": 6.0,
40
+ "load_in_4bit": true,
41
+ "load_in_8bit": false,
42
+ "quant_method": "bitsandbytes"
43
+ },
44
+ "query_pre_attn_scalar": 168,
45
+ "rms_norm_eps": 1e-06,
46
+ "rope_local_base_freq": 10000,
47
+ "rope_scaling": {
48
+ "factor": 8.0,
49
+ "rope_type": "linear"
50
+ },
51
+ "rope_theta": 1000000,
52
+ "sliding_window": 1024,
53
+ "sliding_window_pattern": 6,
54
+ "torch_dtype": "bfloat16",
55
+ "transformers_version": "4.52.1",
56
+ "unsloth_fixed": true,
57
+ "use_cache": true,
58
+ "vocab_size": 262144
59
+ }
generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "cache_implementation": "hybrid",
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 1,
7
+ 106
8
+ ],
9
+ "max_length": 131072,
10
+ "pad_token_id": 0,
11
+ "top_k": 64,
12
+ "top_p": 0.95,
13
+ "transformers_version": "4.52.1"
14
+ }
model-00001-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:87fddce40f4491e9e117b203d61d4cd6e6d2a3a6bced5b59a44997519810a1d3
3
+ size 4983143805
model-00002-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6bf3f8ff11443d741010dce30428f5862b6d7138e183a6ad26e692432acdfe13
3
+ size 4959753712
model-00003-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7f3ce2e451b16ea3c6a23613c65d2caa3eaee446e1dae11c925195f1bf9e1b17
3
+ size 4858637819
model-00004-of-00004.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0212381209d8d0b49babb812c9cf703ba06876407460c68127b86913ebed3689
3
+ size 1740767219
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,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "boi_token": "<start_of_image>",
3
+ "bos_token": {
4
+ "content": "<bos>",
5
+ "lstrip": false,
6
+ "normalized": false,
7
+ "rstrip": false,
8
+ "single_word": false
9
+ },
10
+ "eoi_token": "<end_of_image>",
11
+ "eos_token": {
12
+ "content": "<end_of_turn>",
13
+ "lstrip": false,
14
+ "normalized": false,
15
+ "rstrip": false,
16
+ "single_word": false
17
+ },
18
+ "image_token": "<image_soft_token>",
19
+ "pad_token": {
20
+ "content": "<pad>",
21
+ "lstrip": false,
22
+ "normalized": false,
23
+ "rstrip": false,
24
+ "single_word": false
25
+ },
26
+ "unk_token": {
27
+ "content": "<unk>",
28
+ "lstrip": false,
29
+ "normalized": false,
30
+ "rstrip": false,
31
+ "single_word": false
32
+ }
33
+ }
tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4667f2089529e8e7657cfb6d1c19910ae71ff5f28aa7ab2ff2763330affad795
3
+ size 33384568
tokenizer.model ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
3
+ size 4689074
tokenizer_config.json ADDED
The diff for this file is too large to render. See raw diff