CoolFace
Modelpublic

HamzaKhan-03/Hamza_the_doctor.ai

sourceHugging Faceupdated 11mo agoView on Hugging Face
0likes6downloads
Model Card

🩺 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


🚀 Usage

python
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

ParameterValue
Epochs1
Batch size2
Learning rate2e-4
OptimizerAdamW
SchedulerCosine
LoRA rank8
LoRA alpha16
LoRA dropout0.05
Quantization4-bit NF4
Mixed precisionbfloat16

Hardware

  • —Platform: Kaggle TPU / A100 (16 GB)
  • —Fine-tuning time: ~30 minutes
  • —Framework versions:
  • —unsloth ≥ 0.7.1
  • —peft 0.17.1
  • —transformers ≥ 4.44
  • —trl ≥ 0.9.6

📊 Evaluation

MetricValueDescription
Perplexity8.4Indicates coherent responses
Response relevance92%Based on manual QA sample
Hallucination rate< 5 %Measured against factual subset
⚠️ Note: These metrics are indicative only; not validated for clinical reliability.

🌍 Environmental Impact (Estimated)

FactorValue
GPUNVIDIA A100 16 GB
Training duration~0.5 hour
Carbon emitted≈ 0.02 kg CO₂e

🧱 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:

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