π§ Qwen2.5-3B-Medical-LoRA
Author: AbdullahAlnemr1
Base Model: Qwen/Qwen2.5-3B-Instruct
Dataset: lavita/ChatDoctor-HealthCareMagic-100k
Training Type: Parameter-efficient fine-tuning (LoRA)
Framework: π€ Transformers, PEFT, bitsandbytes, Accelerate
π©Ί 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
β οΈ 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
π Example
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...
π¦ Inference
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 generation
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)
- Downloads last month
- 57