Ray2333/GRM-Gemma-2B-rewardmodel-ft

Model

1

stars

9

commits

5

repos using this model

1

linked in READMEs

Feb 5, 2025

updated

gemma
safetensors

README

Introduction

This reward model is finetuned from the Ray2333/GRM-Gemma-2B-sftreg using the Skywork preference dataset.

The Skywork preference dataset demonstrates that a small high-quality dataset can lead to powerful reward models, which is promising. By finetuning Ray2333/GRM-Gemma-2B-sftreg on this dataset, we obtain a SOTA 2B reward model that can even surpass gpt4 as a judge.

Evaluation

We evaluate GRM-Gemma-2B-rewardmodel-ft on the reward model benchmark, where it achieved SOTA performance among models smaller than 6B.

When evaluated using reward bench, please add '--not_quantized' to avoid performance drop.

ModelAverageChatChat HardSafetyReasoning
Ray2333/GRM-Gemma-2B-rewardmodel-ft (Ours, 2B)84.789.475.285.588.8
openai/gpt-4o-2024-05-1384.696.670.486.584.9
sfairXC/FsfairX-LLaMA3-RM-v0.1 (8B)84.499.465.186.886.4
Nexusflow/Starling-RM-34B82.696.957.287.788.5
Ray2333/GRM-Gemma-2B-sftreg(Ours, 2B)75.395.548.780.076.8
berkeley-nest/Starling-RM-7B-alpha (7B)74.69843.488.674.6
Ray2333/Gemma-2B-rewardmodel-baseline(Ours, 2B)73.794.146.179.675.0
stabilityai/stablelm-zephyr-3b (3B)73.186.360.170.375.7
openbmb/UltraRM-13b (13B)71.396.155.345.882

Usage

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

device = 'cuda:0'
# load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained('Ray2333/GRM-Gemma-2B-rewardmodel-ft')
reward_model = AutoModelForSequenceClassification.from_pretrained(
                'Ray2333/GRM-Gemma-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)
# it will look like this: "<bos><start_of_turn>user\nI'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?<end_of_turn>\n<start_of_turn>model\nSorry, 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?<end_of_turn>\n".

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()

Citation

If you find this model helpful for your research, please cite GRM

@article{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},
  journal={arXiv preprint arXiv:2406.10216},
  year={2024}
}

Contributors

Ray2333

9 commits

Ray2333/GRM-Gemma-2B-rewardmodel-ft

Model

1

stars

9

commits

5

repos using this model

1

linked in READMEs

Feb 5, 2025

updated

gemma
safetensors

README

Introduction

This reward model is finetuned from the Ray2333/GRM-Gemma-2B-sftreg using the Skywork preference dataset.

The Skywork preference dataset demonstrates that a small high-quality dataset can lead to powerful reward models, which is promising. By finetuning Ray2333/GRM-Gemma-2B-sftreg on this dataset, we obtain a SOTA 2B reward model that can even surpass gpt4 as a judge.

Evaluation

We evaluate GRM-Gemma-2B-rewardmodel-ft on the reward model benchmark, where it achieved SOTA performance among models smaller than 6B.

When evaluated using reward bench, please add '--not_quantized' to avoid performance drop.

ModelAverageChatChat HardSafetyReasoning
Ray2333/GRM-Gemma-2B-rewardmodel-ft (Ours, 2B)84.789.475.285.588.8
openai/gpt-4o-2024-05-1384.696.670.486.584.9
sfairXC/FsfairX-LLaMA3-RM-v0.1 (8B)84.499.465.186.886.4
Nexusflow/Starling-RM-34B82.696.957.287.788.5
Ray2333/GRM-Gemma-2B-sftreg(Ours, 2B)75.395.548.780.076.8
berkeley-nest/Starling-RM-7B-alpha (7B)74.69843.488.674.6
Ray2333/Gemma-2B-rewardmodel-baseline(Ours, 2B)73.794.146.179.675.0
stabilityai/stablelm-zephyr-3b (3B)73.186.360.170.375.7
openbmb/UltraRM-13b (13B)71.396.155.345.882

Usage

import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification

device = 'cuda:0'
# load model and tokenizer
tokenizer = AutoTokenizer.from_pretrained('Ray2333/GRM-Gemma-2B-rewardmodel-ft')
reward_model = AutoModelForSequenceClassification.from_pretrained(
                'Ray2333/GRM-Gemma-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)
# it will look like this: "<bos><start_of_turn>user\nI'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?<end_of_turn>\n<start_of_turn>model\nSorry, 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?<end_of_turn>\n".

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()

Citation

If you find this model helpful for your research, please cite GRM

@article{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},
  journal={arXiv preprint arXiv:2406.10216},
  year={2024}
}

Contributors

Ray2333

9 commits