Downloads · 30 days
11
31% of all-time downloads
gandhiraketla277/demo-lora-reward-model
demo-lora-reward-model is a text generation model from gandhiraketla277. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as mit.
This is a demonstration LoRA-based reward model fine-tuned from GPT-2 for RLHF (Reinforcement Learning from Human Feedback) applications.
Downloads · 30 days
11
31% of all-time downloads
All-time downloads
35
Public
Repo size
23.6 MB
Likes
0
Public
Click a slice to open those files.
.safetensors23.6 MB · 83%
From the Hugging Face model README
This is a demonstration LoRA-based reward model fine-tuned from GPT-2 for RLHF (Reinforcement Learning from Human Feedback) applications.
LoraConfig(
r=8,
lora_alpha=16,
target_modules=["c_attn", "c_proj"],
lora_dropout=0.1,
bias="none",
task_type="SEQ_CLS" # Sequence Classification for reward modeling
)
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from peft import PeftModel
import torch
# Load base model
base_model = AutoModelForSequenceClassification.from_pretrained(
"gpt2",
num_labels=1, # Reward score
torch_dtype=torch.float16,
device_map="auto"
)
# Load LoRA adapters
model = PeftModel.from_pretrained(
base_model,
"gandhiraketla277/demo-lora-reward-model"
)
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained("gpt2")
tokenizer.pad_token = tokenizer.eos_token
def get_reward_score(text, model, tokenizer):
inputs = tokenizer(
text,
return_tensors="pt",
padding=True,
truncation=True,
max_length=512
)
with torch.no_grad():
outputs = model(**inputs)
reward_score = outputs.logits.squeeze().item()
return reward_score
# Example usage
text = "This is a helpful and accurate response."
score = get_reward_score(text, model, tokenizer)
print(f"Reward score: {score:.3f}")
This reward model can be used for:
@misc{demo-lora-reward-2025,
title={Demo LoRA Reward Model},
author={gandhiraketla277},
year={2025},
publisher={Hugging Face},
url={https://huggingface.co/gandhiraketla277/demo-lora-reward-model}
}
This model is released under the MIT License for educational use.