Views
No views yet
unsloth/Qwen2.5-3B-bnb-4bit (via Phase 1 Oncology LoRA)ChatML structure (System, User, Assistant).unsloth and the TRL (Transformer Reinforcement Learning) SFTTrainer for high-efficiency instruction tuning.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 Oncology Chat Adapter
9model = PeftModel.from_pretrained(base_model, "Hriday75/qwen2.5-3b-oncology-chat")
10
11# 3. Format your chat prompt
12messages = [
13 {"role": "system", "content": "You are a helpful, empathetic oncology expert."},
14 {"role": "user", "content": "Hi doctor, my biopsy results mention 'invasive ductal carcinoma'. What does this mean, and what happens next?"}
15]
16
17inputs = tokenizer.apply_chat_template(
18 messages,
19 tokenize=True,
20 add_generation_prompt=True,
21 return_tensors="pt"
22)