Downloads · 30 days
2
3% of all-time downloads
Sugandha-Chauhan/MedGemma-SymptomDiagnosis
MedGemma-SymptomDiagnosis is a machine learning model from Sugandha-Chauhan. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
This is a fine-tuned version of MedGemma (based on Google Gemma 2 2B) specialized for medical diagnosis classification based on patient symptoms.
Downloads · 30 days
2
3% of all-time downloads
All-time downloads
80
Public
Repo size
35.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors35.7 MB · 97%
From the Hugging Face model README
This is a fine-tuned version of MedGemma (based on Google Gemma 2 2B) specialized for medical diagnosis classification based on patient symptoms.
Important Note: While MedGemma is originally a multimodal model built on Gemini architecture capable of processing text, images, and other modalities, this fine-tuned version is optimized as a causal language model specifically for text-based symptom-to-diagnosis classification.
The model was fine-tuned using LoRA (Low-Rank Adaptation) on a dataset of 10,000 medical cases with symptom-diagnosis pairs, achieving 98.9% training accuracy at checkpoint-1100.
LoRA Hyperparameters:
Training Hyperparameters:
Training Environment:
Final Checkpoint (checkpoint-1100):
✅ Medical diagnosis prediction from text symptom descriptions
✅ Clinical decision support systems (with medical oversight)
✅ Medical education and training
✅ Healthcare AI research
✅ Ensemble medical diagnosis systems
✅ Lightweight deployment scenarios (smallest model in ensemble)
❌ Multimodal medical imaging analysis (requires base model capabilities)
❌ Direct patient care without medical professional oversight
❌ Emergency medical decisions
❌ Replacement for professional medical judgment
pip install transformers peft torch bitsandbytes accelerate
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
import torch
# Quantization config
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True
)
# Load base model (Gemma 2 2B)
base_model = AutoModelForCausalLM.from_pretrained(
"google/gemma-2-2b",
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True
)
# Load fine-tuned adapter
model = PeftModel.from_pretrained(
base_model,
"Sugandha-Chauhan/MedGemma-SymptomDiagnosis"
)
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("google/gemma-2-2b")
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
# Suppress warnings
import warnings
warnings.filterwarnings('ignore')
import os
os.environ['TRANSFORMERS_VERBOSITY'] = 'error'
# Patient symptoms (text-only input)
symptoms = "fever, cough, fatigue, body aches, headache"
# Format prompt
prompt = f"""Below is a patient case with symptoms. Provide ONLY the most likely diagnosis.
### Symptoms:
{symptoms}
### Diagnosis:
"""
# Generate
inputs = tokenizer(prompt, return_tensors="pt", max_length=512, truncation=True)
inputs = {k: v.to(model.device) for k, v in inputs.items()}
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=50,
temperature=0.1,
do_sample=False
)
# Decode
result = tokenizer.decode(outputs[0], skip_special_tokens=True)
diagnosis = result[len(prompt):].strip().split('\n')[0]
print(f"Diagnosis: {diagnosis}")
| Metric | Value |
|---|---|
| Training Loss | ~0.05 |
| Training Accuracy | 98.9% |
| Training Steps | 1100 |
| Checkpoint | checkpoint-1100 |
| Base Model Size | 2B parameters |
| Adapter Size | 35 MB |
Part of a 4-model ensemble for medical diagnosis:
| Model | Base | Size | Adapter Size | Training Acc | Checkpoint | Specialty |
|---|---|---|---|---|---|---|
| BioMistral-7B | BioMistral | 7B | 52 MB | 99.1% | 700 | Medical text |
| MedAlpaca-7B | MedAlpaca | 7B | 64 MB | 99.0% | 600 | Medical LLM |
| MedGemma | Gemma 2 | 2B | 35 MB | 98.9% | 1100 | Multimodal base |
| BioGPT | BioGPT | 1.5B | 12 MB | TBD | 1100 | Biomedical |
Key Advantages:
Given the multimodal base architecture, potential future versions could:
⚠️ Medical AI Ethics:
⚠️ Bias Considerations:
If you use this model, please cite:
@misc{chauhan2024medgemma,
author = {Sugandha Chauhan},
title = {MedGemma Fine-tuned for Medical Diagnosis: Text-based Classification from Multimodal Foundation},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Sugandha-Chauhan/MedGemma-SymptomDiagnosis}},
note = {Fine-tuned causal model from multimodal MedGemma base}
}
⚠️ IMPORTANT MEDICAL DISCLAIMER
This AI model is for educational and research purposes only. It is NOT:
Always consult a physician or qualified healthcare provider for medical decisions.
Released under the same license as Gemma 2. See base model for details.
Author: Sugandha Chauhan
Repository: https://huggingface.co/Sugandha-Chauhan/MedGemma-SymptomDiagnosis
Model Portfolio: 4-model ensemble for medical diagnosis
Model Version: 1.0 (Checkpoint-1100)
Last Updated: November 2024
Architecture: Multimodal foundation → Text-only fine-tuning
Part of: Multi-model Medical Diagnosis System