Downloads · 30 days
9
24% of all-time downloads
shayfeng/qwen-dpo-adapter
qwen-dpo-adapter is a machine learning model from shayfeng. 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. The card lists the license as apache-2.0.
This is a PEFT LoRA adapter for Qwen2.5-7B-Instruct fine-tuned using Direct Preference Optimization (DPO).
Downloads · 30 days
9
24% of all-time downloads
All-time downloads
38
Public
Repo size
—
Likes
0
Public
Click a slice to open those files.
.md1.5 KB · 40%
From the Hugging Face model README
This is a PEFT LoRA adapter for Qwen2.5-7B-Instruct fine-tuned using Direct Preference Optimization (DPO).
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct",
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(
base_model,
"your-username/qwen-dpo-adapter"
)
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-7B-Instruct")
# Generate
messages = [{"role": "user", "content": "Your prompt here"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0]))
The fine-tuned model shows improvements in response quality through optimized preferences.
Generated for Assignment 4 - AI Model Fine-tuning