Downloads · 30 days
7
3% of all-time downloads
SamuelJaja/llama-3.1-8b-instruct-construction-merged
llama-3.1-8b-instruct-construction-merged is a text generation model from SamuelJaja. Use it when you need the model to write or continue text. The card lists the license as apache-2.0.
This is a fine-tuned version of Meta's Llama-3.1-8B-Instruct model optimized for construction industry and UK building regulations knowledge. This repository contains the full merged model (base + fine-tuning), making…
Downloads · 30 days
7
3% of all-time downloads
All-time downloads
220
Public
Parameters
8B
16.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors16.1 GB · 100%
From the Hugging Face model README
This is a fine-tuned version of Meta's Llama-3.1-8B-Instruct model optimized for construction industry and UK building regulations knowledge. This repository contains the full merged model (base + fine-tuning), making it directly usable with the Hugging Face API.
This model can:
You can use this model directly with the Hugging Face transformers library:
import torch
import re
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model and tokenizer
model_id = "SamuelJaja/llama-3.1-8b-instruct-construction-merged"
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.float16, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Clean response function
def clean_response(text):
"""Remove any instruction tags from the response"""
return re.sub(r'\[/?INST\]', '', text).strip()
# Format prompt function
def format_prompt(prompt):
if not prompt.startswith("[INST]"):
return f"[INST] {prompt} [/INST]"
return prompt
# Generate text
prompt = "What are the main requirements for fire safety in commercial buildings?"
formatted_prompt = format_prompt(prompt)
inputs = tokenizer(formatted_prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
input_ids=inputs.input_ids,
attention_mask=inputs.attention_mask,
max_new_tokens=256,
temperature=0.1,
top_p=0.9,
do_sample=False
)
# Process the response
full_response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Extract just the model's response
if formatted_prompt in full_response:
response = full_response.replace(formatted_prompt, "").strip()
else:
response = full_response
# Clean any remaining tags
response = clean_response(response)
print(response)