🚀 Qwen2.5-3B-Medical-LoRA
Qwen2.5-3B-Medical-LoRA
is a fine - tuned model based on Qwen2.5-3B-Instruct. It is trained on a healthcare - focused dataset, aiming to generate medically relevant responses and offer clear health guidance.
✨ Features
- Fine - tuned on the
ChatDoctor-HealthCareMagic-100k
dataset for healthcare scenarios.
- Utilizes LoRA (Low - Rank Adaptation) for efficient training.
- Can be deployed on consumer hardware using 4 - bit quantization with bitsandbytes.
📦 Installation
The README doesn't provide specific installation steps, so this section is skipped.
💻 Usage Examples
Basic Usage
Input:
instruction = "I'm a 60-year-old man with a history of hypertension and type 2 diabetes..."
response = generate_response(instruction)
Output:
The symptoms you're describing — including chest pain on exertion, fatigue, shortness of breath, and ankle swelling — may indicate congestive heart failure or coronary artery disease...
Advanced Usage
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
import torch
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-3B-Instruct", trust_remote_code=True)
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4"
)
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-3B-Instruct",
quantization_config=bnb_config,
device_map="auto",
trust_remote_code=True
)
model = PeftModel.from_pretrained(base_model, "AbdullahAlnemr1/qwen2.5-medical-lora")
model = model.merge_and_unload()
model.eval()
prompt = '''<|im_start|>system
You are a highly knowledgeable and accurate medical assistant...
<|im_end|>
<|im_start|>user
Instruction: What are the symptoms of anemia?<|im_end|>
<|im_start|>assistant
'''
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
📚 Documentation
Model Overview
Qwen2.5-3B-Medical-LoRA
is a fine - tuned version of Qwen2.5-3B-Instruct on the healthcare - focused dataset ChatDoctor-HealthCareMagic-100k
. It is designed to generate medically relevant responses to user instructions, offering clear and concise health guidance.
This model uses LoRA (Low - Rank Adaptation) for efficient training, enabling deployment on consumer hardware using 4 - bit quantization with bitsandbytes.
Files and Artifacts
adapter_model
: LoRA weights trained on the healthcare dataset.
README.md
: Project documentation.
training_args.bin
: Training configuration.
tokenizer_config.json
, tokenizer.model
, special_tokens_map.json
: Tokenizer files.
Intended Use
- Medical Question - Answering
- Health advisory systems
- Educational tools for healthcare professionals
- AI - assisted medical assistants
⚠️ Important Note
This model is not a substitute for professional medical advice, diagnosis, or treatment. Always consult with a licensed healthcare provider.
Prompt Format
This model follows an instruction - tuned format:
<|im_start|>system
You are a highly knowledgeable and accurate medical assistant trained to provide evidence - based medical advice. Answer clearly and concisely using medical best practices. If the question is unclear or potentially harmful to answer, respond with a disclaimer.<|im_end|>
<|im_start|>user
Instruction: [YOUR INSTRUCTION HERE]
[OPTIONAL INPUT]<|im_end|>
<|im_start|>assistant
📄 License
This project is licensed under the apache - 2.0
license.
Property |
Details |
Model Type |
Qwen2.5-3B-Medical-LoRA |
Training Data |
lavita/ChatDoctor-HealthCareMagic-100k |
Author |
AbdullahAlnemr1 |
Base Model |
Qwen/Qwen2.5-3B-Instruct |
Training Type |
Parameter - efficient fine - tuning (LoRA) |
Framework |
Transformers, PEFT, bitsandbytes, Accelerate |