Views
No views yet
| Subfolder on the Hub | Training target (response_aspect) | Description |
|---|---|---|
full-lora | full | Supervise the full extended-refusal style response. |
explanation-only-lora | explanation_only | Supervise only the explanation segment. |
justification-only-lora | justification_only | Supervise only the justification segment. |
refusal-only-lora | refusal_only | Supervise only the refusal segment. |
adapter_model.safetensors, adapter_config.json, and tokenizer files (tokenizer.json, tokenizer_config.json, chat_template.jinja, etc.) aligned with the base instruct model.pip install "transformers>=4.43" "peft>=0.11" torch acceleratetransformers / peft pair that supports Qwen2.5 and PeftModel.from_pretrained(..., subfolder=...).SUBFOLDER from the table above (e.g. full-lora).1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5BASE_MODEL_ID = "Qwen/Qwen2.5-3B-Instruct"
6ADAPTER_REPO_ID = "CSMaya/er_ablations_qwen2.5_3b"
7SUBFOLDER = "full-lora" # or explanation-only-lora, justification-only-lora, refusal-only-lora
8
9tokenizer = AutoTokenizer.from_pretrained(ADAPTER_REPO_ID, subfolder=SUBFOLDER, trust_remote_code=True)
10
11model = AutoModelForCausalLM.from_pretrained(
12 BASE_MODEL_ID,
13 torch_dtype=torch.bfloat16 if torch.cuda.is_bf16_supported() else torch.float16,
14 device_map="auto",
15 trust_remote_code=True,
16)
17model = PeftModel.from_pretrained(model, ADAPTER_REPO_ID, subfolder=SUBFOLDER)
18
19# Example chat turn (match Qwen2.5 Instruct chat format)
20messages = [{"role": "user", "content": "Your prompt here."}]
21inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
22outputs = model.generate(inputs, max_new_tokens=256, do_sample=False)
23print(tokenizer.decode(outputs[0], skip_special_tokens=True))train_sft.py + YAML under configs/). Summary for these Qwen runs:| Setting | Value |
|---|---|
| Base model | Qwen/Qwen2.5-3B-Instruct |
| Dataset | HarethahMo/extended-refusal (train split) |
| Method | LoRA (not QLoRA) on attention + MLP projections |
LoRA r / alpha / dropout | 64 / 128 / 0.05 |
| Epochs | 3 |
| Learning rate | 1e-6 |
| Max sequence length | 2048 |
| Per-device batch / grad accumulation | 1 / 8 |
| Precision | bf16 when supported |
| Gradient checkpointing | on |
response_aspect selects which segment of the formatted assistant output contributes to the SFT loss (full, explanation_only, justification_only, refusal_only). See the project train_sft.py flag --response_aspect and dataset loader for details.