Downloads · 30 days
0
masharma/my-personalized-llama-dpo
my-personalized-llama-dpo is a machine learning model from masharma. 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 transformers.
This model is a personalized version of Llama-3.2-3B-Instruct, fine-tuned using Direct Preference Optimization (DPO) on human preference data.
Downloads · 30 days
0
Access
Public
Updated Oct 15, 2025
Repo size
26.4 MB
Likes
0
Public
Click a slice to open those files.
.json17.3 MB · 65%
From the Hugging Face model README
This model is a personalized version of Llama-3.2-3B-Instruct, fine-tuned using Direct Preference Optimization (DPO) on human preference data.
This model was created as part of CS 329X homework on Model Alignment and Human Feedback. It has been fine-tuned using DPO to align with personal preferences collected through the PRISM dataset.
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"meta-llama/Llama-3.2-3B-Instruct",
load_in_4bit=True,
device_map="auto"
)
# Load LoRA adapter
model = PeftModel.from_pretrained(
base_model,
"masharma/my-personalized-llama-dpo"
)
tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-3.2-3B-Instruct")
# Generate
messages = [
{"role": "system", "content": "You are a helpful assistant"},
{"role": "user", "content": "What are your thoughts on climate change?"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
The model shows increased confidence and more structured responses compared to the base model, with:
Course: CS 329X - Model Alignment and Human Feedback (Stanford University)
Assignment: HW1 - Direct Preference Optimization
Mayank Sharma - Stanford University