Project Case Study

JurisAI

A specialized Legal AI chatbot designed for the Indian judicial system. It uses RAG pipelines to retrieve case laws and legal precedents.

Live Demo → GitHub Repo

How It Started

The legal system in India is incredibly vast, with millions of historical case records and precedents. Legal professionals often spend huge amounts of time simply searching through dense archives to find relevant cases to support their arguments.

I wanted to leverage the power of Large Language Models and Retrieval-Augmented Generation (RAG) to make this process instantaneous. JurisAI was built to act as a highly specialized legal assistant capable of semantic search across complex legal texts, understanding the nuance of legal queries rather than relying solely on keyword matching.

Architecture & Flowchart

        graph TD
          User((User)) -->|Enters Legal Query| Frontend[Chat UI]
          Frontend -->|API Request| Backend[Python Backend]
          Backend --> Embedder[Embedding Model]
          Embedder -->|Generates Vectors| DB[(pgvector Database)]
          DB -->|Returns Top-K Similar Cases| Backend
          Backend -->|Context + Query| LLM{Large Language Model}
          LLM -->|Synthesizes Response| Backend
          Backend -->|Legal Advice & Citations| Frontend
          Frontend --> User
      

Challenges Faced

1. Vector Search Accuracy

Traditional keyword search fails for complex legal queries because the phrasing of the question rarely matches the exact phrasing of the historical document. Transitioning to dense vector embeddings using pgvector allowed the system to perform true semantic search, capturing the "meaning" of the query and retrieving highly relevant documents even when terminology differed.

2. Hallucination Mitigation

In the legal domain, hallucinated facts or fabricated case laws are disastrous. To combat this, the LLM is strictly prompted to only synthesize answers using the retrieved context. The RAG pipeline was heavily tuned to inject precise citations and to gracefully refuse to answer if the retrieved context did not contain sufficient legal precedent.