Views
No views yet
incident_descriptions.json) containing workplace safety reports. Each entry in the dataset includes:1{
2base_model: mistralai/Mistral-7B-v0.1
3model_type: MistralForCausalLM
4tokenizer_type: LlamaTokenizer
5
6load_in_8bit: true
7load_in_4bit: false
8strict: false
9
10adapter: lora
11lora_model_dir:
12
13sequence_len: 8192
14sample_packing: False
15pad_to_sequence_len: true
16
17lora_r: 32
18lora_alpha: 16
19lora_dropout: 0.05
20lora_target_linear: true
21lora_fan_in_fan_out:
22lora_target_modules:
23 - gate_proj
24 - down_proj
25 - up_proj
26 - q_proj
27 - v_proj
28 - k_proj
29 - o_proj
30
31gradient_accumulation_steps: 4
32micro_batch_size: 2
33num_epochs: 2
34optimizer: adamw_bnb_8bit
35lr_scheduler: cosine
36learning_rate: 0.0002
37
38train_on_inputs: false
39group_by_length: false
40bf16: auto
41fp16:
42tf32: false
43
44gradient_checkpointing: true
45early_stopping_patience:
46resume_from_checkpoint:
47local_rank:
48logging_steps: 1
49xformers_attention:
50flash_attention: true
51
52loss_watchdog_threshold: 5.0
53loss_watchdog_patience: 3
54
55warmup_steps: 10
56evals_per_epoch: 4
57eval_table_size:
58eval_max_new_tokens: 128
59saves_per_epoch: 1
60debug:
61deepspeed:
62weight_decay: 0.0
63fsdp:
64fsdp_config:
65special_tokens:
66 bos_token: "<s>"
67 eos_token: "</s>"
68 unk_token: "<unk>"
69save_safetensors: true
70}| Training Loss | Epoch | Step | Validation Loss |
|---|---|---|---|
| 1.0331 | 0.0076 | 1 | 1.0164 |
| 0.3599 | 0.2505 | 33 | 0.3364 |
| 0.3004 | 0.5009 | 66 | 0.3113 |
| 0.274 | 0.7514 | 99 | 0.2991 |
| 0.2273 | 1.0019 | 132 | 0.2860 |
| 0.1722 | 1.2524 | 165 | 0.2868 |
| 0.2038 | 1.5028 | 198 | 0.2863 |
| 0.2167 | 1.7533 | 231 | 0.2845 |
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Load model and tokenizer
5model_name = "NimaZahedinameghi/WHI"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
8
9# Prepare the input
10instruction = "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."
11incident_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."
12
13# Combine instruction and input
14input_text = f"{instruction}\n\nIncidentDescription: {incident_description}"
15
16# Tokenize and generate
17input_ids = tokenizer.encode(input_text, return_tensors="pt").to(model.device)
18output = model.generate(input_ids, max_length=500, num_return_sequences=1, do_sample=True, temperature=0.7)
19
20# Decode and print the result
21result = tokenizer.decode(output[0], skip_special_tokens=True)
22print(result)@misc{WHI2023,
author = {Nima Zahedinameghi},
title = {WHI: Workplace Hazard Identification Model},
year = {2023},
publisher = {HuggingFace},
journal = {HuggingFace Hub},
howpublished = {\url{https://huggingface.co/NimaZahedinameghi/WHI}},
}