Inspiration The project was inspired by Tom Hagen, the lawyer-advisor character from The Godfather. The idea was to build a system that helps common people understand how flaws, gaps, and procedural weaknesses in the Indian judicial system can affect outcomes, especially under BNSS, BNS, and BSA.

What it does The user enters a general legal query, such as how someone managed to reduce punishment or avoid conviction for a specific crime despite existing laws. The model then returns a detailed explanation of the relevant laws, the case-based reasoning, and the loopholes or weak points that influenced the outcome.

How we built it We developed the entire project in a Databricks workspace notebook. First, we collected relevant articles and case reports related to crimes where accused individuals reduced punishment or escaped stronger penalties. We converted these into structured CSV files, including case details and legal sections. Then we used RAG and vectorization to match the user query with the most relevant article. After that, we extracted the important legal sections from those articles and passed them through a second RAG layer to filter the most relevant laws and sections. Finally, the extracted laws, flaws, and case context were sent to a Llama 3.3 70B model, which was tightly instructed to use only the provided data and avoid hallucination.

Challenges we ran into Hallucination was the biggest challenge. Llama 3.1 8B was not strong enough for the task, so we moved to Llama 3.3 70B for better reliability. Another major challenge was manual data preparation: we had to create case CSVs from articles and legal section data ourselves. BNSS data was not readily available in a structured format, so we built our own CSV dataset from scratch. Our original idea was also much broader and operated in a grey area of law, but no available model could handle it properly, so we scaled the concept down to something more practical and usable.

Accomplishments we’re proud of The system works end-to-end. It can take a query, identify the right case context, fetch the relevant legal sections, and produce a grounded explanation based on the available data. Building a working legal-RAG pipeline with structured case data, custom legal datasets, and model control was a major achievement for us.

What we learned We learned a lot about RAG pipelines, vector search, legal data structuring, model behavior, prompt control, and how to build AI applications inside Databricks. We also gained experience in dataset creation, retrieval filtering, and controlling generation to reduce hallucination.

What’s next for Tom Hegan The next step is to turn Tom Hegan into a more advanced legal reasoning assistant that can identify legal loopholes, procedural weaknesses, and human factors in a case, and explain how they affect outcomes. The long-term goal is to make it a strong public-facing legal education tool that helps users understand how Indian law works in practice.

Built With

Share this project:

Updates

posted an update —

future plan is to make it publically available and make it a chat bot and also it can tell flaws in the new BNS BNSS and BNA by mapping them to older ipcs and corelating the flaws so people can know the flaws and question the judiciary

Log in or sign up for Devpost to join the conversation.