A specialized fine-tuning project for GPT-2 to provide insulin dosage adjustment recommendations based on 7-day fasting blood glucose (FBG) measurements.
🎯 Project Overview
This project fine-tunes GPT-2 language models to analyze patient blood glucose patterns and recommend insulin dosage adjustments. The system implements clinical decision rules for insulin titration based on average FBG levels and variability patterns.
Decision Logic
High FBG (>180 mg/dL): Increase insulin by 20 units
Low FBG (<100 mg/dL): Decrease insulin by 20 units
Optimal FBG (100-180 mg/dL): No change in dosage
High variability (std >40): Consider smaller adjustments
📁 Project Structure
fine_tuning/
├── fine_tune.py # Standard GPT-2 fine-tuning
├── fine_tune_lora.py # LoRA (Low-Rank Adaptation) fine-tuning
├── fine_tune_qlora.py # QLoRA (Quantized LoRA) fine-tuning
├── push_to_hub.py # Script to upload models to HuggingFace Hub
├── gpt2_insulin_titration/ # Standard fine-tuned model
├── gpt2_insulin_lora/ # LoRA fine-tuned model
└── gpt2_insulin_qlora/ # QLoRA fine-tuned model
1# Login to HuggingFace2huggingface-cli login
34# Push model5python push_to_hub.py
Or use the model directly from the Hub:
model = GPT2LMHeadModel.from_pretrained("MohammadReza99/GPT2-optimal_insulin_calculator")
📈 Performance Comparison
Method
Training Time
Memory Usage
Model Size
Accuracy
Standard
~10 min
4-6 GB
548 MB
Baseline
LoRA
~5 min
2-3 GB
3.2 MB (adapter)
~95% of baseline
QLoRA
~7 min
1-2 GB
3.2 MB (adapter)
~93% of baseline
⚠️ Important Notes
Medical Disclaimer
This is a demonstration project for educational purposes. The model should NOT be used for actual medical decisions without proper validation and regulatory approval.
Limitations
Synthetic training data may not capture all real-world scenarios
Model outputs should be validated by healthcare professionals
Does not account for individual patient factors beyond FBG