Downloads · 30 days
67
100% of all-time downloads
gaurav2310/finetuned-smollm2
finetuned-smollm2 is a text generation model from gaurav2310. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
A medical conversational AI model fine-tuned on the ChatDoctor dataset using LoRA (Low-Rank Adaptation) technique.
Downloads · 30 days
67
100% of all-time downloads
All-time downloads
67
Public
Repo size
2.2 GB
Likes
1
Public
Click a slice to open those files.
.pt1.4 GB · 50%
From the Hugging Face model README
A medical conversational AI model fine-tuned on the ChatDoctor dataset using LoRA (Low-Rank Adaptation) technique.
This model is fine-tuned to respond like a medical professional. It can:
Disclaimer: This model is for educational purposes only. Always consult a real doctor for medical advice.
pip install transformers peft torch
from transformers import AutoTokenizer, AutoModelForCausalLM from peft import PeftModel import torch
BASE_MODEL = "HuggingFaceTB/SmolLM2-1.7B-Instruct" FINETUNED_MODEL = "gaurav2310/finetuned-smollm2"
tokenizer = AutoTokenizer.from_pretrained(BASE_MODEL)
base_model = AutoModelForCausalLM.from_pretrained( BASE_MODEL, dtype=torch.float16 )
model = PeftModel.from_pretrained(base_model, FINETUNED_MODEL) model.eval()
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
)
print(ask_doctor("I have a headache and fever from 2 days. What should I do?"))
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.
| 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 |
Gaurav — Fine-tuned as part of ML learning project
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->[More Information Needed]
[More Information Needed]
[More Information Needed]
[More Information Needed]