Instructions to use Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/meta-llama-3.1-8b-instruct-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- Unsloth Studio
How to use Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal 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 Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal 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 Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal", max_seq_length=2048, )
metadata
base_model: unsloth/meta-llama-3.1-8b-instruct-unsloth-bnb-4bit
library_name: peft
license: apache-2.0
datasets:
- opennyaiorg/InJudgements_dataset
language:
- en
tags:
- law
- legal
- india
- llama-3
- unsloth
pipeline_tag: text-generation
Nyaya-Llama-3.1-8B-Indian-Legal โ๏ธ๐ฎ๐ณ
Nyaya-Llama is a specialized legal language model fine-tuned on Indian Legal Judgments. It is based on Meta Llama 3.1 8B and trained using Unsloth for efficient fine-tuning.
- Nyaya (เคจเฅเคฏเคพเคฏ): Sanskrit/Hindi word for Justice.
- Focus: Designed to understand, analyze, and summarize Indian legal documents, case laws, and reasoning.
๐ Model Details
- Base Model:
unsloth/Meta-Llama-3.1-8B-Instruct - Training Data: OpenNyAI Judgments (~12,000 Indian High Court & Supreme Court judgments).
- Training Method: QLoRA (4-bit quantization) via Unsloth.
- Epochs: 1 Full Epoch (guaranteeing comprehensive coverage of the subset).
- Context Window: 8192 tokens.
๐ Usage
Installation
pip install unsloth
pip install --no-deps "xformers<0.0.26" "trl<0.9.0" peft accelerate bitsandbytes
Inference Code
from unsloth import FastLanguageModel
import torch
model_name = "Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal" # Replace with your username
model, tokenizer = FastLanguageModel.from_pretrained(
model_name = model_name,
max_seq_length = 8192,
dtype = None,
load_in_4bit = True,
)
FastLanguageModel.for_inference(model)
prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
### Instruction:
Analyze this Indian legal judgment and remove key reasoning.
### Input:
[Paste Legal Judgment Text Here]
### Response:
"""
inputs = tokenizer([prompt], return_tensors = "pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens = 512, repetition_penalty=1.2)
print(tokenizer.batch_decode(outputs, skip_special_tokens=True)[0])
โ ๏ธ Limitations & Disclaimers
- Legal Advice: This model is for research and development purposes only. Do not use it as a substitute for professional legal advice.
- Citation formatting: The model may mimic the style of judgments by appending case citations to answers. Use string processing to clean outputs if needed.
- Accuracy: While trained on real data, LLMs can hallucinate. Always verify citations against official reporters.
๐ ๏ธ Training
Trained with Unsloth on NVIDIA GPUs.