🧠 Qwen2.5-3B-Medical-LoRA

Model Size
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
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using AbdullahAlnemr1/qwen2.5-medical-lora 1