How pixeler5diti/delhi-high-court-virtual-judge works
Project Type and Purpose
• This is a full-stack, AI-powered legal analysis and judgment prediction system.
• It leverages advanced NLP (with LegalBERT) for processing legal documents and uses vector similarity search (via FAISS) to match legal precedents.
• The system also provides a user interface built in Streamlit to allow legal professionals to upload documents and view analysis and predictions.
File Structure
• Top-Level Files and Scripts:
• app.py: The main Streamlit web app that acts as the frontend interface.
• data_downloader.py, run_training.py, train_model.py: Scripts for data acquisition and model training.
• setup_local.py and others indicate local deployment setups.
• Folders:
• data: Contains raw and processed legal documents, plus pre-computed FAISS indices and metadata.
• model: Holds modules related to embedding generation (embedding_utils.py), training (model_trainer.py), and model inference (use_trained_model.py).
• utils: Contains helper utilities for loading data, predicting judgments, processing PDF documents, integrating OpenAI’s GPT-4o, vector storage, and visualization.
• Configuration files such as LICENSE, pyproject.toml, replit.nix, requirements_local.txt indicate environment/deployment and dependency management.
Key Architectural Components and Their Relationships
a. Document Processing Module:
• Components: PDF processing utilities (pdf_processor.py in utils) and Data Loader (data_loader.py).
• Flow: Incoming documents are loaded and preprocessed (e.g., text extraction from PDFs) before being analyzed.
b. Vector Embedding and Similarity Search Module:
• Components: embedding_utils.py (converts texts into high-dimensional legal vectors) and vector_store.py (in utils) for storing and retrieving embeddings.
• Flow: Processed text gets converted into embeddings via LegalBERT; these vectors are stored in a FAISS index to enable similarity search against historical legal cases.
c. Judgment Prediction Engine:
• Components: judgment_predictor.py (contains the logic for linking extracted data, similar cases, and making predictions) and use_trained_model.py (for making use of trained embedding models).
• Flow: Based on similarities and learned patterns, predicted judgment outcomes are generated.
d. Legal Analysis Generator:
• Components: Possibly a blend of the judgment_predictor and additional transformer-based processing (optionally enhanced with OpenAI integration via openai_integration.py).
• Flow: Generates comprehensive legal analysis with reasoning, case summaries, liability determination, and recommended remedies.
e. Model Training Module:
• Components: train_model.py, run_training.py, and model_trainer.py.
• Flow: Facilitates periodic retraining and fine-tuning using updated legal data.
f. User Interface (Frontend):
• Components: app.py that implements a Streamlit application.
• Flow: Provides a multi-tab interface for document upload, viewing similar cases, judgment prediction, and additional legal analyses. It interacts with backend modules for processing and analysis.
Architectural Patterns & Design Principles
• Modular Design: Each component (document processing, vector embedding, similarity search, judgment prediction) is encapsulated into its module, making updates and testing easier.
• Clear Separation of Concerns: The data preparation, model training/inference, prediction logic, and UI are clearly delineated.
• Optional Component Integration: The design gracefully handles dependencies (for example, integrating OpenAI GPT-4o only when the API key is present).
• Pipeline Approach: The processing flows from data intake (document upload) through preprocessing, vectorization, similarity search, prediction, and then analysis generation.
• That the integration between components is explicit—demonstrate how document analysis and model training form a continuous improvement pipeline.