π§ 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
- Base model:
unsloth/medgemma-4b-it - Datasets:
- Framework: Unsloth (LoRA fine-tuning)
- Training type: SFT (Supervised Fine-Tuning)
- Epochs: 1β2
- Loss curve:

βοΈ 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 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.β
| Model | Example 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
| Model | Example 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)
| Model | Example 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:
Model tree for Jesteban247/medgemma-brats-experiments
Base model
google/gemma-3-4b-pt
Finetuned
google/medgemma-4b-pt
Finetuned
google/medgemma-4b-it
Finetuned
unsloth/medgemma-4b-it


