NyayaRAG: Indian Legal RAG Systems
- NyayaRAG is a legal AI framework that integrates factual case data, statutory provisions, and judicial precedents to simulate common-law reasoning.
- It employs a modular pipeline combining dense semantic retrieval and an instruction-tuned LLM to generate judicial predictions and explanations.
- The framework enhances prediction accuracy and explanation quality by leveraging structured legal texts and advanced retrieval engineering techniques.
NyayaRAG most specifically denotes a Retrieval-Augmented Generation (RAG) framework for Legal Judgment Prediction (LJP) under the Indian common law system, designed to simulate realistic courtroom reasoning by combining factual case descriptions with statutory provisions and judicial precedents rather than relying only on the internal text of a case document (Nigam et al., 1 Aug 2025). In adjacent work, the term also functions as a broader label for an India-focused, jurisdiction-aware, citation-grounded legal RAG stack, and, in a separate line of scholarship, for retrieval-and-generation systems grounded in Nyāya and Navya-Nyāya semantics and formalization (Panchal et al., 23 Feb 2025).
1. Definition and terminological scope
The primary legal-AI usage of NyayaRAG is anchored in LJP. In that usage, judicial decision-making is modeled through three pillars: the factual context of the case, applicable statutory provisions, and relevant judicial precedents. This contrasts with earlier Indian LJP approaches that focused on facts, issues, arguments, and reasoning internal to the judgment and often omitted statutes and precedents as explicit external knowledge sources (Nigam et al., 1 Aug 2025).
A second usage treats NyayaRAG as a reference architecture for Indian legal assistants. In this sense, the term refers to a RAG stack built over Indian legal corpora, with emphasis on authoritative sources, jurisdictional adaptation, retrieval grounding, and explicit legal-literacy functions. LawPal is described as closely aligned with this notion of a “NyayaRAG”—a jurisdiction-aware, citation-grounded RAG stack dedicated to Indian law (Panchal et al., 23 Feb 2025).
A third, distinct usage appears in work on Sanskrit and Navya-Nyāya knowledge representation. There, NyayaRAG denotes retrieval and generation constrained by yogyatā, kāraka structure, or cubical type-theoretic encodings of Navya-Nyāya technical language, rather than a legal assistant or judgment predictor (Salaskar et al., 2022).
| Usage of “NyayaRAG” | Representative work | Core object of retrieval |
|---|---|---|
| Indian common-law LJP | (Nigam et al., 1 Aug 2025) | Facts, statutes, precedents |
| Indian legal RAG reference design | (Panchal et al., 23 Feb 2025) | Constitution, statutes, judgments, official legal sources |
| Nyāya/Navya-Nyāya textual-formal retrieval | (Salaskar et al., 2022) | Yogyatā structures, kāraka relations, formal objects |
2. Common-law courtroom simulation
NyayaRAG, in the legal judgment prediction sense, is organized as a modular pipeline. The input judgment is first summarized to fit model context. A RAG agent then retrieves top- similar documents from a vector database, and an instruction-tuned LLM produces both a binary prediction and a legal explanation (Nigam et al., 1 Aug 2025).
The legal context is constructed from three sources. First, statutory references cited in the judgment are programmatically extracted, including items such as the Indian Penal Code and the Constitution of India. Sections that exceed length limits are summarized using Mixtral-8x7B-Instruct. Second, explicitly cited precedents are extracted via IndianKanoon metadata. Third, “previous similar cases” are retrieved by dense semantic similarity against the full Supreme Court corpus. All 56,387 Supreme Court of India judgments up to April 2024 are embedded with the all-MiniLM-L6-v2 sentence transformer and indexed in ChromaDB; for each target among 5,000 selected samples, the framework retrieves the top-3 most similar judgments via cosine similarity (Nigam et al., 1 Aug 2025).
The retrieval score is defined as
No additional reranking stage is reported; retrieval relies on cosine similarity in the vector database. The judgment predictor is LLaMA-3.1 8B Instruct, prompted to return a fixed structure:
##PREDICTION: [0 or 1]##EXPLANATION: [legal reasoning]
The label space is binary, with , where $0$ denotes appeal rejected and $1$ denotes appeal fully or partially accepted (Nigam et al., 1 Aug 2025).
The framework evaluates multiple input configurations in order to isolate the contribution of factual narratives and external legal knowledge. These pipelines are: CaseText Only, CaseText + Statutes, CaseText + Precedents, CaseText + Previous Similar Cases, CaseText + Statutes + Precedents, Facts Only, and Facts + Statutes + Precedents. This experimental design is central to NyayaRAG’s claim that common-law reasoning is not well modeled by fact-only prediction (Nigam et al., 1 Aug 2025).
3. Retrieval engineering in Indian legal RAG systems
A broader NyayaRAG pattern emerges in Indian legal assistants that are not limited to LJP. LawPal presents a RAG chatbot for Indian legal accessibility using a curated corpus from the Indian Constitution, statutory laws, Supreme Court archives, official government databases, legal books, and research papers; a FAISS-based vector store; DeepSeek-R1:5B for both embedding generation and answer synthesis; hierarchical indexing by topic; and a Streamlit interface (Panchal et al., 23 Feb 2025). Its preprocessing includes cleaning, OCR digitization, text normalization, tokenization, stopword removal, stemming or lemmatization, Named Entity Recognition for case names and statutory references, and chunking with LangChain’s RecursiveCharacterTextSplitter using 500–750 character chunks and 50–100 character overlap. DeepSeek-R1:5B produces 1,024-dimensional vectors, retrieval uses cosine similarity, and the reported latency is 10–50 ms for FAISS retrieval and 800–1500 ms for generation (Panchal et al., 23 Feb 2025).
NyayaAI generalizes the same design into a multi-agent legal assistant. It combines a curated Indian legal knowledge base, FAISS retrieval, and a Mastra TypeScript orchestration layer coordinating a main agent with specialized sub-agents for legal research, document summarization, case law retrieval, and drafting assistance. A compliance module validates all responses before delivery. Reported evaluation gives domain classification precision of 70\%, RAG retrieval precision of 74\%, overall response accuracy of 72\%, and an F1-score of 0.71 (Deepanshu et al., 11 May 2026).
NyayaMind provides a more retrieval-intensive formulation of the same family. Its Retrieval Module indexes statutes and precedents in three alternative backends: Endee, Milvus, and Vespa. All use snowflake/snowflake-arctic-embed-m-v2.0 with 768-dimensional embeddings. Endee uses HNSW with cosine similarity and returns top- nearest neighbors. Milvus implements a three-stage hybrid pipeline with ANN pre-filtering, Okapi BM25 subset reranking using and , and Reciprocal Rank Fusion with . Vespa runs semantic and lexical retrieval in parallel and also fuses them with RRF. In the Milvus configuration, the indexed corpus contains approximately 1,847,564 segments across Central Acts, Supreme Court judgments, High Court judgments, and State Acts (Shukla et al., 10 Apr 2026).
These systems share a recognizable NyayaRAG design vocabulary: authoritative Indian legal corpora, chunked statutory and precedential text, dense retrieval or hybrid dense-lexical retrieval, structured prompt packaging, and generation constrained by retrieved legal evidence. This suggests that, outside the specific LJP paper, NyayaRAG has become a practical shorthand for Indian-law RAG pipelines that are retrieval-first rather than closed-book.
4. Multilingual, adaptive, and compliance-oriented extensions
A multilingual extension of the NyayaRAG pattern appears in LegalRAG, a bilingual question-answering system over the Bangladesh Police Gazettes. The corpus comprises 13 gazettes totaling 81 pages and covering 2016–2023. OCR uses PyPDFium2 and Tesseract configured for Bangla and English. Embeddings are generated with BAAI/bge-m3, stored in ChromaDB, and retrieved with Maximum Marginal Relevance. The proposed “advanced hybrid RAG” adds a multilingual LLM-based relevance check and query refinement loop using Llama 3.2 (3B), iterating up to cycles (Kabir et al., 19 Apr 2025). Reported gains over vanilla RAG include, for Llama 3.1 (8B), cosine similarity improving from 0.76 to 0.82 and human score from 3.41 to 3.70.
An adaptive extension appears in work on legal research assistance. That pipeline adds a context-aware query translator that disentangles document references from natural-language questions, predicts expertise with the Dale–Chall readability formula, classifies specificity with a DistilBERT vague-versus-verbose classifier, and adapts retrieval depth accordingly. With open-source SBERT and GTE embeddings, the authors report Recall@K improvements of 30–95\% and Precision@K improvements of about 2.50 for 1, with a custom legal-grounded prompt outperforming baseline prompting on RAGAS faithfulness and BERTScore-F1 (Keisha et al., 18 Aug 2025).
A further extension concerns procedural compliance. In a system for supporting Japanese litigation procedures, three requirements are emphasized for legally compliant RAG: retrieval from appropriate external knowledge in accordance with the principle prohibiting the use of private knowledge, responses that remain faithful to retrieved context, and retrieval that references external knowledge with appropriate timestamps corresponding to the issues at hand (Ishihara et al., 28 Nov 2025). A plausible implication is that NyayaRAG-style systems for Indian law can be strengthened by approved-source gating, per-claim attribution, and time-aware retrieval over laws, precedents, official guidelines, and other provenance-bearing sources.
5. Evaluation profile and empirical results
NyayaRAG’s evaluation combines judgment prediction metrics with explanation-quality metrics. For prediction, the paper reports Accuracy, Macro Precision, Macro Recall, and Macro F1. For explanations, it reports ROUGE-L, BLEU, METEOR, BERTScore, BLANC, G-Eval, expert ratings, and Inter-Annotator Agreement measures including Fleiss’ Kappa, Cohen’s Kappa, ICC, Krippendorff’s Alpha, and Pearson correlation (Nigam et al., 1 Aug 2025).
The main empirical result is that structured legal knowledge improves both predictive accuracy and explanation quality. In the Single partition, CaseText + Statutes achieved the best accuracy at 67.07\%, compared with 62.27\% for CaseText Only. In the Multi partition, CaseText + Statutes + Precedents achieved the best accuracy at 65.86\%, compared with 53.10\% for CaseText Only. Facts Only reached 53.71\%, while Facts + Statutes + Precedents reached 52.57\% (Nigam et al., 1 Aug 2025).
Explanation metrics show the same pattern. In the Single partition, CaseText + Statutes led across key metrics with ROUGE-L 0.17, BLEU 0.03, METEOR 0.20, BERTScore 0.53, BLANC 0.09, G-Eval 4.21, and Expert score 5.5. Facts-only configurations lagged; for Facts + Statutes + Precedents, G-Eval was 2.97 and Expert score was 3.9. The paper also reports that removing statutes reduces multi-label F1 from 63.96 to 57.53, while removing precedents also reduces performance, indicating complementary roles (Nigam et al., 1 Aug 2025).
LawPal reports a different evaluation profile because it is a legal chatbot rather than an LJP system. It names Precision@K, MRR, and NDCG for retrieval, and BLEU, ROUGE, and Legal Consistency Score for generation, but exact numeric retrieval values are not reported. The paper instead emphasizes “over 90% legal accuracy” validated by expert reviews, user satisfaction of 85\% for accuracy and reliability, and a variation rate below 5\% attributable to generative rephrasing rather than legal inconsistency (Panchal et al., 23 Feb 2025).
Across these systems, one recurrent finding is that statutes are especially important. In NyayaRAG, statutory augmentation often produces the strongest gains in both judgment prediction and explanation quality; in LawPal, grounding in constitutional law, statutory provisions, and precedents is presented as the primary anti-hallucination mechanism. This suggests that, for Indian legal RAG, statute retrieval is not merely auxiliary context but a central structural signal.
6. Limitations, disputes, and non-legal extensions
The NyayaRAG LJP paper identifies several limitations: RAG reduces but does not eliminate hallucinations; binary and multi-label framing do not cover a hierarchical or multi-class verdict taxonomy; summarization may omit subtle legal nuances; real-world texts can be noisy or inconsistently formatted; and the system does not include full fine-tuning on Indian legal corpora (Nigam et al., 1 Aug 2025). LawPal reports additional practical gaps, including the absence of disclosed FAISS index parameters, no explicit cross-encoder reranker, limited multilingual support, and unspecified citation formatting policies (Panchal et al., 23 Feb 2025).
The term also extends beyond legal AI. In work on Sanskrit computational linguistics, NyayaRAG is proposed as an end-to-end RAG system for Nyāya texts grounded in yogyatā and kāraka theory. Its pipeline includes yogyatā-aware word sense disambiguation, kāraka labeling, a knowledge graph 2, and reranking with a score of the form
3
where 4 measures structural congruity between query and document (Salaskar et al., 2022).
In a more formal direction, “Cubical Type Theoretic Navya-Nyāya” designs NyayaRAG around typed formal objects such as Sambandha, Avacchedaka, Abhāva, Vyāpti, Tadātmyā, Paramparā, Paryāpti, and Jñāna. Retrieval is then performed over formal type signatures, universe tags, avacchedaka contexts, and proof objects, with type-checking in Cubical Agda serving as a validator for retrieved distinctions (Panday et al., 10 May 2026). This usage is conceptually remote from Indian legal assistance, but it preserves the same core intuition: retrieval and generation should be constrained by explicit structure rather than unconstrained free-form language modeling.
In its dominant contemporary sense, however, NyayaRAG names a family of Indian legal RAG systems that seek to align LLM outputs with the actual materials of common-law reasoning—facts, statutes, and precedents—while moving toward stricter grounding, citation fidelity, multilingual coverage, and auditability.