qwen2.5-0.5b-chatdoctor-qlora
This is a QLoRA fine-tuned adapter for Qwen/Qwen2.5-0.5B-Instruct trained on the ChatDoctor-HealthCareMagic-100k medical Q&A dataset.
Model Details
- Base Model: Qwen/Qwen2.5-0.5B-Instruct
- Fine-tuning Method: QLoRA (4-bit quantization + LoRA)
- Dataset: ChatDoctor-HealthCareMagic-100k
- Training Samples: 39,500
- Evaluation Samples: 500
LoRA Configuration
- Rank (r): 16
- Alpha: 32
- Dropout: 0.05
- Target Modules: q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj
Training Configuration
- Epochs: 1
- Batch Size: 4
- Gradient Accumulation Steps: 4
- Learning Rate: 0.0002
- Max Sequence Length: 512
Evaluation Results (ROUGE Metrics)
| Metric | Score |
|---|---|
| ROUGE-1 | 0.2646 |
| ROUGE-2 | 0.0485 |
| ROUGE-L | 0.1493 |
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model and tokenizer
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-0.5B-Instruct",
device_map="auto",
torch_dtype=torch.bfloat16,
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "justjuu/qwen2.5-0.5b-chatdoctor-qlora-adapters")
# Generate response
messages = [
{"role": "system", "content": "You are a helpful medical assistant."},
{"role": "user", "content": "What are the symptoms of diabetes?"},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Training Framework
- transformers: HuggingFace Transformers
- peft: Parameter-Efficient Fine-Tuning
- trl: Transformer Reinforcement Learning (SFTTrainer)
- bitsandbytes: 4-bit quantization
Disclaimer
This model is for educational and research purposes only. It should not be used as a substitute for professional medical advice, diagnosis, or treatment. Always seek the advice of a qualified healthcare provider.
- Downloads last month
- 3
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support