Skip to content

ayush9h/LegalDigest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LegalDigest

LegalDigest for legal text understanding, built using parameter-efficient fine-tuning (LoRA). The project focuses on Indian Penal Code (IPC) data and supports both sequence-to-sequence and causal language models. This repository contains a smaller-scale, reproducible version of the project.

Finetuned Flan-t5-small HuggingFace Model Card


Training Results

Training Loss – Seq2Seq (FLAN-T5)
Seq2Seq Loss


Logging & Monitoring

Model logs are captured in Mlflow.

Mlflow MlFlow Dashboard

Requests logs are monitored through prometheus

Prometheus
Prometheus Dashboard


Project Structure

LegalDigest/
├── legal_digest/
│   ├── api/
│   │   ├── inference.py (Endpoint for interncing the finetuned model)
│   │   ├── metrics.py (Endpoint for metrics logging for Prometheus)
│   │   └── train.py (Endpoint for finetuning the model)
│   │
│   ├── config/
│   │   ├── __init__.py
│   │   └── training.yaml (Config for model finetuning)
│   │
│   ├── data/
│   │   └── constitution_qa.json
│   │
│   ├── pipelines/
│   │   ├── __init__.py
│   │   ├── inference.py (inferencing the finetuned model)
│   │   ├── metrics.py (metrics for finetuned model Rouge, f1)
│   │   ├── preprocess.py (preprocessing of the data)
│   │   └── train.py (Fine tuning process)
│   │
│   ├── utils/
│   │   ├── __init__.py
│   │   ├── load_yaml_config.py (loads configs from training.yaml)
│   │   ├── logger.py
│   │   └── monitoring.py (monitoring uits)
│   │
│   ├── __init__.py
│   ├── app.py (streamlit demo app)
│   └── main.py (Entry point)
│
├── prometheus.yml
├── .env
├── .gitignore
├── LICENSE
├── pyproject.toml
└── README.md

Installation and How to use

1. Clone the repository

git clone https://github.com/ayush9h/LegalDigest.git
cd LegalDigest

2. Create and activate virtual environment

uv venv .venv
source .venv/bin/activate        # Linux / macOS
.\.venv\Scripts\Activate     # Windows

3. Install requirements

pip install -e .

3. Run fastapi and mlflow application

In seperate terminals run the below two commands:

uvicorn main:app --reload
mlflow server

3. Open CMD and run Prometheus through Docker

Runs prometheus on localhost:9090

docker run -p 9090:9090 -v <promtheus_yml_file_path>:/etc/prometheus/prometheus.yml prom/prometheus

About

LegalDigest: a legal-domain fine-tuning project with experiments on LLaMA vs Flan-T5, evaluating model behavior and performance on legal text tasks.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages