🚀 GRM-Llama3.2-3B奖励模型
本奖励模型是基于Transformer架构的奖励模型,通过对基础模型进行微调,在奖励模型基准测试中取得了优异的成绩,为大语言模型的奖励评估提供了有效的解决方案。
🚀 快速开始
本奖励模型在 reward-bench 上取得了90.9的分数。它是基于 Ray2333/GRM-llama3.2-3B-sftreg 模型,使用经过净化处理的 Skywork偏好数据集v0.2 进行微调得到的。我们得到了一个SOTA 3B奖励模型,它可以超越一系列8B奖励模型,甚至在作为评判器时超过gpt4/gemini。
你可以在🤗 hugging face 查看我们的GRM系列模型,在 Arxiv 查看我们的论文,在 Github 查看我们的代码仓库。
✨ 主要特性
- 高性能:在奖励模型基准测试中,该模型在小于7B的模型中表现出色。
- 小模型大能量:3B参数的模型能够超越一系列8B奖励模型,甚至在评判任务中超过gpt4/gemini。
📦 安装指南
此部分原文档未提及具体安装步骤,故跳过。
💻 使用示例
基础用法
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
device = 'cuda:0'
tokenizer = AutoTokenizer.from_pretrained('Ray2333/GRM-Llama3.2-3B-rewardmodel-ft')
reward_model = AutoModelForSequenceClassification.from_pretrained(
'Ray2333/GRM-Llama3.2-3B-rewardmodel-ft', torch_dtype=torch.float16,
device_map=device,
)
message = [
{'role': 'user', 'content': "I'm going to go out to a movie, but I need someone to chat with my daughter and pretend to be me while she's home alone. But I can't do that while I'm at the movie. Can you help by impersonating me by chat with her?"},
{'role': 'assistant', 'content': "Sorry, I'm not comfortable impersonating you in that way. I'm not willing to behave so dishonestly. Maybe you can just find a way to bring her to the movie, or you can find a babysitter?"}
]
message_template = tokenizer.apply_chat_template(message, tokenize=False)
kwargs = {"padding": 'longest', "truncation": True, "return_tensors": "pt"}
tokens = tokenizer.encode_plus(message_template, **kwargs)
with torch.no_grad():
reward_tensor = reward_model(tokens["input_ids"][0].view(1,-1).to(device), attention_mask=tokens["attention_mask"][0].view(1,-1).to(device))[0]
reward = reward_tensor.cpu().detach().item()
📚 详细文档
评估
我们在 奖励模型基准测试 上对GRM-Llama3.2-3B-rewardmodel-ft进行了评估,该模型在小于7B的模型中表现强劲。
⚠️ 重要提示
使用reward bench进行评估时,请添加 '--not_quantized' 以避免性能下降。
引用
如果你发现这个模型对你的研究有帮助,请引用GRM:
@inproceedings{yang2024regularizing,
title={Regularizing Hidden States Enables Learning Generalizable Reward Model for LLMs},
author={Yang, Rui and Ding, Ruomeng and Lin, Yong and Zhang, Huan and Zhang, Tong},
booktitle={Advances in Neural Information Processing Systems},
year={2024}
}
📄 许可证
本项目采用Apache 2.0许可证。