📖 Model Description
Indian Legal Llama 3.2 — 3B (LoRA Adapter) contains the QLoRA adapter weights trained on top of unsloth/llama-3.2-3b-instruct-unsloth-bnb-4bit, domain-adapted for all 1,059 sections of India's three landmark 2023 criminal justice reform acts:
Table with columns: Act, Full Name, Replaces, Sections| Act | Full Name | Replaces | Sections |
|---|
| 📕 BNS 2023 | Bharatiya Nyaya Sanhita | IPC 1860 | 358 |
| 📗 BNSS 2023 | Bharatiya Nagarik Suraksha Sanhita | CrPC 1973 | 531 |
| 📘 BSA 2023 | Bharatiya Sakshya Adhiniyam | Indian Evidence Act 1872 | 170 |
Trained on 6,354 instruction-format QA pairs — 6 question types per section covering definitions, scenarios, legal elements, exceptions, and consequences.
🔗 Model Family — Llama 3.2 3B
Table with columns: Variant, Repo, Best For| Variant | Repo | Best For |
|---|
| 🟢 Merged | GSMS-B/Indian-Legal-Llama-3.2-3B | Out-of-the-box inference, Gradio / API deployment |
| 🔵 LoRA Adapter (this repo) | GSMS-B/Indian-Legal-Llama-3.2-3B-Adapter | Lightweight loading on top of base model |
| 🟡 GGUF (Quantized) | GSMS-B/Indian-Legal-Llama-3.2-3B-GGUF | CPU inference via Ollama / llama.cpp |
🚀 Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizerfrom peft import PeftModelimport torch base_model_id = "unsloth/llama-3.2-3b-instruct-unsloth-bnb-4bit"adapter_id = "GSMS-B/Indian-Legal-Llama-3.2-3B-Adapter" tokenizer = AutoTokenizer.from_pretrained(base_model_id)base_model = AutoModelForCausalLM.from_pretrained( base_model_id, torch_dtype=torch.float16, device_map="auto")model = PeftModel.from_pretrained(base_model, adapter_id) SYSTEM = "You are an expert legal assistant specializing in Indian criminal law — BNS, BNSS, and BSA 2023." def ask(question): messages = [ {"role": "system", "content": SYSTEM}, {"role": "user", "content": question} ] text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) inputs = tokenizer(text, return_tensors="pt").to(model.device) with torch.no_grad(): out = model.generate(**inputs, max_new_tokens=300, temperature=0.1, do_sample=True, pad_token_id=tokenizer.eos_token_id) return tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True) print(ask("What are the key differences between BNS 2023 and IPC 1860?"))
🎯 Recommended Use Cases
⚠️ Important Note: This model has been domain-adapted on structured QA data and works best as a component in a larger pipeline rather than a standalone answer engine. Direct usage without retrieval context may produce incomplete or imprecise answers on complex legal queries.
✅ Where this model excels
Table with columns: Use Case, 💡 How to Use| Use Case | 💡 How to Use |
|---|
| 🔍 RAG Pipeline | Pair with a BM25 or vector retriever over BNS/BNSS/BSA texts; feed retrieved sections as context for grounded, citation-backed answers |
| 🤖 Legal Chatbot Backend | Use as the generation backbone of a legal assistant app with a ChromaDB / FAISS document store |
| 🧩 Flexible Adapter Stacking | Swap this adapter onto the base model without maintaining a full merged checkpoint — ideal for multi-adapter experiments |
| 📚 Legal Education Tool | Build interactive Q&A apps for law students and practitioners learning the 2023 criminal justice reforms |
| 🔎 Section Lookup Assistant | Combine with a section index to surface the exact BNS / BNSS / BSA provision relevant to a given situation |
| 🧪 Further Fine-tuning | Use as a starting point for more specialised adaptation (e.g., only BNSS procedure, only BSA evidence rules) |
❌ Not recommended for
- Standalone legal advice without a retrieval component
- High-stakes legal decisions without qualified human review
- Jurisdictions or acts outside BNS / BNSS / BSA 2023
🏋️ Training Details
Table with columns: Property, Value| Property | Value |
|---|
| 🤖 Base model | unsloth/llama-3.2-3b-instruct-unsloth-bnb-4bit |
| 🔧 Fine-tuning method | QLoRA |
| 🎛️ LoRA rank | 64 |
| 🎛️ LoRA alpha | 128 |
| 🧩 Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| 📊 Training data | 6,354 QA pairs — 1,059 sections × 6 question types |
| 🔁 Epochs | 3 |
| 📦 Batch size (effective) | 4 |
📊 Training Dataset
6 question types per section:
definitional_topic · definitional_section · scenario · elements · exceptions · consequence
👤 Author
GSMS-B — Bugatha Ganasyam Mani Sankar
🤗 Hugging Face Profile
⚠️ Disclaimer
This model is intended for research and educational purposes only. It does not constitute legal advice. Outputs should not be relied upon for any legal decision without review by a qualified legal professional. The model's responses reflect patterns in training data and may contain errors or omissions.
⚡ Fine-tuned using Unsloth for training efficiency.