Views
No views yet
unsloth/Qwen2.5-3B-bnb-4bit (via Phase 2 Infectious Disease Chat LoRA)chosen (structurally valid medical outputs) and rejected (annotated structural or formatting errors) examples to learn from.unsloth and the TRL DPOTrainer. DPO requires an extremely low learning rate to subtly shift the model's generation probabilities toward the "chosen" format without destroying the scientific knowledge learned in Phases 1 and 2.1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4# 1. Load the base model and tokenizer
5base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen2.5-3B-bnb-4bit")
6tokenizer = AutoTokenizer.from_pretrained("unsloth/Qwen2.5-3B-bnb-4bit")
7
8# 2. Attach this DPO Aligned Infectious Disease Adapter
9model = PeftModel.from_pretrained(base_model, "Hriday75/qwen2.5-3b-infectious-disease-dpo-aligned")
10
11# 3. Format your chat prompt
12messages = [
13 {"role": "system", "content": "You are a helpful, empathetic infectious disease expert."},
14 {"role": "user", "content": "Please review these lab results and generate a structured clinical summary regarding the patient's viral load."}
15]
16
17inputs = tokenizer.apply_chat_template(
18 messages,
19 tokenize=True,
20 add_generation_prompt=True,
21 return_tensors="pt"
22)