AI Legal AssistantBack to Projects
apps

AI Legal Assistant

RAG-powered full-stack app that predicts SCOTUS case outcomes and surfaces similar precedents from 18,100+ opinions using Legal-BERT, MLP classification, and GPT-4o-mini explanations.

PythonNLPScikit-learnPandasVisualization

Deep dive

Case Study

Problem
Legal researchers and attorneys needed a scalable way to analyze long case documents, compare them to prior rulings, and surface outcome patterns—without manually reading thousands of opinions.
Approach
Built a full-stack AI Legal Assistant using NLP and ML on 18,500+ U.S. Supreme Court opinions from CourtListener. Embedded case text with Legal-BERT, trained an MLP classifier for win/lose prediction, and added RAG-based precedent retrieval via cosine similarity. Wrapped the pipeline in a FastAPI backend and a Next.js frontend, with GPT-4o-mini generating explanations grounded in retrieved precedents.
Results
Delivered an interactive web app that predicts case outcomes, retrieves 1–10 similar precedents with similarity scores, and produces AI-generated legal reasoning. The best classifier (MLP) reached ~99% accuracy on held-out data, giving legal teams a repeatable, data-driven workflow for case analysis.
Learnings
Domain-specific legal text and labeling constraints shaped everything—from mapping multi-class dispositions (granted, denied, reversed, etc.) to binary win/lose labels, to stripping disposition-language leakage from opinion tails so the model learned substance rather than verdict keywords. Severe class imbalance (~96% lose) showed that headline accuracy can hide weaker performance on minority “win” cases, reinforcing the need for careful evaluation beyond a single metric.