CoolFace
Modelpublic

Ayushi054/BNS-Legal-Llama-3B

sourceHugging Facellama3.2updated 5mo agoView on Hugging Face
0likes
Model Card

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.

DetailInfo
Base modelunsloth/Llama-3.2-3B-Instruct
Training methodQLoRA (4-bit + LoRA, via Unsloth)
Dataset734 BNS 2023 Q&A pairs (extracted from official PDF)
LanguagesEnglish + Hindi
Training3 full epochs on Kaggle 2x T4
GGUF formatQ4KM (~2000 MB) — runs without GPU

Dataset

SourceCoverage
BNS 2023 Official PDFAll 358 sections
Section explanations714 Q&A pairs (2 per section)
Topic-based Q&A20 pairs (Hindi + English)
Total734 examples

Quick Start

Option 1 — LM Studio (No code, recommended)

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

Option 2 — Ollama

bash
# 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)

python
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](https://github.com/unslothai/unsloth)

License

Llama 3.2 Community License — Free for personal and commercial use.