Update README.md
Browse files
README.md
CHANGED
@@ -1,19 +1,22 @@
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
-
|
|
|
|
|
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 |
|
@@ -27,7 +30,7 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
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]
|
@@ -35,43 +38,113 @@ This is the model card of a 🤗 transformers model that has been pushed on the
|
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
## Training Details
|
77 |
|
@@ -79,50 +152,83 @@ Use the code below to get started with the model.
|
|
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 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
89 |
|
90 |
-
[More Information Needed]
|
91 |
|
92 |
|
93 |
#### Training Hyperparameters
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
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 |
-
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|
@@ -136,13 +242,13 @@ Use the code below to get started with the model.
|
|
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]
|
@@ -158,13 +264,13 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
158 |
|
159 |
### Compute Infrastructure
|
160 |
|
161 |
-
[More Information Needed]
|
162 |
|
163 |
#### Hardware
|
164 |
|
165 |
-
|
166 |
|
167 |
-
|
168 |
|
169 |
[More Information Needed]
|
170 |
|
@@ -172,7 +278,7 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
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 |
-
|
176 |
|
177 |
[More Information Needed]
|
178 |
|
@@ -184,7 +290,7 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
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 |
|
@@ -196,4 +302,4 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
196 |
|
197 |
## Model Card Contact
|
198 |
|
199 |
-
[More Information Needed]
|
|
|
1 |
---
|
2 |
library_name: transformers
|
3 |
+
license: cc-by-4.0
|
4 |
+
datasets:
|
5 |
+
- hendrycks/ethics
|
6 |
---
|
7 |
|
8 |
# Model Card for Model ID
|
9 |
|
10 |
<!-- Provide a quick summary of what the model is/does. -->
|
11 |
|
12 |
+
Fine-tuned version of Phi-3-mini-4k-instruct on a subset of the hendrycks/ethics dataset
|
13 |
|
14 |
+
<!--
|
15 |
## Model Details
|
16 |
|
17 |
### Model Description
|
18 |
|
19 |
+
<!-- Provide a longer summary of what this model is.
|
20 |
|
21 |
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
|
22 |
|
|
|
30 |
|
31 |
### Model Sources [optional]
|
32 |
|
33 |
+
<!-- Provide the basic links for the model.
|
34 |
|
35 |
- **Repository:** [More Information Needed]
|
36 |
- **Paper [optional]:** [More Information Needed]
|
|
|
38 |
|
39 |
## Uses
|
40 |
|
41 |
+
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model.
|
42 |
|
43 |
### Direct Use
|
44 |
|
45 |
+
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app.
|
46 |
|
47 |
[More Information Needed]
|
48 |
|
49 |
### Downstream Use [optional]
|
50 |
|
51 |
+
<!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app
|
52 |
|
53 |
[More Information Needed]
|
54 |
|
55 |
### Out-of-Scope Use
|
56 |
|
57 |
+
<!-- This section addresses misuse, malicious use, and uses that the model will not work well for.
|
58 |
|
59 |
[More Information Needed]
|
60 |
|
61 |
## Bias, Risks, and Limitations
|
62 |
|
63 |
+
<!-- This section is meant to convey both technical and sociotechnical limitations.
|
64 |
|
65 |
[More Information Needed]
|
66 |
|
67 |
### Recommendations
|
68 |
|
69 |
+
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations.
|
70 |
|
71 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations. -->
|
72 |
|
73 |
## How to Get Started with the Model
|
74 |
|
75 |
Use the code below to get started with the model.
|
76 |
|
77 |
+
```markdown
|
78 |
+
Install the latest version of the following python libraries:
|
79 |
+
-torch
|
80 |
+
-accelerate
|
81 |
+
-peft
|
82 |
+
-bitsandbytes
|
83 |
+
```
|
84 |
+
|
85 |
+
Run the model
|
86 |
+
|
87 |
+
```python
|
88 |
+
from transformers import AutoModelForCausalLM
|
89 |
+
from peft import PeftModel
|
90 |
+
|
91 |
+
base_model = AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
|
92 |
+
peft_model_id = "fc91/phi3-mini-instruct-full_ethics-lora_v2.5"
|
93 |
+
model = PeftModel.from_pretrained(base_model, peft_model_id)
|
94 |
+
```
|
95 |
+
|
96 |
+
Run the model with a quantization configuration
|
97 |
+
|
98 |
+
```python
|
99 |
+
import torch, accelerate, peft
|
100 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig, pipeline
|
101 |
+
from peft import PeftModel
|
102 |
+
|
103 |
+
# Set up quantization configuration
|
104 |
+
quantization_config = BitsAndBytesConfig(
|
105 |
+
load_in_4bit=True,
|
106 |
+
bnb_4bit_quant_type="nf4",
|
107 |
+
bnb_4bit_compute_dtype=getattr(torch, "float16")
|
108 |
+
)
|
109 |
+
|
110 |
+
# Load the base model with quantization
|
111 |
+
base_model = AutoModelForCausalLM.from_pretrained(
|
112 |
+
"microsoft/Phi-3-mini-4k-instruct",
|
113 |
+
quantization_config=quantization_config,
|
114 |
+
device_map="auto",
|
115 |
+
attn_implementation='eager',
|
116 |
+
torch_dtype="auto",
|
117 |
+
trust_remote_code=True,
|
118 |
+
)
|
119 |
+
|
120 |
+
peft_model_id = "fc91/phi3-mini-instruct-full_ethics-lora_v2.5"
|
121 |
+
model = PeftModel.from_pretrained(base_model, peft_model_id)
|
122 |
+
|
123 |
+
tokenizer = AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
|
124 |
+
|
125 |
+
messages = [
|
126 |
+
{"role": "system", "content": "You are a helpful AI assistant sensitive to ethical concerns. Carefully read the used prompt. Does it represent an 'ethical' or a 'unethical' reply? Respond ONLY with 'ethical' or 'unethical"},
|
127 |
+
{"role": "user", "content": [provide user content]},
|
128 |
+
{"role": "assistant", "content": "The user reply is..."},
|
129 |
+
]
|
130 |
+
|
131 |
+
pipe = pipeline(
|
132 |
+
"text-generation",
|
133 |
+
model=model,
|
134 |
+
tokenizer=tokenizer,
|
135 |
+
)
|
136 |
+
|
137 |
+
generation_args = {
|
138 |
+
"max_new_tokens": 1000,
|
139 |
+
"return_full_text": False,
|
140 |
+
"temperature": 0.5,
|
141 |
+
"do_sample": False,
|
142 |
+
}
|
143 |
+
|
144 |
+
# Run inference
|
145 |
+
output = pipe(messages, **generation_args)
|
146 |
+
print(output[0]['generated_text'])
|
147 |
+
```
|
148 |
|
149 |
## Training Details
|
150 |
|
|
|
152 |
|
153 |
<!-- 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. -->
|
154 |
|
155 |
+
["hendrycks/ethics"](https://huggingface.co/datasets/hendrycks/ethics)
|
156 |
+
|
157 |
+
```markdown
|
158 |
+
The following subsets of the above dataset were leveraged:
|
159 |
+
-commonsense/train (13.9k random samples)
|
160 |
+
-commonsense/validation (3.6k random samples)
|
161 |
+
-deontology/train (18.2k random samples)
|
162 |
+
-deontology/validation (2.8k random samples)
|
163 |
+
-justice/train (21k random samples)
|
164 |
+
-utilitarianism/train (21k random samples)
|
165 |
+
```
|
166 |
|
167 |
### Training Procedure
|
168 |
|
169 |
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
|
170 |
|
171 |
+
<!--#### Preprocessing [optional]
|
172 |
|
173 |
+
[More Information Needed] -->
|
174 |
|
175 |
|
176 |
#### Training Hyperparameters
|
177 |
|
178 |
+
```python
|
179 |
+
per_device_train_batch_size=64
|
180 |
+
per_device_eval_batch_size=64
|
181 |
+
gradient_accumulation_steps=2
|
182 |
+
gradient_checkpointing=True
|
183 |
+
warmup_steps=100
|
184 |
+
num_train_epochs=1
|
185 |
+
learning_rate=0.00005
|
186 |
+
weight_decay=0.01
|
187 |
+
optim="adamw_hf"
|
188 |
+
fp16=True
|
189 |
+
```
|
190 |
+
|
191 |
+
#### Speeds, Sizes, Times
|
192 |
|
193 |
<!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
|
194 |
|
195 |
+
The overall training took 5 hours and 24 minutes.
|
196 |
|
197 |
## Evaluation
|
198 |
|
199 |
<!-- This section describes the evaluation protocols and provides the results. -->
|
200 |
|
201 |
+
Training Loss = 0.210800
|
202 |
+
|
203 |
+
Validation Loss = 0.234834
|
204 |
+
|
205 |
### Testing Data, Factors & Metrics
|
206 |
|
207 |
#### Testing Data
|
208 |
|
209 |
<!-- This should link to a Dataset Card if possible. -->
|
210 |
|
211 |
+
["hendrycks/ethics"](https://huggingface.co/datasets/hendrycks/ethics)
|
212 |
+
|
213 |
+
```markdown
|
214 |
+
The following subsets of the above dataset were leveraged:
|
215 |
+
-commonsense/test (2.5k random samples)
|
216 |
+
-deontology/test (2.5k random samples)
|
217 |
+
-justice/test (2.5k random samples)
|
218 |
+
-utilitarianism/test (2.5k random samples)
|
219 |
+
```
|
220 |
|
221 |
+
<!-- #### Factors -->
|
222 |
|
223 |
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
224 |
|
225 |
+
<!--[More Information Needed]
|
226 |
|
227 |
#### Metrics
|
228 |
|
229 |
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
230 |
|
231 |
+
<!--[More Information Needed]
|
232 |
|
233 |
### Results
|
234 |
|
|
|
242 |
|
243 |
<!-- Relevant interpretability work for the model goes here -->
|
244 |
|
245 |
+
<!--[More Information Needed]
|
246 |
|
247 |
## Environmental Impact
|
248 |
|
249 |
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
250 |
|
251 |
+
<!--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).
|
252 |
|
253 |
- **Hardware Type:** [More Information Needed]
|
254 |
- **Hours used:** [More Information Needed]
|
|
|
264 |
|
265 |
### Compute Infrastructure
|
266 |
|
267 |
+
[More Information Needed] -->
|
268 |
|
269 |
#### Hardware
|
270 |
|
271 |
+
6xNVIDIA A100-SXM4-40GB
|
272 |
|
273 |
+
<!--#### Software
|
274 |
|
275 |
[More Information Needed]
|
276 |
|
|
|
278 |
|
279 |
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
280 |
|
281 |
+
<!--**BibTeX:**
|
282 |
|
283 |
[More Information Needed]
|
284 |
|
|
|
290 |
|
291 |
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
292 |
|
293 |
+
<!--[More Information Needed]
|
294 |
|
295 |
## More Information [optional]
|
296 |
|
|
|
302 |
|
303 |
## Model Card Contact
|
304 |
|
305 |
+
[More Information Needed] -->
|