🚀 GRM-Gemma2-2B 奖励模型
本奖励模型在奖励基准测试中取得了 88.4 的分数,它是基于 Ray2333/GRM-Gemma2-2B-sftreg,使用经过净化的 Skywork 偏好数据集 v0.2 进行微调得到的。我们得到了一个 SOTA 2B 奖励模型,它可以超越一系列 8B 奖励模型,甚至在作为评判器时超过 GPT4/Gemini。
查看我们的 GRM 系列,请访问 🤗Hugging Face;查看我们的论文,请访问 Arxiv;查看我们的 GitHub 仓库,请访问 Github。
🚀 快速开始
本奖励模型基于特定的基础模型和数据集微调而来,在奖励基准测试中表现出色。下面将为你介绍模型的评估情况、使用方法等内容。
✨ 主要特性
- 高性能:在奖励基准测试中取得了 88.4 的分数,超越了一系列 8B 奖励模型,甚至在作为评判器时超过 GPT4/Gemini。
- 小模型优势:作为 2B 模型,在小于 3B 的模型中取得了 SOTA 性能。
📚 详细文档
评估
我们在 奖励模型基准测试 上对 GRM-Gemma2-2B-rewardmodel-ft 进行了评估,该模型在小于 3B 的模型中取得了 SOTA 性能。
⚠️ 重要提示
当使用奖励基准进行评估时,请添加 '--not_quantized' 以避免性能下降。
模型信息
💻 使用示例
基础用法
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
device = 'cuda:0'
tokenizer = AutoTokenizer.from_pretrained('Ray2333/GRM-Gemma2-2B-rewardmodel-ft')
reward_model = AutoModelForSequenceClassification.from_pretrained(
'Ray2333/GRM-Gemma2-2B-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()
📄 许可证
本项目使用 Apache-2.0 许可证。
📚 引用
如果您发现该模型对您的研究有帮助,请引用 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}
}