Inspiration The work started from a simple observation: most legal documents in Pakistan are long, unstructured, and slow to navigate. Courts drown in pending cases, and lawyers spend hours searching for what should be instantly available. The idea of building an AI system that could classify cases, flag urgent ones, and surface relevant precedents came directly from that gap. The inspiration was the possibility of turning messy legal text into something searchable, explainable, and useful. What it does It automates three core tasks lawyers struggle with: Classifies each case as Civil, Criminal, or Constitutional. Assigns a priority level based on the urgency embedded in the text. Retrieves relevant legal precedents through a RAG pipeline that indexes judgments as embeddings and surfaces the closest matches to any query. All three pieces run in one interface so a user can upload or paste a judgment and get structured outputs immediately. How we built it The project started with the raw Supreme Court judgments. They were cleaned, normalized, and chunked to keep the semantic structure intact. Labeling wasn’t automated; instead, it relied on law students and practicing lawyers to ensure the summaries, categories, and priority levels reflected actual legal reasoning. TF–IDF features powered the classification and prioritization models. A Support Vector Classifier and a stacking ensemble delivered the strongest performance after extensive testing against alternatives. For precedent retrieval, each chunk was embedded using MiniLM and stored in ChromaDB. Queries were matched through cosine similarity, and a GROQ-served Llama model generated grounded answers using the retrieved text. Challenges we ran into The dataset was small, inconsistent, and heavily skewed toward high-priority cases. Many documents had formatting issues or lacked context. Labeling demanded repeated consultation with legal experts because automated guesses would have introduced errors. Getting retrieval to work reliably also required careful chunk sizing and embedding choices. Accomplishments that we're proud of Despite the dataset’s size and imbalance, the system produced high-quality results:

91.5% accuracy for case classification 95.2% accuracy for priority prediction Over 80% semantic similarity for RAG retrieval

The three components worked together as a coherent system rather than separate demos. The Streamlit interface made the whole pipeline usable without exposing the underlying complexity. What we learned Legal NLP is unforgiving. Small inconsistencies in text ruin preprocessing steps. Priority prediction depends more on legal context than surface-level vocabulary. Retrieval quality improves dramatically when chunking and embedding strategy match the domain. And most importantly, domain experts are essential; the system would not have been reliable without their input. What's next for AI-Powered Legal Case Management System The next step is scaling beyond Supreme Court judgments. High Court and District Court cases would make the system far more representative of Pakistan’s actual backlog. Adding metadata extraction, Urdu support, better embeddings, and a more advanced RAG pipeline would push the system closer to real-world deployment. The long-term direction is a full legal assistant that supports drafting, summarization, and research across multiple jurisdictions.

Share this project:

Updates

Submission history