Downloads · 30 days
14
26% of all-time downloads
SetonLiang2/qwen25-7b-assignment4-dpo-adapter
qwen25-7b-assignment4-dpo-adapter is a machine learning model from SetonLiang2. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft.
This is a PEFT LoRA adapter fine-tuned from Qwen/Qwen2.5-7B-Instruct for a course assignment on DPO-based preference optimization.
Downloads · 30 days
14
26% of all-time downloads
All-time downloads
54
Public
Repo size
92.2 MB
Likes
0
Public
Click a slice to open those files.
.safetensors80.8 MB · 84%
From the Hugging Face model README
This is a PEFT LoRA adapter fine-tuned from Qwen/Qwen2.5-7B-Instruct for a course assignment on DPO-based preference optimization.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model_id = "Qwen/Qwen2.5-7B-Instruct"
adapter_path = "SetonLiang2/qwen25-7b-assignment4-dpo-adapter"
tokenizer = AutoTokenizer.from_pretrained(base_model_id, trust_remote_code=True)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
)
model = PeftModel.from_pretrained(base_model, adapter_path)
model.eval()
messages = [{"role": "user", "content": "请解释什么是DPO"}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=256, do_sample=True, temperature=0.7, top_p=0.9)
print(tokenizer.decode(outputs[0][inputs.shape[-1]:], skip_special_tokens=True))
If your deployment environment does not support PEFT, you can merge the adapter into the base model first and run inference on the merged model.