Views
No views yet
🔵 This is the lightweight LoRA Adapter — load it on top of the base model for flexible, memory-efficient inference. For plug-and-play usage, see the Merged Model.
unsloth/Qwen2.5-3B-Instruct-bnb-4bit, domain-adapted for 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 |
| Variant | Repo | Best For |
|---|---|---|
| 🟢 Merged | GSMS-B/Indian-Legal-Qwen2.5-3B | Out-of-the-box inference, Gradio / API deployment |
| 🔵 LoRA Adapter (this repo) | GSMS-B/Indian-Legal-Qwen2.5-3B-Adapter | Lightweight loading on top of base model |
| 🟡 GGUF (Quantized) | GSMS-B/Indian-Legal-Qwen2.5-3B-GGUF | CPU inference via Ollama / llama.cpp |
1from transformers import AutoModelForCausalLM, AutoTokenizer
2from peft import PeftModel
3import torch
4
5base_model_id = "unsloth/Qwen2.5-3B-Instruct-bnb-4bit"
6adapter_id = "GSMS-B/Indian-Legal-Qwen2.5-3B-Adapter"
7
8tokenizer = AutoTokenizer.from_pretrained(base_model_id)
9base_model = AutoModelForCausalLM.from_pretrained(
10 base_model_id,
11 torch_dtype=torch.float16,
12 device_map="auto"
13)
14model = PeftModel.from_pretrained(base_model, adapter_id)
15
16SYSTEM = "You are an expert legal assistant specializing in Indian criminal law — BNS, BNSS, and BSA 2023."
17
18def ask(question):
19 messages = [
20 {"role": "system", "content": SYSTEM},
21 {"role": "user", "content": question}
22 ]
23 text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
24 inputs = tokenizer(text, return_tensors="pt").to(model.device)
25 with torch.no_grad():
26 out = model.generate(**inputs, max_new_tokens=300, temperature=0.1,
27 do_sample=True, pad_token_id=tokenizer.eos_token_id)
28 return tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
29
30print(ask("What are the key differences between BNS 2023 and IPC 1860?"))⚠️ 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.
| 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 answers |
| 🤖 Legal Chatbot Backend | Use as the generation backbone with a ChromaDB / FAISS document store |
| 🧩 Flexible Adapter Stacking | Swap this adapter onto the base model without maintaining a full merged checkpoint |
| 📚 Legal Education Tool | Build Q&A apps for law students and practitioners learning the 2023 reforms |
| 🔎 Section Lookup Assistant | Surface the exact BNS / BNSS / BSA provision relevant to a given query |
| 🧪 Further Fine-tuning | Continue training on sub-domains (e.g., only BNSS procedure, only BSA evidence rules) |
| 📝 Structured Legal Summarization | Summarize sections when the section text is supplied as context |
| 🏛️ Legal NLP Research | Benchmark domain adaptation, compare adapter vs merged performance |
| Property | Value |
|---|---|
| 🤖 Base model | unsloth/Qwen2.5-3B-Instruct-bnb-4bit |
| 🔧 Fine-tuning method | QLoRA |
| 🎛️ LoRA rank | 16 |
| 🎛️ LoRA alpha | 16 |
| 🧩 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) | 2 |
| 📈 Learning rate | 2e-4 |
| ⚙️ Optimizer | adamw_8bit |
| 💻 Hardware | Google Colab T4 GPU |
| 🛠️ Framework | Unsloth + TRL SFTTrainer |
| 💬 Prompt format | ChatML |
| 📂 Dataset | 🔗 Link |
|---|---|
| Indian Legal QA — BNS + BNSS + BSA 2023 | GSMS-B/Indian-Legal-QA-BNS-BNSS-BSA |
definitional_topic · definitional_section · scenario · elements · exceptions · consequence