Downloads · 30 days
6
9% of all-time downloads
xypkent/assignment4-qwen25-7b-dpo-adapter
assignment4-qwen25-7b-dpo-adapter is a machine learning model from xypkent. 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 repository contains a PEFT LoRA adapter fine-tuned with Direct Preference Optimization (DPO) for DSAA6000Q Assignment 4.
Downloads · 30 days
6
9% of all-time downloads
All-time downloads
66
Public
Repo size
162 MB
Likes
0
Public
Click a slice to open those files.
.safetensors162 MB · 100%
From the Hugging Face model README
This repository contains a PEFT LoRA adapter fine-tuned with Direct Preference Optimization (DPO) for DSAA6000Q Assignment 4.
xypkent/assignment4-qwen25-7b-dpo-adapterQwen/Qwen2.5-7B-Instructxypkent/assignment4-lima-pairrm-prefGAIR/lima(prompt, chosen, rejected) pairstransformers, trl, peft, torchQwen/Qwen2.5-7B-Instructinstructionoriginal_completiondpo_completionfrom transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model_id = "Qwen/Qwen2.5-7B-Instruct"
adapter_id = "xypkent/assignment4-qwen25-7b-dpo-adapter"
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
if tokenizer.pad_token is None:
tokenizer.pad_token = tokenizer.eos_token
tokenizer.padding_side = "left"
dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
torch_dtype=dtype,
device_map="auto" if torch.cuda.is_available() else None,
)
if not torch.cuda.is_available():
base_model.to("cpu")
model = PeftModel.from_pretrained(base_model, adapter_id)
model.eval()