File size: 4,151 Bytes
0c84760
 
 
 
 
 
 
 
 
 
 
4f9f079
0c84760
ce34b93
 
 
 
c87e207
 
 
 
 
 
 
 
ce34b93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b1f1f6e
ba622e3
 
ce34b93
 
 
 
 
ba622e3
b1f1f6e
ce34b93
 
 
b1f1f6e
ba622e3
ce34b93
ba622e3
 
 
 
ce34b93
 
 
 
 
 
b1f1f6e
ba622e3
ce34b93
 
ba622e3
 
 
 
 
ce34b93
 
 
 
 
 
b1f1f6e
ba622e3
 
ce34b93
ba622e3
 
 
 
ce34b93
 
 
 
 
ba622e3
 
 
 
ce34b93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
---
base_model: unsloth/meta-llama-3.1-8b-bnb-4bit
language:
- en
license: apache-2.0
tags:
- text-generation-inference
- transformers
- unsloth
- llama
- trl
- sft
---
# 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.

## Faculty In Charge
- **Guide**: Dr. Kalimuthu K
- **Project Coordinator**: Dr. Sandeep Kumar P
  
## Team Members
- **RA2111004010006**: Ganesha Sai Varma
- **RA2111004010008**: Surendra Reddy
- **RA2111004010055**: Sampath Voona

## 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 |
| Hugging Face Repo | [varma007ut/Indian_Legal_Assitant](https://huggingface.co/varma007ut/Indian_Legal_Assitant) |

## Installation

To use this model, you'll need to install the required libraries:

```bash
pip install transformers torch
# For GGUF support
pip install llama-cpp-python

```

## Usage

There are several ways to use the Indian Legal Assistant model:

### 1. Using Hugging Face Pipeline

```python
from transformers import pipeline

pipe = pipeline("text-generation", model="varma007ut/Indian_Legal_Assitant")

prompt = "Summarize the key points of the Indian Contract Act, 1872:"
result = pipe(prompt, max_length=200)
print(result[0]['generated_text'])

```

### 2. Using Hugging Face Transformers directly

```python
from transformers import AutoTokenizer, AutoModelForCausalLM

tokenizer = AutoTokenizer.from_pretrained("varma007ut/Indian_Legal_Assitant")
model = AutoModelForCausalLM.from_pretrained("varma007ut/Indian_Legal_Assitant")

prompt = "What are the fundamental rights in the Indian Constitution?"
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_length=200)
print(tokenizer.decode(outputs[0]))

```

### 3. Using GGUF format with llama-cpp-python

```python
from llama_cpp import Llama

llm = Llama.from_pretrained(
    repo_id="varma007ut/Indian_Legal_Assitant",
    filename="ggml-model-q4_0.gguf",  # Replace with the actual GGUF filename if different
)

response = llm.create_chat_completion(
    messages = [
        {
            "role": "user",
            "content": "Explain the concept of judicial review in India."
        }
    ]
)

print(response['choices'][0]['message']['content'])

```

### 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](https://huggingface.co/docs/inference-endpoints/index) for more information on setting up and using Inference Endpoints.

## Evaluation

To evaluate the model's performance:

1. Prepare a test set of Indian legal queries or tasks.
2. Use standard NLP evaluation metrics such as perplexity, BLEU score, or task-specific metrics.

Example using BLEU score:

```python
from datasets import load_metric

bleu = load_metric("bleu")
predictions = model.generate(encoded_input)
results = bleu.compute(predictions=predictions, references=references)

```

## Contributing

We welcome contributions to improve the model or extend its capabilities. Please see our [Contributing Guidelines](https://www.notion.so/CONTRIBUTING.md) for more details.

## License

This project is licensed under the Apache 2.0 License. See the [LICENSE](https://www.notion.so/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.