ChatDoctor Fine-Tuned SmolLM2-1.7B
A medical conversational AI model fine-tuned on the ChatDoctor dataset using LoRA (Low-Rank Adaptation) technique.
Model Details
- Base Model: HuggingFaceTB/SmolLM2-1.7B-Instruct
- Fine-Tuning Method: LoRA (Low-Rank Adaptation)
- Dataset: avaliev/chat_doctor
- Training Steps: 1494
- Final Loss: 1.18 (started at 1.59)
What This Model Does
This model is fine-tuned to respond like a medical professional. It can:
- Answer patient medical queries
- Suggest possible diagnoses based on symptoms
- Provide general health advice
Disclaimer: This model is for educational purposes only. Always consult a real doctor for medical advice.
How To Use
Installation
pip install transformers peft torch
Code
from transformers import AutoTokenizer, AutoModelForCausalLM from peft import PeftModel import torch
BASE_MODEL = "HuggingFaceTB/SmolLM2-1.7B-Instruct" FINETUNED_MODEL = "gaurav2310/finetuned-smollm2"
Load tokenizer and base model
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
base_model = AutoModelForCausalLM.from_pretrained( BASE_MODEL, dtype=torch.float16 )
Load LoRA adapter
model = PeftModel.from_pretrained(base_model, FINETUNED_MODEL) model.eval()
Chat function
def ask_doctor(question): messages = [{"role": "user", "content": question}] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=200,
pad_token_id=tokenizer.eos_token_id,
temperature=0.7,
do_sample=True,
)
return tokenizer.decode(
outputs[0][inputs["input_ids"].shape[-1]:],
skip_special_tokens=True
)
Example
print(ask_doctor("I have a headache and fever from 2 days. What should I do?"))
Example Output
Patient: I have a headache and fever from 2 days. What should I do?
Model: Based on your symptoms, you may be experiencing a viral infection. I recommend rest, staying hydrated, and taking paracetamol for fever. If fever exceeds 103°F or symptoms worsen, please consult a doctor immediately.
Training Details
| Parameter | Value |
|---|---|
| Base Model | SmolLM2-1.7B-Instruct |
| Method | LoRA |
| Dataset | avaliev/chat_doctor |
| Steps | 1494 |
| Start Loss | 1.5952 |
| Final Loss | 1.1899 |
| Framework | HuggingFace Transformers + PEFT |
Limitations
- Small model (1.7B) — answers may be generic sometimes
- Not a replacement for real medical advice
- Best used for educational and research purposes
Author
Gaurav — Fine-tuned as part of ML learning project
[More Information Needed]
More Information [optional]
[More Information Needed]
Model Card Authors [optional]
[More Information Needed]
Model Card Contact
[More Information Needed]
Framework versions
- PEFT 0.19.1
Model tree for gaurav2310/finetuned-smollm2
Base model
HuggingFaceTB/SmolLM2-1.7B