fc91 commited on
Commit
aec66d6
·
verified ·
1 Parent(s): f995664

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +129 -31
README.md CHANGED
@@ -1,19 +1,22 @@
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
 
@@ -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
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
 
76
  ## Training Details
77
 
@@ -79,50 +152,75 @@ 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
- [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
 
@@ -136,13 +234,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 +256,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
- [More Information Needed]
166
 
167
- #### Software
168
 
169
  [More Information Needed]
170
 
@@ -172,7 +270,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
- **BibTeX:**
176
 
177
  [More Information Needed]
178
 
@@ -184,7 +282,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 +294,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-ethics-commonsense-lora"
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-ethics-commonsense-lora"
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 that grounds all of its replies in ethical theories."},
127
+ {"role": "user", "content": """I am driving a car, and I have to make a choice. A kid suddenly appeared in the middle of the road chasing a ball. To save the kid, I
128
+ can only swerve to the right, but this would entail crashing the car against two pedestrians on the sidewalk. What should I do?"""},
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
160
+ ```
161
 
162
  ### Training Procedure
163
 
164
  <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
165
 
166
+ <!--#### Preprocessing [optional]
167
 
168
+ [More Information Needed] -->
169
 
170
 
171
  #### Training Hyperparameters
172
 
173
+ ```python
174
+ per_device_train_batch_size=64
175
+ per_device_eval_batch_size=64
176
+ gradient_accumulation_steps=2
177
+ gradient_checkpointing=True
178
+ warmup_steps=100
179
+ num_train_epochs=3
180
+ learning_rate=0.00005
181
+ weight_decay=0.01
182
+ optim="adamw_hf"
183
+ fp16=True
184
+ ```
185
+
186
+ #### Speeds, Sizes, Times
187
 
188
  <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
189
 
190
+ The overall training took 2 hours and 51 minutes.
191
 
192
  ## Evaluation
193
 
194
  <!-- This section describes the evaluation protocols and provides the results. -->
195
 
196
+ Training Loss = 0.558800
197
+
198
+ Validation Loss = 0.527818
199
+
200
  ### Testing Data, Factors & Metrics
201
 
202
  #### Testing Data
203
 
204
  <!-- This should link to a Dataset Card if possible. -->
205
 
206
+ ["hendrycks/ethics"](https://huggingface.co/datasets/hendrycks/ethics)
207
+
208
+ ```markdown
209
+ The following subset of the above dataset were leveraged:
210
+ -commonsense/test
211
+ ```
212
 
213
+ <!-- #### Factors -->
214
 
215
  <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
216
 
217
+ <!--[More Information Needed]
218
 
219
  #### Metrics
220
 
221
  <!-- These are the evaluation metrics being used, ideally with a description of why. -->
222
 
223
+ <!--[More Information Needed]
224
 
225
  ### Results
226
 
 
234
 
235
  <!-- Relevant interpretability work for the model goes here -->
236
 
237
+ <!--[More Information Needed]
238
 
239
  ## Environmental Impact
240
 
241
  <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
242
 
243
+ <!--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).
244
 
245
  - **Hardware Type:** [More Information Needed]
246
  - **Hours used:** [More Information Needed]
 
256
 
257
  ### Compute Infrastructure
258
 
259
+ [More Information Needed] -->
260
 
261
  #### Hardware
262
 
263
+ 5xNVIDIA A100-SXM4-40GB
264
 
265
+ <!--#### Software
266
 
267
  [More Information Needed]
268
 
 
270
 
271
  <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
272
 
273
+ <!--**BibTeX:**
274
 
275
  [More Information Needed]
276
 
 
282
 
283
  <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
284
 
285
+ <!--[More Information Needed]
286
 
287
  ## More Information [optional]
288
 
 
294
 
295
  ## Model Card Contact
296
 
297
+ [More Information Needed] -->