Ray2333 commited on
Commit
03f73bd
1 Parent(s): 65afc19

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +76 -3
README.md CHANGED
@@ -1,3 +1,76 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ datasets:
4
+ - Skywork/Skywork-Reward-Preference-80K-v0.1
5
+ language:
6
+ - en
7
+ base_model:
8
+ - Ray2333/GRM-Gemma-2B-sftreg
9
+ ---
10
+
11
+
12
+ # Introduction
13
+ This reward model is finetuned from the [Ray2333/GRM-Gemma-2B-sftreg](https://huggingface.co/Ray2333/GRM-Gemma-2B-sftreg) using the [Skywork preference dataset](https://huggingface.co/datasets/Skywork/Skywork-Reward-Preference-80K-v0.1).
14
+
15
+ 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](https://huggingface.co/Ray2333/GRM-Gemma-2B-sftreg) on this dataset, we obtain a **SOTA 2B reward model** that can even surpass gpt4 as a judge.
16
+
17
+
18
+
19
+ ## Evaluation
20
+ We evaluate Gemma-2B-rewardmodel-ft on the [reward model benchmark](https://huggingface.co/spaces/allenai/reward-bench), where it achieved SOTA performance among models smaller than 6B.
21
+
22
+
23
+ | Model | Average | Chat | Chat Hard | Safety | Reasoning |
24
+ |:-------------------------:|:-------------:|:---------:|:---------:|:--------:|:-----------:|
25
+ |**Ray2333/Gemma-2B-rewardmodel-ft (Ours, 2B)**| **84.7** | 89.4 | 75.2 | 85.5 | 88.8 |
26
+ | openai/gpt-4o-2024-05-13 | 84.6| 96.6 | 70.4 | 86.5 | 84.9 |
27
+ | sfairXC/FsfairX-LLaMA3-RM-v0.1 (8B) | 84.4 | 99.4 | 65.1 | 86.8 | 86.4 |
28
+ | Nexusflow/Starling-RM-34B | 82.6 |96.9 |57.2 |87.7 |88.5|
29
+ | [**Ray2333/GRM-Gemma-2B-sftreg**](https://huggingface.co/Ray2333/GRM-Gemma-2B-sftreg)**(Ours, 2B)** | 75.3 | 95.5 | 48.7 | 80.0 | 76.8 |
30
+ | berkeley-nest/Starling-RM-7B-alpha (7B) | 74.6 | 98 | 43.4 | 88.6 | 74.6 |
31
+ | **Ray2333/Gemma-2B-rewardmodel-baseline**(Ours, 2B) | 73.7 | 94.1 | 46.1 | 79.6 | 75.0 |
32
+ | stabilityai/stablelm-zephyr-3b (3B) | 73.1 | 86.3 | 60.1 | 70.3 | 75.7 |
33
+ | openbmb/UltraRM-13b (13B) | 71.3 | 96.1 | 55.3 | 45.8 | 82 |
34
+
35
+
36
+
37
+
38
+ ## Usage
39
+
40
+ ```
41
+ import torch
42
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
43
+
44
+ device = 'cuda:0'
45
+ # load model and tokenizer
46
+ tokenizer = AutoTokenizer.from_pretrained('Ray2333/Gemma-2B-rewardmodel-ft')
47
+ reward_model = AutoModelForSequenceClassification.from_pretrained(
48
+ 'Ray2333/Gemma-2B-rewardmodel-ft', torch_dtype=torch.float16,
49
+ device_map=device,
50
+ )
51
+ message = [
52
+ {'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?"},
53
+ {'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?"}
54
+ ]
55
+ message_template = tokenizer.apply_chat_template(message, tokenize=False)
56
+ # 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".
57
+
58
+ kwargs = {"padding": 'max_length', "truncation": True, "return_tensors": "pt"}
59
+ tokens = tokenizer.encode_plus(message_template, **kwargs)
60
+
61
+ with torch.no_grad():
62
+ 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]
63
+ reward = reward_tensor.cpu().detach().item()
64
+ ```
65
+
66
+
67
+ ## Citation
68
+ If you find this model helpful for your research, please cite GRM
69
+ ```
70
+ @article{yang2024regularizing,
71
+ title={Regularizing Hidden States Enables Learning Generalizable Reward Model for LLMs},
72
+ author={Yang, Rui and Ding, Ruomeng and Lin, Yong and Zhang, Huan and Zhang, Tong},
73
+ journal={arXiv preprint arXiv:2406.10216},
74
+ year={2024}
75
+ }
76
+ ```