Views
No views yet
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.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.⚠️ This model is not a substitute for professional medical advice, diagnosis, or treatment. Always consult with a licensed healthcare provider.
<|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|>assistant1instruction = "I'm a 60-year-old man with a history of hypertension and type 2 diabetes..."
2response = generate_response(instruction)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...1from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
2from peft import PeftModel
3import torch
4
5tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-3B-Instruct", trust_remote_code=True)
6
7bnb_config = BitsAndBytesConfig(
8 load_in_4bit=True,
9 bnb_4bit_compute_dtype=torch.float16,
10 bnb_4bit_use_double_quant=True,
11 bnb_4bit_quant_type="nf4"
12)
13
14base_model = AutoModelForCausalLM.from_pretrained(
15 "Qwen/Qwen2.5-3B-Instruct",
16 quantization_config=bnb_config,
17 device_map="auto",
18 trust_remote_code=True
19)
20
21model = PeftModel.from_pretrained(base_model, "AbdullahAlnemr1/qwen2.5-medical-lora")
22model = model.merge_and_unload()
23model.eval()
24
25# Prompt generation
26prompt = '''<|im_start|>system
27You are a highly knowledgeable and accurate medical assistant...
28<|im_end|>
29<|im_start|>user
30Instruction: What are the symptoms of anemia?<|im_end|>
31<|im_start|>assistant
32'''
33
34inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
35outputs = model.generate(**inputs, max_new_tokens=512)
36response = tokenizer.decode(outputs[0], skip_special_tokens=True)
37print(response)