BharatGen introduces LegalParam, a domain-specialized large language model fine-tuned from Param-1-2.9B-Instruct on an exhaustive India-centric legal dataset. Trained across a comprehensive taxonomy of acts, laws, policies, and regulations, LegalParam is built to deliver accurate, context-aware answers to legal queries while also supporting tasks such as summarizing lengthy legal documents and simplifying complex policy texts. Whether it’s aiding practitioners with quick references, assisting researchers in exploring legal frameworks, or helping citizens better understand their rights and obligations, LegalParam brings clarity and accessibility to the vast and intricate landscape of Indian law.
⚖️ Motivation
Law in India is vast, complex, and ever-evolving, yet most language models lack the depth and domain specialization needed to navigate acts, policies, and regulations in an India-centric context. Citizens, researchers, and practitioners often struggle with scattered information and dense legal language that is hard to interpret. LegalParam bridges this gap by combining Param-1’s strong instruction-following capabilities with a meticulously curated, exhaustive dataset of Indian laws, policies, and regulations, making legal knowledge more accessible, contextual, and actionable.
🏗 Model Architecture
LegalParam inherits the architecture of Param-1-2.9B-Instruct:
LegalParam’s training corpus was designed to ensure comprehensive coverage of Indian legal knowledge and high-quality instruction tuning along with bilingual (Hindi + English) accessibility.
Steps involved:
Source Gathering
Open-source datasets on Indian laws, acts, and policies were collected and curated. Historical data (for acts and laws) for more grounded training
Question Generation
Q&A pairs were generated from acts and legal texts to create grounded supervision signals
Domain Taxonomy & Personas
An exhaustive taxonomy of the Indian legal framework was built.
Personas such as citizen, lawyer, policymaker, and researcher were defined to guide synthetic data generation.
Dataset Construction
~2M Q&A pairs curated from open sources.
Additional synthetic data grounded in taxonomy and personas expanded the dataset.
In total, 5M Q&A pairs were used for fine-tuning.
🏋️ Training Setup
Base model: Param-1-2.9B-Instruct
Training framework: Hugging Face + torchrun multi-node setup
Prompt template: Custom-designed for legal inference
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
34model_name ="bharatgenai/LegalParam"5tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=False)6model = AutoModelForCausalLM.from_pretrained(7 model_name,8 trust_remote_code=True,9 torch_dtype=torch.bfloat16 if torch.cuda.is_available()else torch.bfloat32,10 device_map="auto"11)1213# Example legal query14user_input ="What steps should a farmer take to legally transfer agricultural land ownership?"1516# 3 types of prompt17# 1. Generic QA18# 2. Context based QA (context as part of prompt)19# 3. Multi-turn conversation2021# Based on your requirements use the type of prompt (refere the above examples)22prompt =f"<user>\n{user_input}<assistant>\n"23# prompt = f"<user>\n{user_or_rag_context}\n<assistant>\n"24# prompt = f"<user>\n{user_input1}\n<assistant>\n{user_input2}\n<user> {user_input3} <assistant>..."25inputs = tokenizer(prompt, return_tensors="pt").to(model.device)2627with torch.no_grad():28 output = model.generate(29**inputs,30 max_new_tokens=300,31 do_sample=True,32 top_k=50,33 top_p=0.95,34 temperature=0.6,35 eos_token_id=tokenizer.eos_token_id,36 use_cache=False37)3839print(tokenizer.decode(output[0], skip_special_tokens=True))