jdchang commited on
Commit
4caa505
·
verified ·
1 Parent(s): f533c42

Upload model

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. README.md +199 -0
  2. config.json +86 -0
  3. generation_config.json +12 -0
  4. hf_utils.py +306 -0
  5. model-00001-of-00062.safetensors +3 -0
  6. model-00002-of-00062.safetensors +3 -0
  7. model-00003-of-00062.safetensors +3 -0
  8. model-00004-of-00062.safetensors +3 -0
  9. model-00005-of-00062.safetensors +3 -0
  10. model-00006-of-00062.safetensors +3 -0
  11. model-00007-of-00062.safetensors +3 -0
  12. model-00008-of-00062.safetensors +3 -0
  13. model-00009-of-00062.safetensors +3 -0
  14. model-00010-of-00062.safetensors +3 -0
  15. model-00011-of-00062.safetensors +3 -0
  16. model-00012-of-00062.safetensors +3 -0
  17. model-00013-of-00062.safetensors +3 -0
  18. model-00014-of-00062.safetensors +3 -0
  19. model-00015-of-00062.safetensors +3 -0
  20. model-00016-of-00062.safetensors +3 -0
  21. model-00017-of-00062.safetensors +3 -0
  22. model-00018-of-00062.safetensors +3 -0
  23. model-00019-of-00062.safetensors +3 -0
  24. model-00020-of-00062.safetensors +3 -0
  25. model-00021-of-00062.safetensors +3 -0
  26. model-00022-of-00062.safetensors +3 -0
  27. model-00023-of-00062.safetensors +3 -0
  28. model-00024-of-00062.safetensors +3 -0
  29. model-00025-of-00062.safetensors +3 -0
  30. model-00026-of-00062.safetensors +3 -0
  31. model-00027-of-00062.safetensors +3 -0
  32. model-00028-of-00062.safetensors +3 -0
  33. model-00029-of-00062.safetensors +3 -0
  34. model-00030-of-00062.safetensors +3 -0
  35. model-00031-of-00062.safetensors +3 -0
  36. model-00032-of-00062.safetensors +3 -0
  37. model-00033-of-00062.safetensors +3 -0
  38. model-00034-of-00062.safetensors +3 -0
  39. model-00035-of-00062.safetensors +3 -0
  40. model-00036-of-00062.safetensors +3 -0
  41. model-00037-of-00062.safetensors +3 -0
  42. model-00038-of-00062.safetensors +3 -0
  43. model-00039-of-00062.safetensors +3 -0
  44. model-00040-of-00062.safetensors +3 -0
  45. model-00041-of-00062.safetensors +3 -0
  46. model-00042-of-00062.safetensors +3 -0
  47. model-00043-of-00062.safetensors +3 -0
  48. model-00044-of-00062.safetensors +3 -0
  49. model-00045-of-00062.safetensors +3 -0
  50. model-00046-of-00062.safetensors +3 -0
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: transformers
3
+ tags: []
4
+ ---
5
+
6
+ # Model Card for Model ID
7
+
8
+ <!-- Provide a quick summary of what the model is/does. -->
9
+
10
+
11
+
12
+ ## Model Details
13
+
14
+ ### Model Description
15
+
16
+ <!-- Provide a longer summary of what this model is. -->
17
+
18
+ This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
+
20
+ - **Developed by:** [More Information Needed]
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
+ ### Model Sources [optional]
29
+
30
+ <!-- Provide the basic links for the model. -->
31
+
32
+ - **Repository:** [More Information Needed]
33
+ - **Paper [optional]:** [More Information Needed]
34
+ - **Demo [optional]:** [More Information Needed]
35
+
36
+ ## Uses
37
+
38
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
+
40
+ ### Direct Use
41
+
42
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
+
44
+ [More Information Needed]
45
+
46
+ ### Downstream Use [optional]
47
+
48
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
+
50
+ [More Information Needed]
51
+
52
+ ### Out-of-Scope Use
53
+
54
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
+
56
+ [More Information Needed]
57
+
58
+ ## Bias, Risks, and Limitations
59
+
60
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
+
62
+ [More Information Needed]
63
+
64
+ ### Recommendations
65
+
66
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
+
68
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
+
70
+ ## How to Get Started with the Model
71
+
72
+ Use the code below to get started with the model.
73
+
74
+ [More Information Needed]
75
+
76
+ ## Training Details
77
+
78
+ ### Training Data
79
+
80
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
+
82
+ [More Information Needed]
83
+
84
+ ### Training Procedure
85
+
86
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
+
88
+ #### Preprocessing [optional]
89
+
90
+ [More Information Needed]
91
+
92
+
93
+ #### Training Hyperparameters
94
+
95
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
+
97
+ #### Speeds, Sizes, Times [optional]
98
+
99
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
+
101
+ [More Information Needed]
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]
config.json ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "./models/m1",
3
+ "architectures": [
4
+ "AutoModelForCausalLMWithRM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "auto_map": {
9
+ "AutoConfig": "hf_utils.RewardModelConfig",
10
+ "AutoModel": "hf_utils.AutoModelForCausalLMWithRM"
11
+ },
12
+ "base_config": {
13
+ "_name_or_path": "meta-llama/Meta-Llama-3.1-70B-Instruct",
14
+ "architectures": [
15
+ "LlamaForCausalLM"
16
+ ],
17
+ "bos_token_id": 128000,
18
+ "eos_token_id": [
19
+ 128001,
20
+ 128008,
21
+ 128009
22
+ ],
23
+ "hidden_size": 8192,
24
+ "intermediate_size": 28672,
25
+ "max_position_embeddings": 131072,
26
+ "model_type": "llama",
27
+ "num_attention_heads": 64,
28
+ "num_hidden_layers": 80,
29
+ "num_key_value_heads": 8,
30
+ "rms_norm_eps": 1e-05,
31
+ "rope_scaling": {
32
+ "factor": 8.0,
33
+ "high_freq_factor": 4.0,
34
+ "low_freq_factor": 1.0,
35
+ "original_max_position_embeddings": 8192,
36
+ "rope_type": "llama3"
37
+ },
38
+ "rope_theta": 500000.0,
39
+ "torch_dtype": "bfloat16",
40
+ "use_cache": false,
41
+ "vocab_size": 128257
42
+ },
43
+ "base_model": "meta-llama/Meta-Llama-3.1-70B-Instruct",
44
+ "bias": 0.0,
45
+ "bos_token_id": 128000,
46
+ "eos_token_id": [
47
+ 128001,
48
+ 128008,
49
+ 128009
50
+ ],
51
+ "hidden_act": "silu",
52
+ "hidden_size": 8192,
53
+ "initializer_range": 0.02,
54
+ "intermediate_size": 28672,
55
+ "max_position_embeddings": 131072,
56
+ "mlp_bias": false,
57
+ "model_type": "pairwise_rm",
58
+ "n_labels": 1,
59
+ "num_attention_heads": 64,
60
+ "num_hidden_layers": 80,
61
+ "num_key_value_heads": 8,
62
+ "p_dropout": 0.0,
63
+ "pretrain_cfg": {
64
+ "attn_implementation": "flash_attention_2",
65
+ "load_in_8bit": false,
66
+ "token": true,
67
+ "trust_remote_code": true
68
+ },
69
+ "pretrained": false,
70
+ "pretraining_tp": 1,
71
+ "return_logits": false,
72
+ "rms_norm_eps": 1e-05,
73
+ "rope_scaling": {
74
+ "factor": 8.0,
75
+ "high_freq_factor": 4.0,
76
+ "low_freq_factor": 1.0,
77
+ "original_max_position_embeddings": 8192,
78
+ "rope_type": "llama3"
79
+ },
80
+ "rope_theta": 500000.0,
81
+ "tie_word_embeddings": false,
82
+ "torch_dtype": "float32",
83
+ "transformers_version": "4.46.1",
84
+ "use_cache": false,
85
+ "vocab_size": 128257
86
+ }
generation_config.json ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 128000,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 128001,
6
+ 128008,
7
+ 128009
8
+ ],
9
+ "temperature": 0.6,
10
+ "top_p": 0.9,
11
+ "transformers_version": "4.46.1"
12
+ }
hf_utils.py ADDED
@@ -0,0 +1,306 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2024 MosaicML ComposeRL authors
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ import os
5
+ from copy import deepcopy
6
+ from dataclasses import dataclass
7
+ from typing import (
8
+ Any,
9
+ Optional,
10
+ Union,
11
+ )
12
+
13
+ import numpy as np
14
+ import torch
15
+ import torch.nn as nn
16
+ from transformers import (
17
+ AutoConfig,
18
+ AutoModelForCausalLM,
19
+ PretrainedConfig,
20
+ PreTrainedModel,
21
+ )
22
+ from transformers.modeling_outputs import ModelOutput
23
+
24
+
25
+ @dataclass
26
+ class SequenceClassifierOutput(ModelOutput):
27
+ """Sequence Classification Output.
28
+
29
+ Args:
30
+ loss (`torch.FloatTensor` of shape `(1,)`, *optional*, returned when `labels` is provided):
31
+ Classification (or regression if config.num_labels==1) loss.
32
+ scores (`torch.FloatTensor` of shape `(batch_size, config.num_labels)`):
33
+ Classification (or regression if config.num_labels==1) scores (before SoftMax).
34
+ logits (`torch.FloatTensor` of shape `(batch_size, sequence_length, config.vocab_size)`):
35
+ Prediction scores of the language modeling head (scores for each vocabulary token before SoftMax).
36
+ past_key_values (`tuple(tuple(torch.FloatTensor))`, *optional*, returned when `use_cache=True` is passed or when `config.use_cache=True`):
37
+ tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of shape
38
+ `(batch_size, num_heads, sequence_length, embed_size_per_head)`)
39
+
40
+ Contains pre-computed hidden-states (key and values in the self-attention blocks) that can be used (see
41
+ `past_key_values` input) to speed up sequential decoding.
42
+ hidden_states (`tuple(torch.FloatTensor)`, *optional*, returned when `output_hidden_states=True` is passed or when `config.output_hidden_states=True`):
43
+ tuple of `torch.FloatTensor` (one for the output of the embeddings, if the model has an embedding layer, +
44
+ one for the output of each layer) of shape `(batch_size, sequence_length, hidden_size)`.
45
+
46
+ Hidden-states of the model at the output of each layer plus the optional initial embedding outputs.
47
+ attentions (`tuple(torch.FloatTensor)`, *optional*, returned when `output_attentions=True` is passed or when `config.output_attentions=True`):
48
+ tuple of `torch.FloatTensor` (one for each layer) of shape `(batch_size, num_heads, sequence_length,
49
+ sequence_length)`.
50
+
51
+ Attentions weights after the attention softmax, used to compute the weighted average in the self-attention
52
+ heads.
53
+ """
54
+
55
+ loss: Optional[torch.FloatTensor] = None
56
+ scores: Optional[torch.FloatTensor] = None
57
+ logits: Optional[torch.FloatTensor] = None
58
+ past_key_values: Optional[tuple[tuple[torch.FloatTensor]]] = None
59
+ hidden_states: Optional[tuple[torch.FloatTensor, ...]] = None
60
+ attentions: Optional[tuple[torch.FloatTensor, ...]] = None
61
+
62
+
63
+ class ValueHead(nn.Module):
64
+ """Value head for the transformer which outputs n_labels values."""
65
+
66
+ def __init__(self, n_labels: int, hidden_size: int, p_dropout: float = 0.0):
67
+ super().__init__()
68
+ self.dense = nn.Linear(hidden_size, hidden_size)
69
+ self.dropout = nn.Dropout(p_dropout)
70
+ self.score = nn.Linear(hidden_size, n_labels)
71
+ torch.nn.init.normal_(
72
+ self.score.weight,
73
+ std=1 / np.sqrt(hidden_size + 1),
74
+ )
75
+ torch.nn.init.constant_(self.score.bias, val=0.0)
76
+
77
+ def forward(
78
+ self,
79
+ hidden_states: torch.Tensor,
80
+ **kwargs: Any,
81
+ ) -> torch.Tensor:
82
+ hidden_states = self.dropout(hidden_states)
83
+ hidden_states = self.dense(hidden_states)
84
+ hidden_states = torch.tanh(hidden_states)
85
+ hidden_states = self.dropout(hidden_states)
86
+ output = self.score(hidden_states)
87
+ return output
88
+
89
+
90
+ class RewardModelConfig(PretrainedConfig):
91
+ model_type = 'pairwise_rm'
92
+
93
+ def __init__(
94
+ self,
95
+ base_model: Optional[Union[str, os.PathLike]
96
+ ] = 'meta-llama/Meta-Llama-3-70B-Instruct',
97
+ base_config: Optional[PretrainedConfig] = None,
98
+ p_dropout: float = 0.0,
99
+ n_labels: int = 1,
100
+ bias: float = 0.0,
101
+ return_logits: bool = False,
102
+ pretrain_cfg: Optional[dict[str, Any]] = None,
103
+ pretrained: bool = False,
104
+ **kwargs: Any,
105
+ ):
106
+ super().__init__(**kwargs)
107
+ self.base_model = base_model
108
+ self.base_config = base_config if base_config is not None else AutoConfig.from_pretrained(
109
+ base_model,
110
+ )
111
+ temp_config = deepcopy(self.base_config)
112
+ if not isinstance(temp_config, dict):
113
+ temp_config = temp_config.__dict__
114
+ for key, value in temp_config.items():
115
+ if key not in ['_name_or_path', 'architectures']:
116
+ setattr(self, key, value)
117
+ self.p_dropout = p_dropout
118
+ self.n_labels = n_labels
119
+ self.bias = bias
120
+ self.return_logits = return_logits
121
+ self.pretrain_cfg = pretrain_cfg if pretrain_cfg is not None else {}
122
+ self.pretrained = pretrained
123
+
124
+
125
+ class AutoModelForCausalLMWithRM(PreTrainedModel):
126
+ config_class = RewardModelConfig
127
+ _supports_flash_attn_2 = True
128
+
129
+ def __init__(self, config: PretrainedConfig, *args: Any, **kwargs: Any):
130
+ super().__init__(config)
131
+ self.config = config
132
+ pretrain_cfg = config.pretrain_cfg
133
+ pretrained = config.pretrained
134
+ if pretrained:
135
+ self.lm_backbone = AutoModelForCausalLM.from_pretrained(
136
+ config.base_model,
137
+ config=config.base_config,
138
+ **pretrain_cfg,
139
+ )
140
+ else:
141
+ # When downloading from hub, base config gets converted to dict
142
+ # Redownload to make type PretrainedConfig
143
+ if isinstance(config.base_config, dict):
144
+ config.base_config = AutoConfig.from_pretrained(
145
+ config.base_model,
146
+ **config.base_config,
147
+ )
148
+ self.lm_backbone = AutoModelForCausalLM.from_config(
149
+ config.base_config,
150
+ **kwargs,
151
+ )
152
+ self.value_head = ValueHead(
153
+ n_labels=self.config.n_labels,
154
+ hidden_size=self.config.hidden_size,
155
+ p_dropout=self.config.p_dropout,
156
+ )
157
+
158
+ def generate(self, *args: Any, **kwargs: Any):
159
+ return self.lm_backbone.generate(**kwargs)
160
+
161
+ def resize_token_embeddings(
162
+ self,
163
+ new_num_tokens: Optional[int] = None,
164
+ pad_to_multiple_of: Optional[int] = None,
165
+ ) -> nn.Embedding:
166
+ # Note need to update vocab size in base config as well so lm_head modification happens
167
+ self.config.base_config.vocab_size = new_num_tokens
168
+ model_embeds = super().resize_token_embeddings(
169
+ new_num_tokens=new_num_tokens,
170
+ pad_to_multiple_of=pad_to_multiple_of,
171
+ )
172
+ return model_embeds
173
+
174
+ def set_input_embeddings(self, new_embeddings: Any):
175
+ return self.lm_backbone.set_input_embeddings(new_embeddings)
176
+
177
+ def get_input_embeddings(self):
178
+ return self.lm_backbone.get_input_embeddings()
179
+
180
+ def set_output_embeddings(self, new_embeddings: Any):
181
+ return self.lm_backbone.set_output_embeddings(new_embeddings)
182
+
183
+ def get_output_embeddings(self):
184
+ return self.lm_backbone.get_output_embeddings()
185
+
186
+ def forward(
187
+ self,
188
+ input_ids: Optional[torch.LongTensor] = None,
189
+ attention_mask: Optional[torch.Tensor] = None,
190
+ position_ids: Optional[torch.LongTensor] = None,
191
+ past_key_values: Optional[Any] = None,
192
+ inputs_embeds: Optional[torch.FloatTensor] = None,
193
+ labels: Optional[torch.LongTensor] = None,
194
+ use_cache: Optional[bool] = None,
195
+ output_attentions: Optional[bool] = None,
196
+ output_hidden_states: Optional[bool] = None,
197
+ return_dict: Optional[bool] = None,
198
+ cache_position: Optional[torch.LongTensor] = None,
199
+ **kwargs: Any,
200
+ ):
201
+ output = self.lm_backbone(
202
+ input_ids=input_ids,
203
+ attention_mask=attention_mask,
204
+ position_ids=position_ids,
205
+ past_key_values=past_key_values,
206
+ inputs_embeds=inputs_embeds,
207
+ labels=labels,
208
+ use_cache=use_cache,
209
+ output_attentions=output_attentions,
210
+ output_hidden_states=True,
211
+ return_dict=True,
212
+ cache_position=cache_position,
213
+ )
214
+ scores = self.value_head(
215
+ output.hidden_states[-1],
216
+ ).squeeze(-1) - self.config.bias
217
+
218
+ logits = None
219
+ if self.config.return_logits:
220
+ logits = output.logits
221
+
222
+ return SequenceClassifierOutput(
223
+ loss=output.loss,
224
+ scores=scores,
225
+ logits=logits,
226
+ past_key_values=output.past_key_values,
227
+ hidden_states=output.hidden_states,
228
+ attentions=output.attentions,
229
+ )
230
+
231
+ @classmethod
232
+ def from_config(
233
+ cls,
234
+ config: PretrainedConfig,
235
+ **kwargs: Any,
236
+ ) -> PreTrainedModel:
237
+ config.pretrained = False
238
+ model = cls(config, **kwargs)
239
+ return model
240
+
241
+ @classmethod
242
+ def from_pretrained(
243
+ cls,
244
+ pretrained_model_name_or_path: Optional[Union[str, os.PathLike]],
245
+ *model_args: Any,
246
+ config: Optional[Union[PretrainedConfig, str, os.PathLike]] = None,
247
+ cache_dir: Optional[Union[str, os.PathLike]] = None,
248
+ ignore_mismatched_sizes: bool = False,
249
+ force_download: bool = False,
250
+ local_files_only: bool = False,
251
+ token: Optional[Union[str, bool]] = True,
252
+ revision: str = 'main',
253
+ use_safetensors: Optional[bool] = None,
254
+ **kwargs: Any,
255
+ ) -> PreTrainedModel:
256
+ trust_remote_code = kwargs.pop('trust_remote_code', None)
257
+ attn_implementation = kwargs.pop(
258
+ 'attn_implementation',
259
+ 'eager',
260
+ )
261
+ return_lm_logits = kwargs.pop('return_lm_logits', False)
262
+ load_in_8bit = kwargs.pop('load_in_8bit', False)
263
+
264
+ pretrained_model_config = AutoConfig.from_pretrained(
265
+ pretrained_model_name_or_path,
266
+ trust_remote_code=trust_remote_code,
267
+ token=token,
268
+ attn_implementation=attn_implementation,
269
+ use_cache=False,
270
+ )
271
+
272
+ if isinstance(pretrained_model_config, cls.config_class):
273
+ return super().from_pretrained(
274
+ pretrained_model_name_or_path,
275
+ *model_args,
276
+ config,
277
+ cache_dir,
278
+ ignore_mismatched_sizes,
279
+ force_download,
280
+ local_files_only,
281
+ token,
282
+ revision,
283
+ use_safetensors,
284
+ **kwargs,
285
+ )
286
+
287
+ pretrain_cfg = {
288
+ 'trust_remote_code': trust_remote_code,
289
+ 'token': token,
290
+ 'load_in_8bit': load_in_8bit,
291
+ 'attn_implementation': attn_implementation,
292
+ }
293
+
294
+ reward_model_config = RewardModelConfig(
295
+ base_model=pretrained_model_name_or_path,
296
+ base_config=pretrained_model_config,
297
+ hidden_size=pretrained_model_config.hidden_size,
298
+ return_logits=return_lm_logits,
299
+ vocab_size=pretrained_model_config.vocab_size,
300
+ pretrained=True,
301
+ pretrain_cfg=pretrain_cfg,
302
+ )
303
+
304
+ model = cls(reward_model_config)
305
+
306
+ return model
model-00001-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:294f2c544bab1e1fcd24d396bf9b0b430548d6c3b13ae93d2df1ced7ac94f2e4
3
+ size 4806705816
model-00002-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b45267979b639d7e05cd34124d744c2f074f9223384812a2bc3bb77f7f052fa5
3
+ size 4362142984
model-00003-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e39d0e5e650b91d46492aa722f483f9e63889304f58d8a53a00aa124d5447e1c
3
+ size 4362142984
model-00004-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e479a450802856cc3bd6d76c3e649d1013dbc529efef69dd66176c62f90d8424
3
+ size 4966189056
model-00005-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9c05c6a13da37580bb30e84b556bf21beaa093fd1f8c7d0518e4ff35f09c5fd
3
+ size 4362142984
model-00006-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ca1d7caabb8b70ad7abce8b7d31b1923b156178c622f42be871fe55e1d306f17
3
+ size 4362142984
model-00007-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:27893b8533d532911050b7e5c04cb731b43b98e0c1e8d057606dc740a6fdc43c
3
+ size 4966189056
model-00008-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fce21752cacbb59f10867a1f2cf69c53742066611ee687db1da34ad79e89a858
3
+ size 4362142984
model-00009-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0a3acf3d4ac90a872fff3d2dbbda31c5d92ea1271e861e72e6d3d4b2d584ec1c
3
+ size 4362143000
model-00010-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:240a7a49775b54ee334086758531882100a5cfdb87e71d84853e0cfecc54821a
3
+ size 4966189072
model-00011-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f88dbb1975a09da766d69b3f1bc83b273bf5772a7e453d8e174c18e403b9ad79
3
+ size 4362142992
model-00012-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:768055444d918661965c63dae18dfa4c09281980514f61b2d728502d4c5a0a54
3
+ size 4362142992
model-00013-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2439d2dcb7305fc7838bf4014c703a50b9db1215af2deed5f1f7896bcf59e485
3
+ size 4966189072
model-00014-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a874f6c22e630fb1eedc2f08b73d5c34919bf4c1ef291fdbafd8d0e45190a089
3
+ size 4362142992
model-00015-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e41f89d87ac154ad1223de04f62a84ba35ac9222316e5ead6524e349c7531e1
3
+ size 4362142992
model-00016-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5cad4f77a062fd926ce2af3241f34fbbddf5bbbfc4a491a1ae8a3e8fe32b7b11
3
+ size 4966189072
model-00017-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b9021bb86b14cbc5daf81cfc51cdcd19ba81c09fcedc30bed2af6dc8199ef3c6
3
+ size 4362142992
model-00018-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b87b90390023a53ddfdcb97cbf0004c321d20fd7125d8a615120121ce234a0ea
3
+ size 4362142992
model-00019-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e27ba2f3df9a016f945c9665e24e32c86a96554f6e267b0e739f43e61dd7f8c3
3
+ size 4966189072
model-00020-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c6dc4585d95c6e1c12bfc1384d643c54bbad018311d7076261b844008d8c8853
3
+ size 4362142992
model-00021-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4fa784ce853d334262bca9b3f37836baee8d68bb2783065e3d1c0164601a22a
3
+ size 4362142992
model-00022-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8de3efe965be4687e15b6afb1a6c9da8471fd7bf171d49f9029ff5f1d7e661f4
3
+ size 4966189072
model-00023-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:98eb9502d89332ff14eb8e65f5776764ba98d214c62e01bc9d5151bbcd9144d0
3
+ size 4362142992
model-00024-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e39b517e68ca597f0ffb837a8cb0b19a1aa7aae340bcf107810b48a2e3192dba
3
+ size 4362142992
model-00025-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aefd4d61e1ba813122e84a7f69a8199a3c015f5ac3bf24394fa5695b67536f20
3
+ size 4966189072
model-00026-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cd3498fb48422556940f9bbc365776c5163551a4cd1a45b8f869d5ccfb58ade5
3
+ size 4362142992
model-00027-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b879aedf4a02eeacc9c3ec23b0af54acb89caae79de3014aca21832e8ebaea3
3
+ size 4362142992
model-00028-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f1cf5d18c822f7b405b83052713cdd02c4353d422f779132b5274eef8c4bc47c
3
+ size 4966189072
model-00029-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:22ec6869126f3f9ec5b013d9a715afdbcfd5b889d0b5bd41065e26670d00a432
3
+ size 4362142992
model-00030-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:814cac49bbbbaf5d4455e18410c3377a41d8e03f9049f58e891e01d7e8315a3a
3
+ size 4362142992
model-00031-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28dcb4ec8538da869260a4d09e6a4fb5a6e10f02680639afdc8fcbed3bc273e0
3
+ size 4966189072
model-00032-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b409bd1e6a074ddc81dbdb2fa842e9b951fb58c95cafdf862b3d65257ac96e0a
3
+ size 4362142992
model-00033-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:379bd098d8b979aafb003daf14058065e19e9812c2f2e77152cf1c601eea7392
3
+ size 4362142992
model-00034-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:28f299b5588d46d160d7435963dc382666a1e9e3dbca5e3c8c5429c9ff1be614
3
+ size 4966189072
model-00035-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4c636c1bf87959f616e34a3e4e582021fe62f91bc43803dc350830c02d18ecb4
3
+ size 4362142992
model-00036-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b39e569d4817387ffb4fe39bf3ba6a246d7cf11d5844e7b4f229b7b9dc21762
3
+ size 4362142992
model-00037-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:81ad4a13b18b22aefcc82444271ebd69341e46ac099b8e03f5875eaede2f7dc2
3
+ size 4966189072
model-00038-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60984e9c2e9f6f1c40d8809b945183aacb958532d1a071f09d1c86a82969d1fa
3
+ size 4362142992
model-00039-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:23a76ab605c7dfded0c9feb01d3f1bccb9de0e75105d4d0eb66bab36ab1b54af
3
+ size 4362142992
model-00040-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2fce911e6e7d95c677e4c397a417db801df35d752e3f4794709e29ac2567fe5e
3
+ size 4966189072
model-00041-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:55796d88008abb46d11cab60849080d4ea44b3733cef2be0c0bb3006ecf80558
3
+ size 4362142992
model-00042-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c246fe0c150de406ada31bece438a19070ce20ba9b3b8f55ba3df7ff1bb68305
3
+ size 4362142992
model-00043-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18b00c7cb79bfa2a85c83bcf0743c5c2ec8eed8c9b13c9cab40d369eed3255d3
3
+ size 4966189072
model-00044-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:aa76b6f8caf68b36a98ba155bd961b53defc439aba68eb2e8ecc10df1eaf2b64
3
+ size 4362142992
model-00045-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2e3ad35aeb5e6e23820516dc82827922f013f1941dc3dce7319a21ab6aa8c05b
3
+ size 4362142992
model-00046-of-00062.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:550b9644a23e4293a325dc09828966d494a6652960bb133cc06b32bb90e31b83
3
+ size 4966189072