Skip to content

submission-Legalysis #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c343982
Create read.me
hari-tummuri Dec 6, 2023
c1e3dcf
Delete legalysis/read.me
hari-tummuri Dec 6, 2023
057f434
Create README.md
hari-tummuri Dec 6, 2023
9f30d4b
Update README.md
hari-tummuri Dec 6, 2023
0f14596
Update README.md
hari-tummuri Dec 6, 2023
9bc125c
Update README.md
hari-tummuri Dec 6, 2023
1542c08
Update README.md
hari-tummuri Dec 6, 2023
b816eb0
Update README.md
hari-tummuri Dec 6, 2023
e3ee669
Update README.md
hari-tummuri Dec 6, 2023
d9c8a61
Update README.md
hari-tummuri Dec 6, 2023
5ba183b
Update README.md
hari-tummuri Dec 6, 2023
8992761
Add files via upload
hari-tummuri Dec 6, 2023
3bf6c01
Create redme.pd
hari-tummuri Dec 6, 2023
29ce80a
Add files via upload
hari-tummuri Dec 6, 2023
181f23b
Delete legalysis/notebooks/redme.pd
hari-tummuri Dec 6, 2023
4765677
Create red.pd
hari-tummuri Dec 6, 2023
8ebfb83
Create red.pd
hari-tummuri Dec 6, 2023
cee5eb6
Add files via upload
hari-tummuri Dec 6, 2023
3620262
Create red.pd
hari-tummuri Dec 6, 2023
59ff579
Add files via upload
hari-tummuri Dec 6, 2023
742bea6
Create red.pd
hari-tummuri Dec 6, 2023
8335acf
Add files via upload
hari-tummuri Dec 6, 2023
fecc8b5
Create red.pd
hari-tummuri Dec 6, 2023
eefaa6c
Add files via upload
hari-tummuri Dec 6, 2023
6e39a56
Delete legalysis/application/locul_run/red.pd
hari-tummuri Dec 12, 2023
8677310
README.md
Kodeeswaran-27 Dec 15, 2023
0884e9a
Merge pull request #1 from Kodeeswaran-27/patch-1
hari-tummuri Dec 15, 2023
aa3753c
Update requirements.txt
hari-tummuri Dec 16, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions legalysis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#### Team Name - Legalysis
#### Problem Statement - AI-Enhanced Legal Practice Platform
#### Team Leader Email - tummuri.hari1@wipro.com

#### A Brief of the Prototype:
To proficiently address these challenges, we’ve utilized diverse capabilities within large language models (LLMs). Our solution encompasses tasks such as summarizing legal documents, researching past cases, recalling IPC sections, and developing litigation strategies. Leveraging Intel’s robust hardware and the powerful Intel OneAPI AI analytics toolkit, we’ve fine-tuned and optimized LLMs on extensive datasets, culminating in a comprehensive and efficient solution. Alongside fine-tuning, we incorporated Retrieval-Augmented Generation to enhance our approach for the mentioned use cases.

#### Prototype Description:
To develop this solution, we have gathered data from diverse sources, which consists of legal case judgments, legal proceedings, and the Indian penal code. These datasets underwent pre-processing, and along with large language model capabilities we utilized various methodologies to devise effective solutions.

For summarizing the legal documents, we have trained LLAMA2 7B model with legal document summarization dataset resulting in performance improvement of LLM for legal case summarization. And we have done finetuning using Intel AI analytics toolkit.

For Legal research, we’ve integrated LLM with RAG (Retrieval Augmented Generation) to access details about specific cases of interest to users. This integration facilitates the provision of valuable insights for their case proceedings.

For IPC related queries, we have fine-tuned a T5 large model using an IPC dataset and used Intel developer cloud for finetuning. This enables the model to identify the specific IPC section applicable to a given scenario.

![Architecture](https://github.com/hari-tummuri/oneAPI-GenAI-Hackathon-2023/assets/104126503/4919b2c9-9ea3-43a0-8bcb-c1bfd2dd74b4)

![Process Flow Diagram](https://github.com/hari-tummuri/oneAPI-GenAI-Hackathon-2023/assets/104126503/7678e04b-7c72-42ff-a353-3656a448d636)






#### Step-by-Step Code Execution Instructions:

1. Login to IDC(Intel developer cloud)
2. Install node,express,ngrok
3. import main.js file
4. import llama.py
5. login to ngrok account
6. run the node files
7. Ngrok will give a url to make a API call to the node.js file for tunneling
8. the user has to update the ngrok url in app.py file.
9. the user has to install all the requirements in requirements.txt file
10. the user has to run the app.py streamlit file




#### Future scope:
To enhance the solution’s effectiveness, we plan to incorporate litigation strategy development in the near future by fine-tuning an LLM and integrating Retrieval-Augmented Generation.
18 changes: 18 additions & 0 deletions legalysis/application/idc/llama.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from transformers import AutoTokenizer, AutoModelForCausalLM
import sys

description = sys.argv[1]
tokenizer = AutoTokenizer.from_pretrained("Bhuvanesh-Ch/summarizationFineTuned")
model = AutoModelForCausalLM.from_pretrained("Bhuvanesh-Ch/summarizationFineTuned")
prompt = description.replace("#", " ")
inputs = tokenizer(prompt, return_tensors='pt')
output = tokenizer.decode(
model.generate(
inputs["input_ids"],
max_new_tokens=1000,
)[0],
skip_special_tokens=True
)

print(output)

43 changes: 43 additions & 0 deletions legalysis/application/idc/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const express = require('express');
const bodyParser = require('body-parser');
const { promisify } = require('util');
const { execFile } = require('child_process');

const app = express();
const port = 3000;
const cors = require('cors');
app.use(cors());
const script1Path = 'llama.py';
const script2Path = "IPC.py";

const execFilePromise = promisify(execFile);

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

app.get('/', (req, res) => {
res.send('Initiating the system');
});

app.post('/', async (req, res) => {
let data = req.body.data;
let description = req.body.description;
description = description.replace(/ /g, "#");
if (data === "Summarization") {
try {
const { stdout } = await execFilePromise('/home/ubuntu/jupyter_env/bin/python3', ['llama.py', description]);
console.log('Python process completed successfully');
res.send({ outputData: stdout });
} catch (error) {
console.error('Error executing Python process:', error.message);
res.status(500).send({ error: error.message });
}
}


});

app.listen(port, () => {
console.log(`Server is listening on http://localhost:${port}`);
});

1 change: 1 addition & 0 deletions legalysis/application/idc/red.pd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Loading