XuehaiPan commited on
Commit
83c5825
1 Parent(s): 1eeef13

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 Cost Model
20
+
21
+ ## Model Details
22
+
23
+ The Beaver cost 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 safe and harmless.
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-unified-reward>
37
+ - **Cost Model:** <https://huggingface.co/PKU-Alignment/beaver-7b-unified-cost>
38
+ - **Dataset Paper:** <https://arxiv.org/abs/2307.04657>
39
+ - **Paper:** <https://arxiv.org/abs/2310.12773>
40
+
41
+ ## How to Use the Cost 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-unified-cost', torch_dtype=torch.bfloat16, device_map='auto')
49
+ tokenizer = AutoTokenizer.from_pretrained('PKU-Alignment/beaver-7b-unified-cost')
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([[[-2.7656],
59
+ # [ 0.8320],
60
+ # [-2.7656],
61
+ # [-2.7500],
62
+ # [-0.9023],
63
+ # [-0.7891],
64
+ # [-0.3125],
65
+ # [-0.8008],
66
+ # [-0.5117],
67
+ # [-1.1562],
68
+ # [-2.3906],
69
+ # [-1.2266],
70
+ # [-1.1797],
71
+ # [-3.3281],
72
+ # [-4.4062],
73
+ # [-1.0234],
74
+ # [-1.1484],
75
+ # [-2.1406],
76
+ # [-2.9531],
77
+ # [-4.6250],
78
+ # [-4.5312],
79
+ # [-3.3594],
80
+ # [-4.1250],
81
+ # [-3.0156],
82
+ # [-3.5156],
83
+ # [-5.0000],
84
+ # [-5.7812],
85
+ # [-7.6562]]], grad_fn=<ToCopyBackward0>),
86
+ # end_scores=tensor([[-7.6562]], grad_fn=<ToCopyBackward0>),
87
+ # last_hidden_state=tensor([[[ 0.7148, 0.3594, -1.0234, ..., 0.5039, -0.0737, 1.4375],
88
+ # [ 1.0781, -1.2812, 1.5078, ..., 0.9102, 1.3594, 1.4141],
89
+ # [ 0.8047, 0.4551, -0.3262, ..., 0.3887, 0.6484, -0.4629],
90
+ # ...,
91
+ # [-0.1836, -0.6094, -0.8086, ..., -0.5078, 0.8086, 1.1719],
92
+ # [ 0.9727, -1.5156, -1.2656, ..., -0.9766, 0.3535, 1.0156],
93
+ # [ 4.2812, -1.6797, -0.4238, ..., 0.6758, -1.1875, -1.1562]]],
94
+ # dtype=torch.bfloat16, grad_fn=<ToCopyBackward0>),
95
+ # end_last_hidden_state=tensor([[ 4.2812, -1.6797, -0.4238, ..., 0.6758, -1.1875, -1.1562]],
96
+ # dtype=torch.bfloat16, grad_fn=<ToCopyBackward0>),
97
+ # end_index=tensor([27])
98
+ # )
99
+ ```