How shivamlth27/predicting-judgment-decisions-using-llm works
Main Project Components
• Data Preparation & Input:
• Notebooks and scripts like data_prep.ipynb and train.ipynb handle dataset preparation.
• The PredEx dataset (Indian legal judgments) is an external input placed in a designated data directory.
• Model Training & Fine-Tuning:
• Dedicated scripts include roberta.py, roberta_train.py, instruction_fine_tuning.py, and rag_fine_tuning.py.
• Models include fine-tuned versions of RoBERTa, Legal-BERT, and a pre-trained LLama (pretrained_llama.py).
• Hierarchical data processing (e.g., aggregating paragraph-level embeddings) is used to manage very long legal texts.
• Vector Storage & Retrieval:
• The "legal_vectorstore" directory (with files like index.faiss and index.pkl) suggests use of a vector store to speed up similarity search and retrieval.
• Inference & Explainability:
• The inference.py script is responsible for running model predictions.
• Attention-based explainability methods provide interpretable rationales for judicial predictions.
• Web Application & User Interface:
• app.py acts as the backend API or web server.
• The templates directory (with about.html, index.html, model.html) provides the HTML pages for interfacing with end users.
• Supporting Documents & Assets:
• The images directory stores visual assets, while the report.pdf contains detailed project documentation.
Relationships and Data Flow
• Role of the Vector Store:
• That once models are trained, the resulting embeddings or indexes (stored in the vector store) facilitate rapid similarity searches during inference.
• Inference Process:
• That the vector store is used in the inference process.
• Web Application:
• Link the Inference component and the Web Application (app.py).
• Connections to the front-end templates where users view results, explanation visualizations (attention heatmaps), or interact further with the system.
Architectural Patterns & Design Principles
• Separation of Concerns:
• Distinguish between the data preparation/training layer and the inference/serving layer.
• Modularity:
• Clearly separated scripts/notebooks for different tasks (training, inference, web serving), allowing independent development and potential microservices if needed.
• Integration of AI Explainability:
• That the system integrates attention-based mechanisms for legal decision explainability.
Relevant Technologies & Frameworks
• NLP & Deep Learning Libraries:
• RoBERTa, Legal-BERT, and LLama-based models.
• Vector Search Tools:
• FAISS is likely used for vector similarity indexing (referenced by index.faiss).
• Web Framework:
• The presence of app.py and HTML templates suggests use of a framework like Flask.
• Notebook-based Experimentation:
• Data preparation and training are supported through Jupyter notebooks (data_prep.ipynb and train.ipynb).
Elements
• Each Component Should be Clearly Labeled:
• “Data Preparation”, “Model Training”, “Vector Store”, “Inference”, “Web API/Backend”, and “User Interface/Frontend”.
Putting It All Together
• Next, branch to the Model Training layer, illustrating fine-tuning with RoBERTa and Legal-BERT, and noting the pre-trained LLama.
• From the Vector Store, indicate its use in the Inference module.
• Finally, connect the Inference module to the Web Application (app.py) and illustrate how the web templates render the outputs to end users.
• Optionally, add a feedback loop for user input or expert evaluations that might help in refining models.