XuehaiPan commited on
Commit
638adde
1 Parent(s): 76eee93

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +99 -0
README.md ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ datasets:
3
+ - PKU-Alignment/PKU-SafeRLHF
4
+ language:
5
+ - en
6
+ tags:
7
+ - reinforcement-learning-from-human-feedback
8
+ - reinforcement-learning
9
+ - beaver
10
+ - safety
11
+ - llama
12
+ - ai-safety
13
+ - deepspeed
14
+ - rlhf
15
+ - alpaca
16
+ library_name: safe-rlhf
17
+ ---
18
+
19
+ # 🦫 Beaver's Reward Model
20
+
21
+ ## Model Details
22
+
23
+ The Beaver reward model is a preference model trained using the [PKU-SafeRLHF](https://huggingface.co/datasets/PKU-Alignment/PKU-SafeRLHF) dataset.
24
+ It can play a role in the safe RLHF algorithm, helping the Beaver model become more helpful.
25
+
26
+ - **Developed by:** the [PKU-Alignment](https://github.com/PKU-Alignment) Team.
27
+ - **Model Type:** An auto-regressive language model based on the transformer architecture.
28
+ - **License:** Non-commercial license.
29
+ - **Fine-tuned from model:** [LLaMA](https://arxiv.org/abs/2302.13971), [Alpaca](https://github.com/tatsu-lab/stanford_alpaca).
30
+
31
+ ## Model Sources
32
+
33
+ - **Repository:** <https://github.com/PKU-Alignment/safe-rlhf>
34
+ - **Beaver:** <https://huggingface.co/PKU-Alignment/beaver-7b-v3.0>
35
+ - **Dataset:** <https://huggingface.co/datasets/PKU-Alignment/PKU-SafeRLHF>
36
+ - **Reward Model:** <https://huggingface.co/PKU-Alignment/beaver-7b-v3.0-reward>
37
+ - **Cost Model:** <https://huggingface.co/PKU-Alignment/beaver-7b-v3.0-cost>
38
+ - **Dataset Paper:** <https://arxiv.org/abs/2307.04657>
39
+ - **Paper:** <https://arxiv.org/abs/2310.12773>
40
+
41
+ ## How to Use the Reward Model
42
+
43
+ ```python
44
+ import torch
45
+ from transformers import AutoTokenizer
46
+ from safe_rlhf.models import AutoModelForScore
47
+
48
+ model = AutoModelForScore.from_pretrained('PKU-Alignment/beaver-7b-v3.0-reward', torch_dtype=torch.bfloat16, device_map='auto')
49
+ tokenizer = AutoTokenizer.from_pretrained('PKU-Alignment/beaver-7b-v3.0-reward')
50
+
51
+ input = 'BEGINNING OF CONVERSATION: USER: hello ASSISTANT:Hello! How can I help you today?'
52
+
53
+ input_ids = tokenizer(input, return_tensors='pt')
54
+ output = model(**input_ids)
55
+ print(output)
56
+
57
+ # ScoreModelOutput(
58
+ # scores=tensor([[[-14.0000],
59
+ # [ -2.6094],
60
+ # [ -2.6562],
61
+ # [ -2.0312],
62
+ # [ -1.2188],
63
+ # [ -1.6250],
64
+ # [ -2.4688],
65
+ # [ -2.7500],
66
+ # [ -3.0000],
67
+ # [ -6.0000],
68
+ # [ -5.0625],
69
+ # [ -7.0938],
70
+ # [ -6.9688],
71
+ # [ -4.3125],
72
+ # [ -4.2188],
73
+ # [ -3.7969],
74
+ # [ -3.6875],
75
+ # [ -3.3750],
76
+ # [ -2.8906],
77
+ # [ -3.9219],
78
+ # [ -2.1406],
79
+ # [ -1.7578],
80
+ # [ 0.4629],
81
+ # [ 2.1719],
82
+ # [ 4.4062],
83
+ # [ 7.1562],
84
+ # [ 7.7188],
85
+ # [ 10.7500]]], grad_fn=<ToCopyBackward0>),
86
+ # end_scores=tensor([[10.7500]], grad_fn=<ToCopyBackward0>),
87
+ # last_hidden_state=tensor([[[ 0.4805, -0.4863, -0.9258, ..., -0.0718, 0.8555, 0.6641],
88
+ # [ 0.2021, 2.0156, 3.5156, ..., -0.9844, -1.1484, 1.3203],
89
+ # [ 1.0938, 1.4609, 1.7891, ..., -3.2031, -0.8555, -1.2969],
90
+ # ...,
91
+ # [ 1.5859, 0.1348, 0.0322, ..., -1.3672, -1.5234, 1.5156],
92
+ # [ 0.9102, 0.6367, -0.8555, ..., -1.2109, -0.6953, 1.5312],
93
+ # [ 1.7188, 0.4434, -0.5586, ..., -1.1484, -0.7461, 2.2031]]],
94
+ # dtype=torch.bfloat16, grad_fn=<ToCopyBackward0>),
95
+ # end_last_hidden_state=tensor([[ 1.7188, 0.4434, -0.5586, ..., -1.1484, -0.7461, 2.2031]],
96
+ # dtype=torch.bfloat16, grad_fn=<ToCopyBackward0>),
97
+ # end_index=tensor([27])
98
+ # )
99
+ ```