HamzaKhan-03/Hamza_the_doctor.ai
06
🩺 Hamzathedoctor.ai — Medical Chatbot (Fine-tuned Gemma 3 270M)
A lightweight medical conversational model fine-tuned on healthcare QA data using Unsloth’s 4-bit optimization, enabling efficient deployment on consumer GPUs while maintaining strong accuracy for medical dialogue.
🧠 Model Overview
Model Description
- Developed by: Muhammad Hamza Khan
- Base model: `unsloth/gemma-3-270m-it-unsloth-bnb-4bit`
- Task: Medical Question Answering / Chatbot
- Fine-tuning method: LoRA using PEFT + TRL (SFTTrainer)
- Language(s): English
- Frameworks used: Python, Jupyter Notebook (Kaggle), Unsloth, Transformers, PEFT
- License: Apache 2.0
This model was trained for health-related conversational reasoning — ideal for educational or research use-cases involving patient–doctor-style dialogues.
🧩 Model Sources
- Repository: HamzaKhan-03/Hamza_the_doctor.ai
- Dataset: lavita/ChatDoctor-HealthCareMagic-100k
🚀 Usage
from unsloth import FastModel
import torch, os
HF_TOKEN = os.environ["HF_TOKEN"]
HF_REPO_ID = "HamzaKhan-03/Hamza_the_doctor.ai"
# Load model in 4-bit precision
model, tokenizer = FastModel.from_pretrained(
HF_REPO_ID,
load_in_4bit=True,
token=HF_TOKEN,
)
model.to("cuda")
messages = [{"role": "user", "content": "Can you tell me about cancer?"}]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
).removeprefix('<bos>')
inputs = tokenizer(text, return_tensors="pt").to("cuda")
outputs = model.generate(
**inputs,
max_new_tokens=512,
temperature=0.7,
top_p=0.95,
top_k=50,
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))🧪 Training Details
Dataset
- Name:
lavita/ChatDoctor-HealthCareMagic-100k - Type: Doctor–Patient QA pairs for medical reasoning tasks
- Preprocessing: Filtered for concise Q&A, cleaned for multi-turn context
Hyperparameters
Hardware
- Platform: Kaggle TPU / A100 (16 GB)
- Fine-tuning time: ~30 minutes
- Framework versions:
unsloth≥ 0.7.1peft0.17.1transformers≥ 4.44trl≥ 0.9.6
📊 Evaluation
⚠️ Note: These metrics are indicative only; not validated for clinical reliability.
🌍 Environmental Impact (Estimated)
🧱 Model Architecture
- Base: Gemma 3 270 M (Instruction-Tuned)
- Adapter: LoRA (rank 8)
- Quantization: 4-bit NF4 for reduced memory footprint
- Objective: Supervised Fine-Tuning (SFT) with instruction-style prompts
🧾 Citation
If you use this model, please cite:
BibTeX:
@misc{hamza2025doctorai,
title={Hamza_the_doctor.ai — Medical Chatbot (Fine-tuned Gemma 3 270M)},
author={Muhammad Hamza Khan},
year={2025},
howpublished={\url{https://huggingface.co/HamzaKhan-03/Hamza_the_doctor.ai}},
}📬 Contact
For technical questions or collaborations: Author: Muhammad Hamza Khan Hugging Face: @HamzaKhan-03
