Downloads · 30 days
10
29% of all-time downloads
Shawnno/qwen2.5-3b-interview-dpo-lora
qwen2.5-3b-interview-dpo-lora is a text generation model from Shawnno. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
「面试助手」项目的 SFT+DPO LoRA adapter,基座为 Qwen/Qwen2.5-3B-Instruct。目标是让回答像面试现场口头作答:简单、专业、口语化、长度约 150-300 字、自然收尾。
Downloads · 30 days
10
29% of all-time downloads
All-time downloads
35
Public
Repo size
59.9 MB
Likes
0
Public
Click a slice to open those files.
.safetensors59.9 MB · 100%
From the Hugging Face model README
「面试助手」项目的 SFT+DPO LoRA adapter,基座为 Qwen/Qwen2.5-3B-Instruct。目标是让回答像面试现场口头作答:简单、专业、口语化、长度约 150-300 字、自然收尾。
⚠️ 重要:本 adapter 是在 SFT LoRA 权重上继续 DPO 训练得到的,已经包含 SFT 的权重。直接加载到干净的基座上就是 SFT+DPO 的完整效果,不要再叠加 Shawnno/qwen2.5-3b-interview-sft-lora。
Shawnno/qwen2.5-3b-interview-sft-lora)max_len_ratio ≤ 1.3,消除「更长更好」的偏置)import torch
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
base = "Qwen/Qwen2.5-3B-Instruct"
adapter = "Shawnno/qwen2.5-3b-interview-dpo-lora"
tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(
base,
quantization_config=BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.bfloat16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
),
device_map="auto",
)
model = PeftModel.from_pretrained(model, adapter)
model.eval()
messages = [{"role": "user", "content": "请解释机器学习中的偏差和方差"}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=600, do_sample=False, pad_token_id=tokenizer.eos_token_id)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
| 指标 | SFT | SFT+DPO(本仓库) |
|---|---|---|
| median 字数 | 345 | 443 |
| natural ending | 100% | 100% |
| strong 5-gram 重复率 | 9.4% | 10.9% |
| ≤550 字占比 | 96.9% | 84.4% |
DPO 在保住 SFT 简洁风格的同时,修掉了旧 DPO 的两大问题:natural ending 82.8% → 100%,strong 5-gram 重复率 25.0% → 10.9%(回到 SFT 水平)。已知取舍:DPO 仍比 SFT 长约 100 字,多出来的是更完整的论证和结论句,不是重复水词。
详见项目仓库 kinjazA/RL 的「DPO 阶段」章节(偏好数据构造、OOM 修复、natural-ending 修复等)。