Indian Legal Assistant: A LLaMA-based Model for Indian Legal Text Generation
This repository contains information and code for using the Indian Legal Assistant, a LLaMA-based model finetuned on Indian legal texts. This model is designed to assist with various legal tasks and queries related to Indian law.
Model Description
The Indian Legal Assistant is a text generation model specifically trained to understand and generate text related to Indian law. It can be used for tasks such as:
- Legal question answering
- Case summarization
- Legal document analysis
- Statute interpretation
Model Details
| Attribute | Value |
|---|
| Model Name | Indian_Legal_Assitant |
| Developer | varma007ut |
| Model Size | 8.03B parameters |
| Architecture | LLaMA |
| Language | English |
| License | Apache 2.0 |
Installation
To use this model, you'll need to install the required libraries:
1pip install transformers torch
2# For GGUF support
3pip install llama-cpp-python
4
Usage
There are several ways to use the Indian Legal Assistant model:
1. Using Hugging Face Pipeline
1from transformers import pipeline
2
3pipe = pipeline("text-generation", model="varma007ut/Indian_Legal_Assitant")
4
5prompt = "Summarize the key points of the Indian Contract Act, 1872:"
6result = pipe(prompt, max_length=200)
7print(result[0]['generated_text'])
8
2. Using Hugging Face Transformers directly
1from transformers import AutoTokenizer, AutoModelForCausalLM
2
3tokenizer = AutoTokenizer.from_pretrained("varma007ut/Indian_Legal_Assitant")
4model = AutoModelForCausalLM.from_pretrained("varma007ut/Indian_Legal_Assitant")
5
6prompt = "What are the fundamental rights in the Indian Constitution?"
7inputs = tokenizer(prompt, return_tensors="pt")
8outputs = model.generate(**inputs, max_length=200)
9print(tokenizer.decode(outputs[0]))
10
3. Using GGUF format with llama-cpp-python
1from llama_cpp import Llama
2
3llm = Llama.from_pretrained(
4 repo_id="varma007ut/Indian_Legal_Assitant",
5 filename="ggml-model-q4_0.gguf", # Replace with the actual GGUF filename if different
6)
7
8response = llm.create_chat_completion(
9 messages = [
10 {
11 "role": "user",
12 "content": "Explain the concept of judicial review in India."
13 }
14 ]
15)
16
17print(response['choices'][0]['message']['content'])
18
4. Using Inference Endpoints
This model supports Hugging Face Inference Endpoints. You can deploy the model and use it via API calls. Refer to the
Hugging Face documentation for more information on setting up and using Inference Endpoints.
Evaluation
To evaluate the model's performance:
- Prepare a test set of Indian legal queries or tasks.
- Use standard NLP evaluation metrics such as perplexity, BLEU score, or task-specific metrics.
Example using BLEU score:
1from datasets import load_metric
2
3bleu = load_metric("bleu")
4predictions = model.generate(encoded_input)
5results = bleu.compute(predictions=predictions, references=references)
6
Contributing
We welcome contributions to improve the model or extend its capabilities. Please see our
Contributing Guidelines for more details.
License
This project is licensed under the Apache 2.0 License. See the
LICENSE file for details.
Note: While this model is based on the LLaMA architecture, it has been finetuned on Indian legal texts. Ensure compliance with all relevant licenses and terms of use when using this model.