lavita/ChatDoctor-HealthCareMagic-100k
Viewer • Updated • 112k • 4.83k • 111
How to use justjuu/qwen2.5-0.5b-chatdoctor-qlora-adapters with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-0.5B-Instruct")
model = PeftModel.from_pretrained(base_model, "justjuu/qwen2.5-0.5b-chatdoctor-qlora-adapters")This is a QLoRA fine-tuned adapter for Qwen/Qwen2.5-0.5B-Instruct trained on the ChatDoctor-HealthCareMagic-100k medical Q&A dataset.
| Metric | Score |
|---|---|
| ROUGE-1 | 0.2646 |
| ROUGE-2 | 0.0485 |
| ROUGE-L | 0.1493 |
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))
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.