Background and Motivation
Access to legal information in India is severely limited for the majority of the population. Statutory language is dense, jurisdictional hierarchies are complex, and professional legal counsel is expensive and often inaccessible. General-purpose AI systems such as GPT-4 and Gemini can answer legal questions, but they are poorly suited to the Indian legal context: they frequently fabricate section numbers and case citations, confuse Indian law with US or UK frameworks, and have no coverage of recent Indian legislation such as the Bharatiya Nyaya Sanhita (BNS) 2023, the comprehensive criminal law that replaced the Indian Penal Code, because it postdates their training data. Keyword-based tools such as Indian Kanoon provide accurate statutory text but offer no natural language understanding, no synthesis across multiple Acts, and no conversational capability.
This paper presents Nomos, from the Greek word for law, a full-stack AI system designed specifically to answer legal questions grounded in Indian statutory law, with source attribution, privacy preservation, and multi-turn conversational support.
System Overview
Nomos is built on a technique called Retrieval-Augmented Generation (RAG). Rather than relying on a language model's internal memory, which may be outdated, hallucinated, or jurisdiction-blind, RAG first retrieves the most relevant passages from a curated document corpus, then passes those passages as context to the model when generating a response. This grounds the answer in actual statutory text rather than the model's parametric knowledge.
The system has three layers. The user interacts through a React-based chat interface with Google authentication. The backend is a Flask REST API that orchestrates the retrieval and generation pipeline. The data layer consists of a vector database (ChromaDB) storing embeddings of the legal corpus, with retrieval powered by a lightweight sentence embedding model (MiniLM-L6-v2). Language model inference is handled entirely locally using Llama 3.2 served via Ollama, meaning no user query is ever transmitted to an external server.
Legal Corpus
The Nomos corpus covers eleven sources totaling approximately 2.32 million characters of preprocessed statutory text, spanning the major domains of Indian law. Constitutional: Indian Constitution. Criminal: Indian Penal Code, Code of Criminal Procedure, Bharatiya Nyaya Sanhita 2023. Civil: Code of Civil Procedure. Regulatory: Income Tax Act 1961, Contract Act 1872, IT Act 2000, Consumer Protection Act, RTI Act 2005. Supplementary: Legal Dictionary.
Statutory texts were scraped from Indian Kanoon and extracted from Ministry of Home Affairs official PDFs, then cleaned and segmented into overlapping chunks of approximately 2,048 characters with 200-character overlap to avoid information loss at boundaries. Each chunk is tagged with its source Act name, enabling the system to attribute every answer to its statutory origin.
Prompt Architecture
A structured five-layer prompt is assembled at every inference step. The first layer establishes the model's persona as an Indian legal expert and instructs it to always cite the relevant Act and section. The second layer inserts the retrieved statutory chunks, each labelled with its source Act. The third layer provides the last five turns of conversation history, enabling coherent multi-turn dialogue, for instance a follow-up question about a section cited in the previous answer. The fourth layer is the user's current query, and the fifth layer is a simple answer trigger. This design produces responses that are grounded in retrieved text, jurisdiction-specific, and source-attributed, without exposing the retrieval mechanism to the user.
Evaluation
Nomos is qualitatively evaluated across six dimensions against GPT-4/Gemini and Indian Kanoon, using test queries spanning constitutional law, criminal law, consumer rights, digital law, and tax law.
Citation accuracy: Nomos scores 4.5/5. Responses consistently cite the correct Act and section. General LLMs score 3.2/5, with correct Act names but sometimes hallucinated section numbers. Indian Kanoon scores 2.0/5, returning raw text rather than attributed answers.
Indian law coverage: Nomos scores 4.8/5, including BNS 2023 which is absent from all general LLM training data. General LLMs score 2.5/5.
Hallucination resistance: Nomos scores 4.2/5. Retrieval-grounded generation substantially reduces fabrication. General LLMs score 3.0/5.
Jurisdictional specificity: Nomos scores 4.9/5. General LLMs score 2.4/5, frequently defaulting to US or UK legal frameworks for ambiguous queries.
Conversational memory: Nomos scores 3.8/5 with a five-turn context window. General LLMs score 4.5/5 due to longer commercial context windows. Indian Kanoon scores 1.0/5, with no conversational capability.
Privacy: Nomos scores 5.0/5 with fully local inference. General LLMs score 1.0/5 as all queries are transmitted to commercial servers. This is a meaningful distinction for legal queries involving personal circumstances, financial disputes, or criminal matters.
Contribution and Significance
Nomos makes four substantive contributions. First, it constructs and publicly releases a curated, preprocessed legal corpus spanning ten major Indian Acts, the first such corpus combined with a full RAG pipeline for Indian law. Second, it provides coverage of the Bharatiya Nyaya Sanhita 2023, filling a gap that exists in every general-purpose LLM currently available. Third, it implements a fully local inference architecture that preserves user privacy without sacrificing response quality, which is particularly important given the sensitivity of legal queries. Fourth, it demonstrates through structured evaluation that RAG-based grounding substantially outperforms general-purpose LLMs on the dimensions that matter most for legal question answering, citation accuracy, jurisdictional specificity, and hallucination resistance, while remaining accessible to users without legal training.
The broader significance is the democratisation of legal information access. India has over a billion people, most of whom cannot afford professional legal counsel for everyday legal questions. A privacy-preserving, source-attributed, jurisdiction-specific AI legal assistant represents a meaningful step toward closing that access gap.
Limitations
The corpus covers only central legislation and does not include state-level amendments, subordinate regulations, or case law, limiting completeness for queries that turn on judicial interpretation or state-specific provisions. The embedding model (MiniLM-L6-v2) was not trained on legal text, and a domain-adapted legal embedding model would likely improve retrieval precision for statutory terminology. The five-turn conversational memory window may be insufficient for extended multi-step legal consultations. The evaluation is qualitative rather than benchmark-based, as no standardised Indian legal question answering benchmark currently exists. Future work should extend the corpus to state legislation, develop a legal-domain embedding model for Indian statutory text, integrate citation verification against the corpus, and build standardised evaluation datasets for reproducible quantitative comparison.