NimaZahedinameghi commited on
Commit
f15c09b
·
verified ·
1 Parent(s): dc5e36f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -197
README.md CHANGED
@@ -18,203 +18,6 @@ should probably proofread and complete it, then remove this comment. -->
18
  [<img src="https://raw.githubusercontent.com/axolotl-ai-cloud/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/axolotl-ai-cloud/axolotl)
19
  <details><summary>See axolotl config</summary>
20
 
21
- # WHI (Workplace Hazard Identification)
22
-
23
- This model is a fine-tuned version of [Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1) on a workplace hazard identification dataset. It's designed to analyze incident descriptions and provide structured hazard classifications.
24
-
25
- ## Model Description
26
-
27
- **Model Type:** Mistral-7B (Causal Language Model)
28
- **Language(s):** English
29
- - **License:** Apache 2.0
30
- - **Finetuned from model:** [mistralai/Mistral-7B-v0.1](https://huggingface.co/mistralai/Mistral-7B-v0.1)
31
-
32
- ## Intended Uses & Limitations
33
-
34
- This model is intended for:
35
- - Analyzing workplace incident descriptions
36
- - Providing structured hazard classifications
37
- - Identifying hazard sources and types
38
- - Generating keywords for database querying related to incidents
39
-
40
- It should not be used as a substitute for professional safety assessments or medical advice.
41
-
42
- ## Training and Evaluation Data
43
-
44
- The model was fine-tuned on a custom dataset (`incident_descriptions.json`) containing workplace safety reports. Each entry in the dataset includes:
45
- - An instruction
46
- - An incident description
47
- - A structured output with hazard classification
48
-
49
- ## Training Procedure
50
-
51
- The model was fine-tuned using the Axolotl framework with the following configuration:
52
-
53
- ```json
54
- {
55
- "_name_or_path": "mistralai/Mistral-7B-v0.1",
56
- "architectures": ["MistralForCausalLM"],
57
- "attention_dropout": 0.0,
58
- "hidden_size": 4096,
59
- "num_attention_heads": 32,
60
- "num_hidden_layers": 32,
61
- "num_key_value_heads": 8,
62
- "quantization_config": {
63
- "load_in_8bit": true,
64
- "quant_method": "bitsandbytes"
65
- },
66
- "torch_dtype": "bfloat16",
67
- "transformers_version": "4.42.4",
68
- "use_cache": false
69
- }
70
- ```
71
-
72
- ## How to Use
73
-
74
- Here's how you can use this model for workplace hazard identification:
75
-
76
- ```python
77
- from transformers import AutoTokenizer, AutoModelForCausalLM
78
- import torch
79
-
80
- # Load model and tokenizer
81
- model_name = "NimaZahedinameghi/WHI"
82
- tokenizer = AutoTokenizer.from_pretrained(model_name)
83
- model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
84
-
85
- # Prepare the input
86
- instruction = "Given an incident description from a workplace safety report, analyze the text and provide a structured hazard classification. Your response should include the hazard source (broken down into three levels of granularity), the general hazard type, and keywords for database querying related to the incident. Ensure your classification is specific and accurately reflects the details provided in the incident description."
87
- incident_description = "During the night shift, a worker was operating a forklift in the warehouse. While maneuvering between storage racks, the forklift's rear wheel caught on a piece of loose pallet wrap on the floor. This caused the forklift to swerve suddenly, colliding with a nearby rack. The impact dislodged several heavy boxes from the upper levels, which fell and narrowly missed the worker. The worker managed to stop the forklift and exit safely, but was visibly shaken by the near-miss incident."
88
-
89
- # Combine instruction and input
90
- input_text = f"{instruction}\n\nIncidentDescription: {incident_description}"
91
-
92
- # Tokenize and generate
93
- input_ids = tokenizer.encode(input_text, return_tensors="pt").to(model.device)
94
- output = model.generate(input_ids, max_length=500, num_return_sequences=1, do_sample=True, temperature=0.7)
95
-
96
- # Decode and print the result
97
- result = tokenizer.decode(output[0], skip_special_tokens=True)
98
- print(result)
99
- ```
100
-
101
- This code will generate a structured hazard classification based on the given incident description.
102
-
103
- ## Limitations and Biases
104
-
105
- - The model's performance is limited by the quality and diversity of the training data.
106
- - It may not accurately classify hazards outside its training domain.
107
- - The model should not be used as the sole basis for safety decisions; always consult with safety professionals.
108
-
109
- ## Ethical Considerations
110
-
111
- When using this model, consider:
112
- - Privacy: Ensure that incident descriptions do not contain personally identifiable information.
113
- - Accountability: The model's outputs should be reviewed by qualified safety professionals.
114
- - Bias: Be aware of potential biases in the training data that could affect the model's classifications.
115
-
116
- ## Citation
117
-
118
- If you use this model in your research, please cite:
119
-
120
- ```
121
- @misc{WHI2023,
122
- author = {Nima Zahedinameghi},
123
- title = {WHI: Workplace Hazard Identification Model},
124
- year = {2023},
125
- publisher = {HuggingFace},
126
- journal = {HuggingFace Hub},
127
- howpublished = {\url{https://huggingface.co/NimaZahedinameghi/WHI}},
128
- }
129
- ```
130
-
131
- axolotl version: `0.4.1`
132
- ```yaml
133
- base_model: mistralai/Mistral-7B-v0.1
134
- model_type: MistralForCausalLM
135
- tokenizer_type: LlamaTokenizer
136
-
137
- load_in_8bit: true
138
- load_in_4bit: false
139
- strict: false
140
-
141
- datasets:
142
- - path: NimaZahedinameghi/Workplace-Hazard-Identification
143
- type: alpaca
144
- dataset_prepared_path: last_run_prepared
145
- val_set_size: 0.1
146
- output_dir: ./outputs/lora-out
147
- hub_model_id: NimaZahedinameghi/WHI
148
-
149
-
150
- adapter: lora
151
- lora_model_dir:
152
-
153
- sequence_len: 8192
154
- sample_packing: False
155
- pad_to_sequence_len: true
156
-
157
- lora_r: 32
158
- lora_alpha: 16
159
- lora_dropout: 0.05
160
- lora_target_linear: true
161
- lora_fan_in_fan_out:
162
- lora_target_modules:
163
- - gate_proj
164
- - down_proj
165
- - up_proj
166
- - q_proj
167
- - v_proj
168
- - k_proj
169
- - o_proj
170
-
171
- wandb_project: WHI
172
- wandb_entity: uqam
173
- wandb_watch:
174
- wandb_name:
175
- wandb_log_model:
176
-
177
- gradient_accumulation_steps: 4
178
- micro_batch_size: 2
179
- num_epochs: 2
180
- optimizer: adamw_bnb_8bit
181
- lr_scheduler: cosine
182
- learning_rate: 0.0002
183
-
184
- train_on_inputs: false
185
- group_by_length: false
186
- bf16: auto
187
- fp16:
188
- tf32: false
189
-
190
- gradient_checkpointing: true
191
- early_stopping_patience:
192
- resume_from_checkpoint:
193
- local_rank:
194
- logging_steps: 1
195
- xformers_attention:
196
- flash_attention: true
197
-
198
- loss_watchdog_threshold: 5.0
199
- loss_watchdog_patience: 3
200
-
201
- warmup_steps: 10
202
- evals_per_epoch: 4
203
- eval_table_size:
204
- eval_max_new_tokens: 128
205
- saves_per_epoch: 1
206
- debug:
207
- deepspeed:
208
- weight_decay: 0.0
209
- fsdp:
210
- fsdp_config:
211
- special_tokens:
212
- bos_token: "<s>"
213
- eos_token: "</s>"
214
- unk_token: "<unk>"
215
- save_safetensors: true
216
-
217
- ```
218
 
219
  </details><br>
220
 
 
18
  [<img src="https://raw.githubusercontent.com/axolotl-ai-cloud/axolotl/main/image/axolotl-badge-web.png" alt="Built with Axolotl" width="200" height="32"/>](https://github.com/axolotl-ai-cloud/axolotl)
19
  <details><summary>See axolotl config</summary>
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  </details><br>
23