Inspiration

The recent introduction of the Bharatiya Nyaya Sanhita (BNS) 2023 represents a massive shift in India's legal landscape. Transitioning to this new penal code can be daunting for citizens, law students, and even legal professionals. We wanted to build a tool that democratizes access to this new legal framework, making it easy for anyone to understand the law without having to manually sift through dense, complex legal documents.

What it does

The BNS Legal Assistant is an interactive AI chatbot that acts as a virtual legal aide. Users can ask natural language questions—such as "What are the laws around theft?"—and the chatbot instantly provides accurate, context-aware answers. It currently specializes in 64 critical sections of the BNS 2023, bridging the gap between complex legal jargon and everyday understanding.

How we built it

We developed the entire pipeline within Databricks, allowing for seamless execution and data handling. The core of the application is powered by a Retrieval-Augmented Generation (RAG) architecture. Data Processing: We ingested and processed 64 sections of the BNS 2023, converting the legal text into high-dimensional embeddings. Vector Search: We utilized FAISS (Facebook AI Similarity Search) as our vector database. This allows the system to perform blazing-fast similarity searches to find the exact legal statutes relevant to a user's prompt. Interface: We built an interactive chat UI directly within the Databricks notebook environment, allowing users to run the cells and instantly start chatting.

Challenges we ran into

Legal text is incredibly dense and specific. One of our primary challenges was optimizing the chunking strategy for the BNS documents so that the FAISS index could accurately retrieve the correct sections without missing crucial context. Preventing the AI from "hallucinating" legal advice was also a top priority, requiring us to strictly ground the model's responses in the retrieved RAG context. Additionally, rendering a clean, interactive chat UI natively inside a Databricks notebook required some creative engineering.

Accomplishments that we're proud of

We are highly proud of building a fully functional, end-to-end RAG application in a streamlined Databricks environment. Successfully integrating FAISS to handle the vector search and effectively restricting the AI to answer only based on the provided 64 BNS sections ensures our tool is both fast and legally reliable.

What we learned

Building this assistant deepened our expertise in vector databases and embedding strategies, particularly regarding how to handle domain-specific text like law. We also gained significant hands-on experience constructing RAG pipelines within Databricks and, naturally, learned a great deal about the new provisions and updates introduced in the BNS 2023 itself.

What's next for DataAI

Our immediate next step is scaling the vector database to encompass the entirety of the BNS 2023, rather than just the initial 64 sections. Following that, we aim to: Incorporate the other new criminal laws, including the Bharatiya Nagarik Suraksha Sanhita (BNSS) and the Bharatiya Sakshya Adhiniyam (BSA). Deploy the application outside of Databricks as a standalone, mobile-responsive web app. Introduce multilingual support so users across India can query their legal system in their native languages.

Built With

Share this project:

Updates