chrisliu298
commited on
Commit
•
fa899ca
1
Parent(s):
287efed
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -1,199 +1,144 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
|
7 |
|
8 |
-
|
|
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
12 |
-
|
13 |
|
14 |
-
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
19 |
|
20 |
-
|
21 |
-
- **Funded by [optional]:** [More Information Needed]
|
22 |
-
- **Shared by [optional]:** [More Information Needed]
|
23 |
-
- **Model type:** [More Information Needed]
|
24 |
-
- **Language(s) (NLP):** [More Information Needed]
|
25 |
-
- **License:** [More Information Needed]
|
26 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
27 |
|
28 |
-
|
|
|
|
|
|
|
29 |
|
30 |
-
|
31 |
|
32 |
-
|
33 |
-
- **Paper [optional]:** [More Information Needed]
|
34 |
-
- **Demo [optional]:** [More Information Needed]
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
39 |
|
40 |
-
|
41 |
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
47 |
|
48 |
-
|
|
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
|
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
-
|
|
|
|
|
59 |
|
60 |
-
|
|
|
61 |
|
62 |
-
|
|
|
|
|
|
|
|
|
63 |
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
|
|
|
|
|
|
67 |
|
68 |
-
|
69 |
|
70 |
-
|
71 |
|
72 |
-
|
73 |
|
74 |
-
|
75 |
|
76 |
-
|
77 |
|
78 |
-
|
79 |
|
80 |
-
|
81 |
|
82 |
-
|
83 |
|
84 |
-
|
85 |
|
86 |
-
|
87 |
|
88 |
-
|
89 |
|
90 |
-
|
91 |
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
## Evaluation
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
base_model: meta-llama/Meta-Llama-3.1-8B-Instruct
|
4 |
+
datasets:
|
5 |
+
- nvidia/HelpSteer2
|
6 |
+
- NCSOFT/offsetbias
|
7 |
+
- allenai/wildguardmix
|
8 |
+
- argilla/magpie-ultra-v0.1
|
9 |
+
- Magpie-Align/Magpie-Llama-3.1-Pro-DPO-100K-v0.1
|
10 |
+
- Magpie-Align/Magpie-Pro-DPO-100K-v0.1
|
11 |
+
- Magpie-Align/Magpie-Air-DPO-100K-v0.1
|
12 |
+
pipeline_tag: text-classification
|
13 |
---
|
14 |
|
15 |
+
<div align="center">
|
16 |
|
17 |
+
<img src="misc/fig.jpg" width="400"/>
|
18 |
+
<div> </div>
|
19 |
+
</div>
|
20 |
|
21 |
+
# Skywork Reward Model Series
|
22 |
|
23 |
+
## Introduction
|
24 |
|
25 |
+
[**Skywork-Reward-Gemma-2-27B**](https://huggingface.co/Skywork/Skywork-Reward-Gemma-2-27B) and [**Skywork-Reward-Llama-3.1-8B**](https://huggingface.co/Skywork/Skywork-Reward-Llama-3.1-8B) are two advanced reward models built on the [gemma-2-27b-it](https://huggingface.co/google/gemma-2-27b-it) and [Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct) architectures, respectively. Both models were trained using the [Skywork Reward Data Collection](https://huggingface.co/collections/Skywork/skywork-reward-data-collection-66d7fda6a5098dc77035336d) containing only 80K high-quality preference pairs sourced from publicly available data.
|
26 |
|
27 |
+
We include only public data in an attempt to demonstrate that high-performance reward models can be achieved with a relatively small dataset and straightforward data curation techniques, without further algorithmic or architectural modifications. The sources of data used in the [Skywork Reward Data Collection](https://huggingface.co/collections/Skywork/skywork-reward-data-collection-66d7fda6a5098dc77035336d) are detailed in the [Data Mixture](#data-mixture) section below.
|
28 |
|
29 |
+
The resulting reward models excel at handling preferences in complex scenarios, including challenging preference pairs, and span various domains such as mathematics, coding, and safety. As of September 2024, they hold the first and the third positions on the [RewardBench leaderboard](https://huggingface.co/spaces/allenai/reward-bench).
|
30 |
|
31 |
+
## Data Mixture
|
32 |
|
33 |
+
Instead of relying on existing large preference datasets, we carefully curate the [Skywork Reward Data Collection](https://huggingface.co/collections/Skywork/skywork-reward-data-collection-66d7fda6a5098dc77035336d) (1) to include high-quality preference pairs and (2) to target specific capability and knowledge domains. The curated training dataset consists of approximately 80K samples, subsampled from multiple publicly available data sources, including
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
+
1. [HelpSteer2](https://huggingface.co/datasets/nvidia/HelpSteer2)
|
36 |
+
2. [OffsetBias](https://huggingface.co/datasets/NCSOFT/offsetbias)
|
37 |
+
3. [WildGuard (adversarial)](https://huggingface.co/allenai/wildguard)
|
38 |
+
4. Magpie DPO series: [Ultra](https://huggingface.co/datasets/argilla/magpie-ultra-v0.1), [Pro (Llama-3.1)](https://huggingface.co/datasets/Magpie-Align/Magpie-Llama-3.1-Pro-DPO-100K-v0.1), [Pro](https://huggingface.co/datasets/Magpie-Align/Magpie-Pro-DPO-100K-v0.1), [Air](https://huggingface.co/datasets/Magpie-Align/Magpie-Air-DPO-100K-v0.1).
|
39 |
|
40 |
+
**Disclaimer: We made no modifications to the original datasets listed above, other than subsampling the datasets to create the Skywork Reward Data Collection.**
|
41 |
|
42 |
+
During dataset curation, we adopt several tricks to achieve both performance improvement and a balance between each domain, without compromising the overall performance:
|
|
|
|
|
43 |
|
44 |
+
1. We select top samples from math, code, and other categories in the combined Magpie dataset independently, based on the average ArmoRM score provided with the dataset. We subtract the ArmoRM average scores in the Magpie-Air subset and the Magpie-Pro subset by 0.1 and 0.05, respectively, to prioritize Magpie-Ultra and Magpie-Pro-Llama-3.1 samples.
|
45 |
+
2. Instead of including all preference pairs in WildGuard, we first train a reward model (RM) on three other data sources. We then (1) use this RM to score the chosen and rejected responses for all samples in WildGuard and (2) select only samples where the chosen response's RM score is greater than the rejected response's RM score. We observe that this approach largely preserves the original performance of Chat, Char hard, and Reasoning while improving Safety. For both models, we use the 27B model to score the WildGuard samples.
|
46 |
|
47 |
+
## RewardBench Leaderboard
|
48 |
|
49 |
+
We evaluate our model on [RewardBench](https://huggingface.co/spaces/allenai/reward-bench) using the [official test script](https://github.com/allenai/reward-bench). As of September 2024, Skywork-Reward-Gemma-2-27B and Skywork-Reward-Llama-3.1-8B rank first and third on the RewardBench leaderboard.
|
50 |
|
51 |
+
| Rank | Model | Chat | Chat Hard | Safety | Reasoning | Score |
|
52 |
+
| :---: | --------------------------- | :---: | :-------: | :----: | :-------: | :---: |
|
53 |
+
| 1 | Skywork-Reward-Gemma-2-27B | 95.8 | 91.4 | 92.0 | 96.2 | 93.9 |
|
54 |
+
| 2 | SFR-LLaMa-3.1-70B-Judge-r | 96.9 | 84.8 | 92.2 | 97.6 | 92.8 |
|
55 |
+
| 3 | Skywork-Reward-Llama-3.1-8B | 96.1 | 87.3 | 90.6 | 96.1 | 92.5 |
|
56 |
+
| 4 | Nemotron-4-340B-Reward | 95.8 | 87.1 | 92.2 | 93.6 | 92.2 |
|
57 |
+
| 5 | ArmoRM-Llama3-8B-v0.1 | 96.9 | 76.8 | 92.2 | 97.3 | 90.8 |
|
58 |
+
| 6 | internlm2-20b-reward | 98.9 | 76.5 | 89.9 | 95.8 | 90.3 |
|
59 |
|
60 |
+
## Demo Code
|
61 |
|
62 |
+
We provide example usage of the Skywork reward model series below. Please note that:
|
63 |
|
64 |
+
1. We removed the BOS token from the chat templates of the two models to prevent it being added twice during `apply_chat_template` and tokenization.
|
65 |
+
2. To enable optimal performance for the 27B reward model, ensure that you have enabled either the `flash_attention_2` or `eager` implementation. The default `spda` implementation may result in bugs that could significantly degrade the model's performance for this particular model.
|
66 |
|
67 |
+
Below is an example of obtaining the reward scores of two conversations.
|
68 |
|
69 |
+
```python
|
70 |
+
import torch
|
71 |
|
72 |
+
from transformers import AutoModelForSequenceClassification, AutoTokenizer
|
73 |
|
74 |
+
# Load model and tokenizer
|
75 |
+
device = "cuda:0"
|
76 |
+
model_name = "Skywork/Skywork-Reward-Gemma-2-27B"
|
77 |
+
rm = AutoModelForSequenceClassification.from_pretrained(
|
78 |
+
model_name,
|
79 |
+
torch_dtype=torch.bfloat16,
|
80 |
+
device_map=device,
|
81 |
+
attn_implementation="flash_attention_2",
|
82 |
+
num_labels=1,
|
83 |
+
)
|
84 |
+
rm_tokenizer = AutoTokenizer.from_pretrained(model_name)
|
85 |
|
86 |
+
prompt = "Jane has 12 apples. She gives 4 apples to her friend Mark, then buys 1 more apple, and finally splits all her apples equally among herself and her 2 siblings. How many apples does each person get?"
|
87 |
+
response1 = "1. Jane starts with 12 apples and gives 4 to Mark. 12 - 4 = 8. Jane now has 8 apples.\n2. Jane buys 1 more apple. 8 + 1 = 9. Jane now has 9 apples.\n3. Jane splits the 9 apples equally among herself and her 2 siblings (3 people in total). 9 ÷ 3 = 3 apples each. Each person gets 3 apples."
|
88 |
+
response2 = "1. Jane starts with 12 apples and gives 4 to Mark. 12 - 4 = 8. Jane now has 8 apples.\n2. Jane buys 1 more apple. 8 + 1 = 9. Jane now has 9 apples.\n3. Jane splits the 9 apples equally among her 2 siblings (2 people in total). 9 ÷ 2 = 4.5 apples each. Each person gets 4 apples."
|
89 |
|
90 |
+
conv1 = [{"role": "user", "content": prompt}, {"role": "assistant", "content": response1}]
|
91 |
+
conv2 = [{"role": "user", "content": prompt}, {"role": "assistant", "content": response2}]
|
92 |
|
93 |
+
# Format and tokenize the conversations
|
94 |
+
conv1_formatted = rm_tokenizer.apply_chat_template(conv1, tokenize=False)
|
95 |
+
conv2_formatted = rm_tokenizer.apply_chat_template(conv2, tokenize=False)
|
96 |
+
conv1_tokenized = rm_tokenizer(conv1_formatted, return_tensors="pt").to(device)
|
97 |
+
conv2_tokenized = rm_tokenizer(conv2_formatted, return_tensors="pt").to(device)
|
98 |
|
99 |
+
# Get the reward scores
|
100 |
+
with torch.no_grad():
|
101 |
+
score1 = rm(**conv1_tokenized).logits[0][0].item()
|
102 |
+
score2 = rm(**conv2_tokenized).logits[0][0].item()
|
103 |
+
print(f"Score for response 1: {score1}")
|
104 |
+
print(f"Score for response 2: {score2}")
|
105 |
|
106 |
+
# Output:
|
107 |
+
# Score for response 1: 9.1875
|
108 |
+
# Score for response 2: -17.875
|
109 |
+
```
|
110 |
|
111 |
+
## Declaration and License Agreement
|
112 |
|
113 |
+
### Declaration
|
114 |
|
115 |
+
We hereby declare that the Skywork model should not be used for any activities that pose a threat to national or societal security or engage in unlawful actions. Additionally, we request users not to deploy the Skywork model for internet services without appropriate security reviews and records. We hope that all users will adhere to this principle to ensure that technological advancements occur in a regulated and lawful environment.
|
116 |
|
117 |
+
We have done our utmost to ensure the compliance of the data used during the model's training process. However, despite our extensive efforts, due to the complexity of the model and data, there may still be unpredictable risks and issues. Therefore, if any problems arise as a result of using the Skywork open-source model, including but not limited to data security issues, public opinion risks, or any risks and problems arising from the model being misled, abused, disseminated, or improperly utilized, we will not assume any responsibility.
|
118 |
|
119 |
+
### License Agreement
|
120 |
|
121 |
+
The community usage of Skywork model requires [Skywork Community License](https://github.com/SkyworkAI/Skywork-Reward/blob/main/misc/Skywork%20Community%20License.pdf). The Skywork model supports commercial use. If you plan to use the Skywork model or its derivatives for commercial purposes, you must abide by terms and conditions within [Skywork Community License](https://github.com/SkyworkAI/Skywork-Reward/blob/main/misc/Skywork%20Community%20License.pdf).
|
122 |
|
123 |
+
## Technical Report
|
124 |
|
125 |
+
Coming soon. Please stay tuned.
|
126 |
|
127 |
+
## Contact
|
128 |
|
129 |
+
If you have any questions, please feel free to reach us at <yuhao.liuu@kunlun-inc.com> or <liang.zeng@kunlun-inc.com>.
|
130 |
|
131 |
+
## Citation
|
132 |
|
133 |
+
If you find our work helpful, please feel free to cite us using the following BibTeX entry:
|
134 |
|
135 |
+
```bibtex
|
136 |
+
@misc{skyworkreward2024,
|
137 |
+
title={Skywork Reward Model Series},
|
138 |
+
author={Liu, Chris Yuhao and Zeng, Liang},
|
139 |
+
year={2024},
|
140 |
+
month={September},
|
141 |
+
howpublished={\url{https://huggingface.co/Skywork}},
|
142 |
+
url={https://huggingface.co/Skywork},
|
143 |
+
}
|
144 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|