Ir para o conteúdo
ModelListadosExterno
Browse files

Medgemma Brats Experiments

This repository contains fine-tuning experiments using unsloth/medgemma-4b-it on BraTS and TextBraTS datasets for brain MRI and radiology text understanding. The experiments explore different LoRA configurations and...

TipoOtherModelo baseunsloth/medgemma-4b-itVersãoAdapter modelCnota

Fonte do modelo

Tipo
Other
Tamanho do arquivo
9,29 MB–4,62 GB
Modelo base
unsloth/medgemma-4b-it
Versão
vAdapter model
Atualizado
24 de out. de 2026
Fonte
Hugging Face

Descrição da fonte

🧠 Medgemma-brats-experiments

This repository contains fine-tuning experiments using unsloth/medgemma-4b-it on BraTS and TextBraTS datasets for brain MRI and radiology text understanding. The experiments explore different LoRA configurations and their effects on domain adaptation, language specificity, and catastrophic forgetting.


🧩 Experimental Setup


⚙️ LoRA Configurations

ConfigurationLoRA rLoRA αEpochsTrainable Params% of Total
r1_alpha2_epochs11212.4M0.06%
r1_alpha4_epochs11412.4M0.06%
r1_alpha4_epochs21422.4M0.06%
r4_alpha4_epochs24429.6M0.22%
r16_alpha16_epochs21616238.5M0.89%

📊 Quantitative Results

ConfigurationrαEpochsROUGE-1ROUGE-2ROUGE-LAvg ROUGE
r1_alpha2_epochs11210.55390.27650.39850.4096
r1_alpha4_epochs11410.61790.33440.45530.4692
r1_alpha4_epochs21420.61940.33700.45360.4700
r4_alpha4_epochs24420.61170.32860.44510.4618
r16_alpha16_epochs2161620.62420.34570.46480.4782

🧠 Qualitative Comparisons

Below are qualitative results comparing outputs across configurations using real generation excerpts.

🧩 Example 1 — Brain MRI Slice

Ground truth:

“Lesion in right frontal and parietal lobes with mixed signals. Edema and necrosis observed. Ventricular compression present.”

🖼️ Image:
Brain MRI Example

ModelExample Response
Original“Based on the MRI scan, here are the regions and structures I can identify: Gray Matter, White Matter, and CSF... lacks mention of lesion or edema.”
r1_alpha2“The MRI slice demonstrates: The lesion area is in the right cerebral hemisphere, mainly concentrated in the right frontal and parietal lobes with mixed signals... Edema is observed... Ventricular compression is observed with the right lateral ventricle being compressed.”
r1_alpha4“The lesion area is in the right frontal and parietal lobes with a mix of high and low signals... Necrosis is visible... Ventricular compression is not observed, ventricles appear relatively normal.”
r1_alpha4 (2e)“The lesion area is in the right frontal, parietal, and occipital lobes... Edema extends to occipital lobe... Ventricular compression evident with deformation of its shape.”
r4_alpha4“The lesion area is in the right parietal lobe with heterogeneous high and low signals... Edema is observed... Ventricular compression is observed, with deformation.”
r16_alpha16“Analysis of this brain MRI reveals: The lesion area is in the right cerebral hemisphere... Edema is significant... Necrosis is suggested... Ventricular compression is observed with the right lateral ventricle noticeably compressed.”

🔬 Example 2 — Histology / Blood Sample

🖼️ Image:
Histology Example

ModelExample Response
Original“The image appears to be a microscopic view of tissue... complex architecture, varied coloration, but no explicit lesion detail.”
r1_alpha2“The MRI slice shows: The lesion area is in the right lobe of the brain with a mix of heterogeneous high and low signals... Edema observed... Ventricular compression is observed.”
r1_alpha4“The lesion area is in the left side of the brain with a mix of high and low signals... Edema is significant... Necrosis is observed... Ventricular compression is observed.”
r1_alpha4 (2e)“This is a single axial slice... The lesion area is in the right side of the brain with heterogeneous signals... Edema significant... Necrosis and ventricular compression present.”
r4_alpha4“The lesion area is in the right parietal lobe with heterogeneous signals... Edema prominent... Necrosis indicated by low-signal regions... Ventricular compression observed.”
r16_alpha16“The histology image shows: The tumor area is in the right frontal lobe... Edema significant... Necrosis observed... Ventricular compression evident.”

🐶 Example 3 — Natural Image (Puppies)

🖼️ Image:
Puppies Example

ModelExample Response
Original“The image shows two golden retriever puppies... standing on a lush green lawn covered with flowers... evokes a sense of joy and nature.”
r1_alpha2“A heartwarming photo of two golden retriever puppies in a field of colorful flowers... playful and happy expressions... warm and inviting atmosphere.”
r1_alpha4“Two golden retriever puppies playing in a field of wildflowers... vibrant green meadow... cheerful and heartwarming scene.”
r1_alpha4 (2e)“Two adorable golden retriever puppies... one playfully nudging the other's nose... lush green meadow with scattered flowers.”
r4_alpha4“Two golden retriever puppies standing side-by-side in a field of wildflowers... one grinning, one more subdued... sunny meadow atmosphere.”
r16_alpha16“A pair of golden retriever puppies in a meadow... both looking at the camera with happy expressions... soft and natural lighting.”

💬 Observations

  • Fine-tuning on domain data improves medical accuracy, especially MRI lesion descriptions.
  • Higher LoRA ranks (e.g., r=16) slightly improve quantitative metrics but cause catastrophic forgetting — the model loses general descriptive ability on unrelated domains.
  • For small or specialized datasets, lighter LoRA configurations (r=1, α=4, 1–2 epochs) offer the best balance between specialization and generalization.
  • In such limited-data scenarios, techniques like context engineering or prompt-based adaptation are often more efficient than full fine-tuning.
  • This aligns with current research and discussions on when to fine-tune versus when to leverage better prompting strategies.

📚 References:

Fontes

1 fonte
Hugging FacePrimárioVersão ed2f870e54d64982da9b020d13b7f8c887033a07
huggingface.co/Jesteban247/medgemma-brats-experiments/tree/ed2f870e54d64982da9b020d13b7f8c887033a07

Verificado 24 de out.

Download files

Artefatos de modelo

20 artefatos

brats_medgemma_r1_alpha2_20251013_235648/checkpoint-124/adapter_model.safetensors

safetensors · 9,29 MB · SHA-256 fea46113665c…1e34 · Hugging Face

Download file

brats_medgemma_r1_alpha2_20251013_235648/lora_adapters/adapter_model.safetensors

safetensors · 9,29 MB · SHA-256 fea46113665c…1e34 · Hugging Face

Download file

brats_medgemma_r1_alpha2_20251013_235648/merged_model/model-00001-of-00002.safetensors

safetensors · 4,62 GB · SHA-256 b4d28e41199e…1922 · Hugging Face

Download shard

brats_medgemma_r1_alpha2_20251013_235648/merged_model/model-00002-of-00002.safetensors

safetensors · 3,39 GB · SHA-256 b3e58ed42ced…9848 · Hugging Face

Download shard

brats_medgemma_r1_alpha4_20251014_001744/checkpoint-124/adapter_model.safetensors

safetensors · 9,29 MB · SHA-256 d15df29b6264…fd8b · Hugging Face

Download file

brats_medgemma_r1_alpha4_20251014_001744/lora_adapters/adapter_model.safetensors

safetensors · 9,29 MB · SHA-256 d15df29b6264…fd8b · Hugging Face

Download file

brats_medgemma_r1_alpha4_20251014_001744/merged_model/model-00001-of-00002.safetensors

safetensors · 4,62 GB · SHA-256 acbdfbacb836…03d1 · Hugging Face

Download shard

brats_medgemma_r1_alpha4_20251014_001744/merged_model/model-00002-of-00002.safetensors

safetensors · 3,39 GB · SHA-256 2153f61cfda4…7a15 · Hugging Face

Download shard

brats_medgemma_r1_alpha4_20251014_005739/checkpoint-248/adapter_model.safetensors

safetensors · 9,29 MB · SHA-256 9f6359aab348…70dd · Hugging Face

Download file

brats_medgemma_r1_alpha4_20251014_005739/lora_adapters/adapter_model.safetensors

safetensors · 9,29 MB · SHA-256 9f6359aab348…70dd · Hugging Face

Download file

brats_medgemma_r1_alpha4_20251014_005739/merged_model/model-00001-of-00002.safetensors

safetensors · 4,62 GB · SHA-256 0e4178b12f47…5356 · Hugging Face

Download shard

brats_medgemma_r1_alpha4_20251014_005739/merged_model/model-00002-of-00002.safetensors

safetensors · 3,39 GB · SHA-256 b43e89c54044…2b02 · Hugging Face

Download shard

brats_medgemma_r16_alpha16_20251014_023559/checkpoint-248/adapter_model.safetensors

safetensors · 147 MB · SHA-256 0b71de9c6e97…6ba0 · Hugging Face

Download file

brats_medgemma_r16_alpha16_20251014_023559/lora_adapters/adapter_model.safetensors

safetensors · 147 MB · SHA-256 0b71de9c6e97…6ba0 · Hugging Face

Download file

brats_medgemma_r16_alpha16_20251014_023559/merged_model/model-00001-of-00002.safetensors

safetensors · 4,62 GB · SHA-256 261b82172968…aa4e · Hugging Face

Download shard

brats_medgemma_r16_alpha16_20251014_023559/merged_model/model-00002-of-00002.safetensors

safetensors · 3,39 GB · SHA-256 118602196177…a1da · Hugging Face

Download shard

brats_medgemma_r4_alpha4_20251014_013202/checkpoint-248/adapter_model.safetensors

safetensors · 36,8 MB · SHA-256 9f558f4044e0…f31c · Hugging Face

Download file

brats_medgemma_r4_alpha4_20251014_013202/lora_adapters/adapter_model.safetensors

safetensors · 36,8 MB · SHA-256 9f558f4044e0…f31c · Hugging Face

Download file

brats_medgemma_r4_alpha4_20251014_013202/merged_model/model-00001-of-00002.safetensors

safetensors · 4,62 GB · SHA-256 bc1c678703b5…8f14 · Hugging Face

Download shard

brats_medgemma_r4_alpha4_20251014_013202/merged_model/model-00002-of-00002.safetensors

safetensors · 3,39 GB · SHA-256 0b5947f34a56…a8e1 · Hugging Face

Download shard

Trechos de fonte

2 trechos

--- base_model: - unsloth/medgemma-4b-it model_name: medgemma-brats-experiments tags: - sft - medical-imaging - brats - textbrats - unsloth license: apache-2.0 datasets: - Jupitern52/TextBraTS language: - en pipeline_tag: visual-question-answering library_name: transformers --- # 🧠 Medgemma-brats-experiments This repository contains fine-tuning experiments using **[unsloth/medgemma-4b-it](https://huggingface.co/unsloth/medgemma-4b-it)** on **BraTS** and **TextBraTS** datasets for brain MRI and radiology text understanding. The experiments explore different **LoRA configurations** and their effects on domain adaptation, language specificity, and catastrophic forgetting. --- ## 🧩 Experimental Setup * **Base model:** [`unsloth/medgemma-4b-it`](https://huggingface.co/unsloth/medgemma-4b-it) * **Datasets:** * 🧬 [Jupitern52/TextBraTS](https://huggingface.co/datasets/Jupitern52/TextBraTS) * 🧠 [Kaggle BraTS20 Dataset](https://www.kaggle.com/datasets/awsaf49/brats20-dataset-training-validation) * **Framework:** [Unsloth](https://docs.unsloth.ai) (LoRA fine-tuning) * **Training type:** SFT (Supervised Fine-Tuning) * **Epochs:** 1–2 * **Loss curve:** ![Training Loss](https://huggingface.co/Jesteban247/medgemma-brats-experiments/resolve/main/images/Training-loss_FT.png) --- ## ⚙️ LoRA Configurations | Configuration | LoRA r | LoRA α | Epochs | Trainable Params | % of Total | | ------------------- | ------ | ------ | ------ | ---------------- | ---------- | | r1_alpha2_epochs1 | 1 | 2 | 1 | 2.4M | 0.06% | | r1_alpha4_epochs1 | 1 | 4 | 1 | 2.4M | 0.06% | | r1_alpha4_epochs2 | 1 | 4 | 2 | 2.4M | 0.06% | | r4_alpha4_epochs2 | 4 | 4 | 2 | 9.6M | 0.22% | | r16_alpha16_epochs2 | 16 | 16 | 2 | 38.5M | 0.89% | --- ## 📊 Quantitative Results | Configuration | r | α | Epochs | ROUGE-1 | ROUGE-2 | ROUGE-L | Avg ROUGE | | ------------------- | -- | -- | ------ | ------- | ------- | ------- | ---------- | | r1_alpha2_epochs1 | 1 | 2 | 1 | 0.5539 | 0.2765 | 0.3985 | **0.4096** | | r1_alpha4_epochs1 | 1 | 4 | 1 | 0.6179 | 0.3344 | 0.4553 | **0.4692** | | r1_alpha4_epochs2 | 1 | 4 | 2 | 0.6194 | 0.3370 | 0.4536 | **0.4700** | | r4_alpha4_epochs2 | 4 | 4 | 2 | 0.6117 | 0.3286 | 0.4451 | **0.4618** | | r16_alpha16_epochs2 | 16 | 16 | 2 | 0.6242 | 0.3457 | 0.4648 | **0.4782** | --- ## 🧠 Qualitative Comparisons Below are qualitative results comparing outputs across...

Source context: 0 downloads · 0 likes · Pipeline visual-question-answering · Library transformers · Repo Jesteban247/medgemma-brats-experiments