Model Card for Model ID
This repository contains phi3-indian-law-assistant, a fine-tuned version of Microsoft's Phi-3-mini-4k-instruct. The model has been specialized to understand and summarize Indian legal documents through training on the IN-Abs dataset.
Model Details
Model Description
The model is designed to act as a legal AI assistant. It takes the full text of a legal judgment as input and generates a concise, structured summary of its key points, reasoning, and decision.In its future version, the LLM will be able to cross reference similar decisions that are were made by the court which has set a legal precedance.
- Developed by: Aryan Kankheria
- Model type:
- License: Apache License 2.0
- Finetuned from model: Microsoft's Phi-3-mini-4k-instruct
Model Sources
- Repository: Link
Uses
This model is designed to be used as a specialized assistant for summarizing and answering questions about Indian legal documents, specifically Supreme Court of India judgments. It is intended for legal students and researchers as a tool to quickly understand the gist of a case. It follows instructions in a conversational format.
Downstream Use
Legal document drafting and review.
Contract analysis.
Integration into a Retrieval-Augmented Generation (RAG) system for a comprehensive legal knowledge base.
Out-of-Scope Use
This model should not be used to provide legal advice. It is not a qualified legal professional and its outputs may contain inaccuracies or hallucinations. The model's knowledge is limited to its training data and it has no awareness of real-time legal developments.
Misuse, such as generating fake legal documents or using it for legal decisions without professional oversight, is strictly out of scope.
Bias, Risks, and Limitations
The model is trained on historical judgments from the Supreme Court of India. The training data may contain societal, historical, or gender biases which the model can replicate in its outputs. Its knowledge is also limited to the style and scope of this specific dataset and does not cover all areas of Indian law.
The primary risk is over-reliance. Users may mistake the model's coherent outputs for factual and accurate legal advice, which could lead to incorrect conclusions.
Recommendations
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
How to Get Started with the Model
import torch from transformers import AutoTokenizer, AutoModelForCausalLM model_path = "ak331/Law_LLM" tokenizer = AutoTokenizer.from_pretrained(model_path) model = AutoModelForCausalLM.from_pretrained( model_path, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True, attn_implementation='eager' )
prompt = ( f"<|im_start|>system\n" f"You are a specialized Indian legal AI assistant...\n" f"<|im_end|>\n" f"<|im_start|>user\n" f"Please analyze and summarize the following judgment...\n" f"<|im_end|>\n" f"<|im_start|>assistant\n" )
inputs = tokenizer(prompt, return_tensors="pt").to("cuda") outputs = model.generate(**inputs, max_length=512) response_text = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response_text)
Training Details
Training behaviour for this model can be found on this wandb link
Training Data
The model was fine-tuned on a 1,000-sample subset of the percins/IN-ABS dataset. This dataset contains judgments from the Supreme Court of India and their corresponding human-written summaries.
Training Procedure
The model was fine-tuned using the QLoRA method for parameter-efficient fine-tuning.
Preprocessing
Each data sample (judgment and summary) was formatted into the ChatML prompt structure to teach the model the conversational assistant persona. The format is: <|im_start|>system\n{system_prompt}<|im_end|>\n<|im_start|>user\nJUDGMENT TEXT:\n{judgment}<|im_end|>\n<|im_start|>assistant\nSUMMARY:\n{summary}<|im_end|>
Training Hyperparameters
- Base Model: microsoft/Phi-3-mini-4k-instruct
-Training Regime: QLoRA (4-bit nf4 quantization with bfloat16 compute dtype)
-per_device_train_batch_size: 1
-gradient_accumulation_steps: 8 (effective batch size of 8)
- paged_adamw_8bit
-learning_rate: 2e-4
-max_steps: 500
-max_seq_length: 512
-lora_r (rank): 16
-lora_alpha: 32
Speeds, Sizes, Times [optional]
-Hardware: 1x NVIDIA GeForce GTX 1660 Ti (6 GB VRAM)
-Training Time: Approximately 7 hours and 26 minutes.
Evaluation
Testing Data, Factors & Metrics
Testing Data
[More Information Needed]
Factors
[More Information Needed]
Metrics
[More Information Needed]
Results
[More Information Needed]
Summary
Model tree for ak331/Law_LLM
Base model
microsoft/Phi-3-mini-4k-instruct