Downloads · 30 days
0
FrAnKu34t23/osha-tiny-llama
osha-tiny-llama is a machine learning model from FrAnKu34t23. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for transformers.
Fine-tuned TinyLlama-1.1B-Chat model for Occupational Safety and Health (OSHA) risk assessment and hazard extraction from incident descriptions.
Downloads · 30 days
0
Access
Public
Updated Jul 1, 2025
Repo size
9.5 MB
Likes
0
Public
Click a slice to open those files.
.safetensors9 MB · 69%
From the Hugging Face model README
Fine-tuned TinyLlama-1.1B-Chat model for Occupational Safety and Health (OSHA) risk assessment and hazard extraction from incident descriptions.
This model is designed to:
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type='nf4'
)
model = AutoModelForCausalLM.from_pretrained("your-username/osha-tiny-llama", device_map="auto", quantization_config=bnb_config)
tokenizer = AutoTokenizer.from_pretrained("your-username/osha-tiny-llama")
tokenizer.pad_token = tokenizer.eos_token
def generate_response(prompt, max_new_tokens=512):
inputs = tokenizer(prompt, return_tensors='pt').to('cuda')
outputs = model.generate(input_ids=inputs['input_ids'], max_new_tokens=max_new_tokens, pad_token_id=tokenizer.pad_token_id)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
prompt = """Incident Description:
A worker fell from a ladder while painting a wall.
Please extract the following in JSON format:
- Hazards
- Cause of Accident
- Degree of Injury (choose: High - may cause fatality, Medium - may cause hospitalized injury, Low - may cause non hospitalized injury)
- Occupation"""
print(generate_response(prompt))