🚀 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}
}