Instructions to use GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/qwen2.5-1.5b-instruct-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter", max_seq_length=2048, )
βοΈπ Indian Legal Qwen 2.5 β 1.5B (LoRA Adapter)
π΅ This is the lightweight LoRA adapter β load it on top of the base Qwen2.5-1.5B-Instruct model. For ready-to-run inference see the Merged Model Β· For CPU/Ollama usage see the GGUF.
π Model Description
Indian Legal Qwen 2.5 β 1.5B (Adapter) is a LoRA adapter that domain-adapts unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit, 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. This adapter-only release keeps the download small and lets you swap it in or out of the base model at will.
π Model Family β Qwen 2.5 1.5B
| Variant | Repo | Best For |
|---|---|---|
| π’ Merged | GSMS-B/Indian-Legal-Qwen2.5-1.5B | Out-of-the-box inference, Gradio / API deployment |
| π΅ LoRA Adapter (this repo) | GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter |
Lightweight loading on top of base model |
| π‘ GGUF (Quantized) | GSMS-B/Indian-Legal-Qwen2.5-1.5B-GGUF | CPU inference via Ollama / llama.cpp |
π Quick Start
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_model_id = "unsloth/Qwen2.5-1.5B-Instruct-bnb-4bit"
adapter_id = "GSMS-B/Indian-Legal-Qwen2.5-1.5B-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 is a Zero FIR under BNSS 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 | 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 |
| π§© Modular Deployment | Swap the adapter in/out of the base model, or combine with other LoRA adapters |
| π§ͺ Further Fine-tuning | Use as a starting point for more specialised adaptation (e.g., only BNSS procedure, only BSA evidence rules) |
| π Structured Legal Summarization | Summarize individual sections when the section text is supplied as input context |
| βοΈ 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 |
π Training Dataset
| π Dataset | π Link |
|---|---|
| Indian Legal QA β BNS + BNSS + BSA 2023 | 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
β οΈ 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.
- Downloads last month
- 17
Model tree for GSMS-B/Indian-Legal-Qwen2.5-1.5B-Adapter
Base model
Qwen/Qwen2.5-1.5B