BNS Legal Llama β€” Bharatiya Nyaya Sanhita 2023 Explainer

Built with Llama 3.2 | Fine-tuned with Unsloth | GGUF available

Overview

A QLoRA fine-tuned Llama-3.2-3B model specialized in explaining the Bharatiya Nyaya Sanhita (BNS) 2023 β€” India's new criminal code that replaced the Indian Penal Code (IPC) 1860.

Detail Info
Base model unsloth/Llama-3.2-3B-Instruct
Training method QLoRA (4-bit + LoRA, via Unsloth)
Dataset 734 BNS 2023 Q&A pairs (extracted from official PDF)
Languages English + Hindi
Training 3 full epochs on Kaggle 2x T4
GGUF format Q4_K_M (~2000 MB) β€” runs without GPU

Dataset

Source Coverage
BNS 2023 Official PDF All 358 sections
Section explanations 714 Q&A pairs (2 per section)
Topic-based Q&A 20 pairs (Hindi + English)
Total 734 examples

Quick Start

Option 1 β€” LM Studio (No code, recommended)

  1. Download LM Studio
  2. Search: Ayushi054/BNS-Legal-Llama-3B-GGUF
  3. Download model.Q4_K_M.gguf
  4. Start chatting β€” model.yaml applies all settings automatically

Option 2 β€” Ollama

# Download GGUF
wget https://huggingface.co/Ayushi054/BNS-Legal-Llama-3B-GGUF/resolve/main/model.Q4_K_M.gguf

# Create Modelfile
cat > Modelfile <<EOF
FROM ./model.Q4_K_M.gguf
SYSTEM "You are a specialized BNS 2023 legal assistant. Answer only Indian criminal law questions."
PARAMETER temperature 0.6
PARAMETER repeat_penalty 1.15
EOF

ollama create bns-legal -f Modelfile
ollama run bns-legal

Option 3 β€” Python (LoRA adapter)

from unsloth import FastLanguageModel

model, tokenizer = FastLanguageModel.from_pretrained(
    model_name = "Ayushi054/BNS-Legal-Llama-3B",
    max_seq_length = 1024,
    load_in_4bit = True,
)
FastLanguageModel.for_inference(model)

messages = [
    {"role": "system", "content": "You are a specialized BNS 2023 legal assistant."},
    {"role": "user",   "content": "What is Section 103 of BNS 2023?"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=400, temperature=0.6)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Example Q&A

Q: What is Section 103 of BNS 2023?
A: BNS Section 103 β€” Punishment for murder
   Whoever commits murder shall be punished with death or imprisonment
   for life, and shall also be liable to fine...

Q: BNS mein murder ki saza kya hai?
A: BNS Section 103 ke anusaar, murder ki saza mrityu dand ya
   aajanm kaarawaas hai, saath mein jurmana bhi...

Q: Tell me a joke.
A: I'm sorry, I can only assist with questions related to the
   Bharatiya Nyaya Sanhita (BNS) 2023 and Indian criminal law.

Important Notes

  • Educational purposes only β€” not legal advice
  • Domain locked β€” model refuses non-legal queries
  • Always verify with official legal sources and a qualified advocate

Training

Trained 2x faster with Unsloth

Unsloth

License

Llama 3.2 Community License β€” Free for personal and commercial use.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Ayushi054/BNS-Legal-Llama-3B

Finetuned
(612)
this model