Downloads · 30 days
4
12% of all-time downloads
Sugandha-Chauhan/MedAlpaca-SymptomDiagnosis
MedAlpaca-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 medalpaca/medalpaca-7b specialized for medical diagnosis classification based on patient symptoms.
Downloads · 30 days
4
12% of all-time downloads
All-time downloads
34
Public
Repo size
67.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors67.3 MB · 100%
From the Hugging Face model README
This is a fine-tuned version of medalpaca/medalpaca-7b specialized for medical diagnosis classification based on patient symptoms.
The model was fine-tuned using LoRA (Low-Rank Adaptation) on a dataset of 10,000 medical cases with symptom-diagnosis pairs, achieving 99.0% training accuracy at checkpoint-600.
LoRA Hyperparameters:
Training Hyperparameters:
Training Environment:
Final Checkpoint (checkpoint-600):
✅ Medical diagnosis prediction from symptom lists
✅ Clinical decision support systems (with medical oversight)
✅ Medical education and training
✅ Healthcare AI research
✅ Ensemble medical diagnosis systems
❌ 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
base_model = AutoModelForCausalLM.from_pretrained(
"medalpaca/medalpaca-7b",
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True
)
# Load fine-tuned adapter
model = PeftModel.from_pretrained(
base_model,
"Sugandha-Chauhan/MedAlpaca-SymptomDiagnosis"
)
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("medalpaca/medalpaca-7b")
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
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 | 99.0% |
| Training Steps | 600 |
| Checkpoint | checkpoint-600 |
Part of a 4-model ensemble for medical diagnosis:
| Model | Base | Adapter Size | Training Acc | Checkpoint |
|---|---|---|---|---|
| BioMistral-7B | BioMistral | 52 MB | 99.1% | 700 |
| MedAlpaca-7B | MedAlpaca | 64 MB | 99.0% | 600 |
| MedGemma | Gemma-2B | 35 MB | TBD | 1100 |
| BioGPT | BioGPT | 12 MB | TBD | 1100 |
⚠️ Medical AI Ethics:
⚠️ Bias Considerations:
If you use this model, please cite:
@misc{chauhan2024medalpaca,
author = {Sugandha Chauhan},
title = {MedAlpaca-7B Fine-tuned for Medical Diagnosis},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/Sugandha-Chauhan/MedAlpaca-SymptomDiagnosis}}
}
⚠️ 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 MedAlpaca-7B. See base model for details.
Author: Sugandha Chauhan
Repository: https://huggingface.co/Sugandha-Chauhan/MedAlpaca-SymptomDiagnosis
Model Portfolio: 4-model ensemble for medical diagnosis
Model Version: 1.0 (Checkpoint-600)
Last Updated: November 2024
Part of: Multi-model Medical Diagnosis System