CoolFace
Modelpublic

GSMS-B/Indian-Legal-Llama-3.2-3B

sourceHugging Faceapache-2.0updated 3mo agoView on Hugging Face
1likes38downloads
Model Card

⚖️ Indian Legal Llama 3.2 — 3B

<p align="center"> <img src="https://img.shields.io/badge/Base%20Model-Llama%203.2%203B-7C3AED?style=for-the-badge&logo=meta" alt="Base Model"/> <img src="https://img.shields.io/badge/Domain-Indian%20Criminal%20Law-DC2626?style=for-the-badge" alt="Domain"/> <img src="https://img.shields.io/badge/Method-QLoRA-2563EB?style=for-the-badge" alt="Method"/> <img src="https://img.shields.io/badge/Acts-BNS%20%7C%20BNSS%20%7C%20BSA-16A34A?style=for-the-badge" alt="Acts"/> <img src="https://img.shields.io/badge/License-Apache%202.0-F59E0B?style=for-the-badge" alt="License"/> </p>


📖 Model Description

Indian Legal Llama 3.2 — 3B is a domain-adapted version of `unsloth/Llama-3.2-3B-Instruct`, fine-tuned using QLoRA on a structured question-answer dataset covering all 1,059 sections of India's three 2023 criminal justice acts:

ActFull NameReplacesSections
📕 BNS 2023Bharatiya Nyaya SanhitaIPC 1860358
📗 BNSS 2023Bharatiya Nagarik Suraksha SanhitaCrPC 1973531
📘 BSA 2023Bharatiya Sakshya AdhiniyamIndian Evidence Act 1872170

The model was trained on 6,354 instruction-format QA pairs — 6 questions per section covering definitions, scenarios, legal elements, exceptions, and consequences — giving it broad coverage of Indian criminal law provisions.


🔗 Model Variants

VariantRepoBest For
🟢 Merged (this repo)GSMS-B/Indian-Legal-Llama-3.2-3BOut-of-the-box inference, Gradio/API deployment
🔵 LoRA AdapterGSMS-B/Indian-Legal-Llama-3.2-3B-AdapterLightweight loading on top of base model
🟡 GGUF (Quantized)GSMS-B/Indian-Legal-Llama-3.2-3B-GGUFCPU inference via Ollama / llama.cpp

🚀 Quick Start

python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "GSMS-B/Indian-Legal-Llama-3.2-3B"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

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 is a Zero FIR under BNSS 2023?"))

💻 Run locally with Ollama (GGUF)

bash
ollama run hf.co/GSMS-B/Indian-Legal-Llama-3.2-3B-GGUF

🎯 Recommended Use Cases

⚠️ Important Note: This model has been domain-adapted on structured QA data and works best when used as a component in a larger system rather than as a standalone answer engine. Direct usage may produce incomplete or imprecise answers on complex legal queries.

✅ Where this model works well

Use CaseHow to Use
🔍 RAG (Retrieval-Augmented Generation)Use a retriever (BM25, vector search) to fetch relevant BNS/BNSS/BSA sections, then pass to this model as context for grounded answers
🤖 Legal Chatbot BackendCombine with a document store of the actual act texts; use this model for generation with retrieved context
📚 Legal Education ToolBuild Q&A apps for law students learning the new 2023 acts
🔎 Section Lookup AssistantPair with a section index to quickly surface which section of BNS/BNSS/BSA applies to a given situation
🧪 Research & ExperimentationFine-tune further on specific sub-domains (e.g., only BNSS procedure, only BSA evidence rules)
📝 Structured Legal SummarizationSummarize specific sections when given the section text as input context

❌ Not recommended for

  • Standalone legal advice without a retrieval component
  • High-stakes legal decisions without human expert review
  • Jurisdictions outside BNS / BNSS / BSA 2023 scope

🏋️ Training Details

PropertyValue
Base modelmeta-llama/Llama-3.2-3B-Instruct
Fine-tuning methodQLoRA
LoRA rank64
LoRA alpha128
Target modulesqproj, kproj, vproj, oproj, gateproj, upproj, down_proj
Training data6,354 QA pairs — 1,059 sections × 6 question types
Epochs3
Batch size (effective)4
Learning rate2e-4
Optimizeradamw_8bit
HardwareGoogle Colab T4 GPU
FrameworkUnsloth + TRL SFTTrainer
Prompt formatChatML

📊 Training Data

DatasetLink
Indian Legal QA — BNS + BNSS + BSA 2023GSMS-B/Indian-Legal-QA-BNS-BNSS-BSA

6 question types per section: definitional_topic · definitional_section · scenario · elements · exceptions · consequence


👤 Author

GSMS-B — Bugatha Ganasyam Mani Sankar


⚠️ 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](https://github.com/unslothai/unsloth) for training efficiency.