CoolFace
Modelpublic

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

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

⚖️🦙 Indian Legal Llama 3.2 — 3B · GGUF

<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/Type-GGUF%20Quantized-F59E0B?style=for-the-badge" alt="Type"/> <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/Runtime-Ollama%20%7C%20llama.cpp-10B981?style=for-the-badge" alt="Runtime"/> <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>

🟡 This is the GGUF quantized version — optimised for CPU inference via Ollama or llama.cpp. No GPU required. For full-precision PyTorch usage, see the Merged Model.

📖 Model Description

Indian Legal Llama 3.2 — 3B (GGUF) is a quantized, CPU-friendly version of the domain-adapted Llama 3.2 3B model, fine-tuned via QLoRA on `unsloth/llama-3.2-3b-instruct-unsloth-bnb-4bit` and covering all 1,059 sections of India's three 2023 criminal justice reform acts:

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

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

VariantRepoBest For
🟢 MergedGSMS-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 (this repo)GSMS-B/Indian-Legal-Llama-3.2-3B-GGUFCPU inference via Ollama / llama.cpp

🚀 Quick Start

🖥️ Run with Ollama (easiest)

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

🐍 Run with llama-cpp-python

python
from llama_cpp import Llama

llm = Llama.from_pretrained(
    repo_id="GSMS-B/Indian-Legal-Llama-3.2-3B-GGUF",
    filename="*Q4_K_M.gguf",   # recommended quant
    n_ctx=2048,
    verbose=False
)

response = llm.create_chat_completion(
    messages=[
        {"role": "system",  "content": "You are an expert legal assistant specializing in Indian criminal law — BNS, BNSS, and BSA 2023."},
        {"role": "user",    "content": "What is a Zero FIR under BNSS 2023?"}
    ],
    max_tokens=300,
    temperature=0.1
)
print(response["choices"][0]["message"]["content"])

🦜 LangChain integration

python
from langchain_community.llms import LlamaCpp

llm = LlamaCpp(
    model_path="path/to/Indian-Legal-Llama-3.2-3B.Q4_K_M.gguf",
    n_ctx=2048,
    temperature=0.1,
    verbose=False
)
print(llm.invoke("Explain the presumption of innocence under BSA 2023."))

🎯 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

Use Case💡 How to Use
🔍 RAG Pipeline (CPU)Run a full retrieval-augmented legal assistant entirely on CPU — no GPU needed
🖥️ Local / Offline DeploymentDeploy in air-gapped environments, court offices, or law firms without cloud dependency
🤖 Legal Chatbot BackendIntegrate via Ollama's REST API into any chatbot stack
📚 Legal Education ToolBuild Q&A apps for law students and practitioners on standard hardware
🔎 Section Lookup AssistantSurface the exact BNS / BNSS / BSA provision relevant to a query on-device
🧪 Research & BenchmarkingEvaluate quantization impact on Indian legal domain understanding
📝 Structured Legal SummarizationSummarize specific sections when the section text is supplied as context
🏛️ Edge / Low-Resource DeploymentRun on laptops, edge servers, or Raspberry Pi-class devices with sufficient RAM

❌ 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

PropertyValue
🤖 Base modelunsloth/llama-3.2-3b-instruct-unsloth-bnb-4bit
🔧 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 Dataset

📂 Dataset🔗 Link
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 🤗 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](https://github.com/unslothai/unsloth) for training efficiency. Quantized to GGUF for broad CPU compatibility.