File size: 7,223 Bytes
5348deb
af16dcc
 
 
 
5348deb
af16dcc
 
 
 
 
 
 
 
5348deb
 
af16dcc
 
5348deb
af16dcc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5348deb
 
 
af16dcc
 
 
 
 
 
 
 
 
 
5348deb
af16dcc
5348deb
af16dcc
 
5348deb
af16dcc
 
 
 
 
 
 
5348deb
af16dcc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
---
language:
- en
license: apache-2.0
base_model: unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit
tags:
- legal
- indian-law
- BNS
- BNSS
- BSA
- criminal-law
- qwen
- qwen2.5
- gguf
- llama.cpp
- ollama
- qlora
- unsloth
- domain-adaptation
- instruction-tuning
- question-answering
- law
- india
datasets:
- GSMS-B/Indian-Legal-QA-BNS-BNSS-BSA
pipeline_tag: text-generation
---

# βš–οΈπŸ‰ Indian Legal Qwen 2.5 β€” 1.5B (GGUF)

<p align="center">
  <img src="https://img.shields.io/badge/Base%20Model-Qwen%202.5%201.5B-6366F1?style=for-the-badge" alt="Base Model"/>
  <img src="https://img.shields.io/badge/Type-GGUF%20Quantized-A855F7?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/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>

> 🟑 **This is the GGUF-quantized version** β€” for CPU inference via Ollama or llama.cpp. For full-precision inference see the [Merged Model](https://huggingface.co/GSMS-B/Indian-Legal-Qwen2.5-1.5B) Β· For lightweight adapter loading see the [Adapter](https://huggingface.co/GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter).

---

## πŸ“– Model Description

**Indian Legal Qwen 2.5 β€” 1.5B (GGUF)** is a quantized, CPU-friendly version of [`GSMS-B/Indian-Legal-Qwen2.5-1.5B`](https://huggingface.co/GSMS-B/Indian-Legal-Qwen2.5-1.5B), a domain-adapted model fine-tuned using QLoRA on a structured question-answer dataset covering all **1,059 sections** of India's three landmark 2023 criminal justice reform acts:

| 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 β€” giving it broad, structured coverage of India's reformed criminal law framework. As the smallest model in the family, this GGUF build is ideal for fast, fully offline CPU inference.

---

## πŸ”— Model Family β€” Qwen 2.5 1.5B

| Variant | Repo | Best For |
|---|---|---|
| 🟒 **Merged** | [GSMS-B/Indian-Legal-Qwen2.5-1.5B](https://huggingface.co/GSMS-B/Indian-Legal-Qwen2.5-1.5B) | Out-of-the-box inference, Gradio / API deployment |
| πŸ”΅ **LoRA Adapter** | [GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter](https://huggingface.co/GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter) | Lightweight loading on top of base model |
| 🟑 **GGUF (this repo)** | `GSMS-B/Indian-Legal-Qwen2.5-1.5B-GGUF` | CPU inference via Ollama / llama.cpp |

---

## πŸš€ Quick Start

### πŸ’» Run with Ollama
```bash
ollama run hf.co/GSMS-B/Indian-Legal-Qwen2.5-1.5B-GGUF
```

### βš™οΈ Run with llama.cpp
```bash
./llama-cli \
  -hf GSMS-B/Indian-Legal-Qwen2.5-1.5B-GGUF \
  -p "What is a Zero FIR under BNSS 2023?" \
  -n 300 \
  --temp 0.1
```

### 🐍 Run with llama-cpp-python
```python
from llama_cpp import Llama

llm = Llama.from_pretrained(
    repo_id="GSMS-B/Indian-Legal-Qwen2.5-1.5B-GGUF",
    filename="*.gguf",
)

SYSTEM = "You are an expert legal assistant specializing in Indian criminal law β€” BNS, BNSS, and BSA 2023."

response = llm.create_chat_completion(
    messages=[
        {"role": "system", "content": SYSTEM},
        {"role": "user", "content": "What is a Zero FIR under BNSS 2023?"}
    ],
    temperature=0.1,
    max_tokens=300
)

print(response["choices"][0]["message"]["content"])
```

---

## 🎯 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** | 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 |
| πŸ“š **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 |
| πŸ’» **Offline / Edge Deployment** | Smallest model in the family, runnable on consumer CPUs without a GPU β€” ideal for local apps, kiosks, or low-resource environments |
| πŸ“ **Structured Legal Summarization** | Summarize individual sections when the section text is supplied as input context |
| πŸ›οΈ **Legal NLP Research** | Benchmark Indian criminal law understanding across model families (Qwen vs Llama) |
| βš–οΈ **Comparative Law Analysis** | Highlight differences between old acts (IPC/CrPC/IEA) and their 2023 replacements |

### ❌ 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

| Property | Value |
|---|---|
| πŸ€– Base model | `unsloth/Qwen2.5-1.5B-Instruct-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 (per device) | 4 |
| πŸ“ˆ Learning rate | 2e-4 |
| βš™οΈ Optimizer | adamw_8bit |
| πŸ’» Hardware | Google Colab T4 GPU |
| πŸ› οΈ Framework | Unsloth + TRL SFTTrainer |
| πŸ’¬ Prompt format | ChatML |
| πŸ—œοΈ Quantization | GGUF (converted from merged FP16 model) |

---

## πŸ“Š Training Dataset

| πŸ“‚ Dataset | πŸ”— Link |
|---|---|
| Indian Legal QA β€” BNS + BNSS + BSA 2023 | [GSMS-B/Indian-Legal-QA-BNS-BNSS-BSA](https://huggingface.co/datasets/GSMS-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](https://huggingface.co/GSMS-B)

---

## ⚠️ 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.*