Text Generation
Transformers
Safetensors
PEFT
English
legal-ai
lora
qlora
indian-law
legal-simplification
accessibility
irac
unsloth
conversational
Instructions to use joyboseroy/nyayasaar-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use joyboseroy/nyayasaar-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="joyboseroy/nyayasaar-lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("joyboseroy/nyayasaar-lora", dtype="auto") - PEFT
How to use joyboseroy/nyayasaar-lora with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use joyboseroy/nyayasaar-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "joyboseroy/nyayasaar-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "joyboseroy/nyayasaar-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/joyboseroy/nyayasaar-lora
- SGLang
How to use joyboseroy/nyayasaar-lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "joyboseroy/nyayasaar-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "joyboseroy/nyayasaar-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "joyboseroy/nyayasaar-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "joyboseroy/nyayasaar-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio new
How to use joyboseroy/nyayasaar-lora 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 joyboseroy/nyayasaar-lora 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 joyboseroy/nyayasaar-lora to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for joyboseroy/nyayasaar-lora to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="joyboseroy/nyayasaar-lora", max_seq_length=2048, ) - Docker Model Runner
How to use joyboseroy/nyayasaar-lora with Docker Model Runner:
docker model run hf.co/joyboseroy/nyayasaar-lora
| license: apache-2.0 | |
| base_model: "Qwen/Qwen2.5-0.5B-Instruct" | |
| tags: ["legal-ai", "lora", "peft", "qlora", "indian-law", "legal-simplification", "accessibility", "irac", "transformers", "unsloth"] | |
| language: ["en"] | |
| pipeline_tag: text-generation | |
| datasets: ["joyboseroy/inIRAC"] | |
| library_name: transformers | |
| -------------------------- | |
| # NyayaSaar-LoRA | |
| NyayaSaar-LoRA is a lightweight LoRA adapter fine-tuned to simplify structured Indian legal reasoning into plain English. | |
| The project focuses on improving accessibility to legal reasoning for non-lawyers interacting with the Indian legal system. | |
| This model was trained using parameter-efficient fine-tuning (LoRA/QLoRA) on structured IRAC-style legal reasoning examples derived from the inIRAC dataset. | |
| --- | |
| # Motivation | |
| Indian legal documents are often difficult for ordinary citizens to understand because of: | |
| * archaic terminology | |
| * procedural complexity | |
| * dense sentence structures | |
| * formal legal phrasing | |
| NyayaSaar-LoRA explores whether small language models can learn to preserve legal meaning while simplifying language and improving readability. | |
| The project prioritizes: | |
| * accessibility | |
| * explainability | |
| * low-resource adaptation | |
| * efficient fine-tuning | |
| --- | |
| # Example | |
| ## Input | |
| ```text id="jlwmkm" | |
| Issue: Whether the detention order violates Article 22. | |
| Rule: Preventive detention laws require procedural safeguards. | |
| Application: The petitioner argued safeguards were not followed. | |
| Conclusion: The detention order is quashed. | |
| ``` | |
| ## Output | |
| ```text id="4awft0" | |
| The court examined whether the detention was legal under the Constitution. | |
| The law says preventive detention must follow proper safeguards. | |
| The petitioner argued these safeguards were ignored. | |
| The court agreed and cancelled the detention order. | |
| ``` | |
| --- | |
| # Technical Details | |
| ## Base Model | |
| * Qwen2.5-0.5B-Instruct (4-bit quantized) | |
| ## Fine-Tuning Method | |
| * LoRA / QLoRA | |
| * PEFT | |
| * Unsloth | |
| * Supervised Fine-Tuning (SFT) | |
| ## Training Environment | |
| * Google Colab | |
| * Single GPU | |
| * Low-resource fine-tuning setup | |
| --- | |
| # Dataset | |
| Training examples were derived from the inIRAC dataset: | |
| https://huggingface.co/datasets/joyboseroy/inIRAC | |
| The dataset contains structured Indian legal reasoning in IRAC format: | |
| * Issue | |
| * Rule | |
| * Application | |
| * Conclusion | |
| --- | |
| # Intended Use | |
| This project is intended for: | |
| * legal accessibility research | |
| * plain-English legal explanation | |
| * educational demonstrations | |
| * low-resource legal NLP experimentation | |
| * research into explainable legal AI | |
| --- | |
| # Usage | |
| ```python id="zj38zt" | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| from peft import PeftModel | |
| base_model = "Qwen/Qwen2.5-0.5B-Instruct" | |
| adapter_model = "joyboseroy/nyayasaar-lora" | |
| tokenizer = AutoTokenizer.from_pretrained(base_model) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| base_model, | |
| device_map="auto" | |
| ) | |
| model = PeftModel.from_pretrained(model, adapter_model) | |
| prompt = """ | |
| Issue: Whether the detention order violates Article 22. | |
| Rule: Preventive detention laws require procedural safeguards. | |
| Application: The petitioner argued safeguards were not followed. | |
| Conclusion: The detention order is quashed. | |
| """ | |
| inputs = tokenizer(prompt, return_tensors="pt").to(model.device) | |
| outputs = model.generate( | |
| **inputs, | |
| max_new_tokens=200 | |
| ) | |
| print(tokenizer.decode(outputs[0], skip_special_tokens=True)) | |
| ``` | |
| --- | |
| # Limitations | |
| This model: | |
| * does not provide legal advice | |
| * may oversimplify nuanced legal reasoning | |
| * may omit procedural subtleties | |
| * should not be used in high-stakes legal decision-making | |
| Outputs must always be reviewed by qualified legal professionals before practical use. | |
| --- | |
| # Future Work | |
| Potential future directions include: | |
| * multilingual Indian legal simplification | |
| * Hindi and Bengali adaptation | |
| * graph-grounded legal reasoning | |
| * retrieval-augmented legal explanation | |
| * evaluation using readability and semantic-preservation metrics | |
| --- | |
| # Related Work | |
| ## Dataset | |
| inIRAC Dataset: | |
| https://huggingface.co/datasets/joyboseroy/inIRAC | |
| ## Research | |
| Falkor-IRAC: Graph-Constrained Generation for Verified Legal Reasoning in Indian Judicial AI | |
| https://arxiv.org/abs/2605.14665 | |
| --- | |
| # Citation | |
| ```bibtex id="t1xjlwm" | |
| @misc{bose2026nyayasaar, | |
| title={NyayaSaar-LoRA: Simplifying Indian Legal Reasoning using PEFT}, | |
| author={Joy Bose}, | |
| year={2026}, | |
| howpublished={Hugging Face Model Repository} | |
| } | |
| ``` | |
| --- | |
| # Author | |
| Joy Bose | |
| Senior Data Scientist and Researcher | |
| Research interests: | |
| * Legal AI | |
| * Explainable AI | |
| * Graph Reasoning | |
| * Ethical AI | |
| * Efficient LLM Adaptation | |
| --- | |