opennyaiorg/InJudgements_dataset
Viewer โข Updated โข 12k โข 119 โข 12
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")How to use Raazi29/Nyaya-Llama-3.1-8B-Indian-Legal with Unsloth Studio:
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
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
# 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
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,
)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.
unsloth/Meta-Llama-3.1-8B-Instructpip install unsloth
pip install --no-deps "xformers<0.0.26" "trl<0.9.0" peft accelerate bitsandbytes
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])
Trained with Unsloth on NVIDIA GPUs.