Downloads · 30 days
0
Wosqa/llmshield-1b-finetuned
llmshield-1b-finetuned is a text generation model from Wosqa. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
Downloads · 30 days
0
Access
Public
Updated Feb 18, 2026
Repo size
62.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors45.1 MB · 72%
From the Hugging Face model README
LLMShield is a lightweight, efficient, instruction-following language model based on:
unsloth/Llama-3.2-1B-InstructThe model is optimized for:
Because it is only 1B parameters, it runs extremely fast on CPU and mobile hardware.
The model was trained using:
SFTTrainer (supervised fine tuning)Below is the official working inference code, verified to run on Colab / local Jupyter / any Python environment.
pip install transformers accelerate peft torch huggingface_hub
from huggingface_hub import notebook_login
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
# notebook_login() # Required only if model is private
# Base Llama 3.2 model
base_model = "unsloth/Llama-3.2-1B-Instruct"
# Your fine tuned LoRA adapter
ft_model = "arif-butt/llmshield-1b-finetuned"
# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(base_model)
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype=torch.float16,
device_map="auto"
)
# Apply LoRA adapter
model = PeftModel.from_pretrained(base_model, ft_model)
# Evaluation mode
model.eval()
def chat(user_message, max_new_tokens=80):
# Construct structured messages required by Llama chat template
messages = [
{
"role": "system",
"content": (
"Answer the user's question directly and concisely. "
"Do NOT ask new questions or create a Q&A list."
)
},
{"role": "user", "content": user_message},
]
# Convert messages → tokens using built-in template
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt",
).to(model.device)
# Generate continuation
outputs = model.generate(
inputs,
max_new_tokens=max_new_tokens,
temperature=0.7,
top_p=0.9,
do_sample=True,
)
# Remove prompt → decode assistant reply
generated_tokens = outputs[0, inputs.shape[-1]:]
answer = tokenizer.decode(generated_tokens,
skip_special_tokens=True).strip()
return answer
print(chat("What is LLMShield?"))
Example Output:
LLMShield is a fine-tuned Llama 3.2 1B instruction model designed
to answer questions concisely and follow user instructions.
This model performs well at:
As a small LLM, it may:
Do not use it for:
The model card applies to a repo containing at least:
adapter_model.safetensors or pytorch_lora_weights.bintokenizer.jsonconfig.jsonspecial_tokens_map.jsonSpecify your license:
Example:
MIT License
or:
Apache-2.0
If you use this model in research:
LLMShield: Fine-tuned Llama 3.2 1B model
Author: Dr. Muhammad Arif Butt, Um E Abeeha, Khalood Sami, and Alisha Shahid.
HuggingFace: arif-butt/llmshield-1b-finetuned