TLDR: NyayaRAG is a new Retrieval-Augmented Generation (RAG) framework designed for legal judgment prediction and explanation in the Indian common law system. Unlike previous AI models that relied only on case facts, NyayaRAG incorporates relevant legal statutes and semantically retrieved prior cases, mirroring how judges actually make decisions. This approach significantly improves both the accuracy of predictions and the quality of legal explanations, as validated by both automated metrics and expert evaluations. The framework aims to provide more realistic, interpretable, and trustworthy AI support for legal decision-making.
Artificial intelligence is increasingly being applied to complex fields, and law is no exception. One significant area is Legal Judgment Prediction (LJP), which involves using AI to forecast judicial outcomes. This has the potential to make legal systems more efficient, transparent, and accessible, especially in countries like India, where millions of cases are pending.
India operates under a common law system, meaning that past court decisions, known as precedents, and statutory provisions (laws) are crucial in determining new legal outcomes. However, many existing AI systems for LJP in India have primarily focused on the internal content of a case, such as facts, issues, and reasoning, often overlooking the vital role of these external legal resources.
A new research paper introduces NyayaRAG, a novel framework designed to address this gap. NyayaRAG, a name combining “Nyaya” (justice) and “RAG” (Retrieval-Augmented Generation), aims to simulate realistic courtroom scenarios. It provides AI models with not just the factual descriptions of a case, but also relevant legal statutes and semantically retrieved prior cases. This approach mirrors how judges actually deliberate, by consulting applicable laws and previous judicial opinions.
The core idea behind NyayaRAG is to enhance the AI model’s ability to predict court decisions and generate legal explanations by grounding its responses in verifiable legal information. This helps to mitigate issues like “hallucinations” – where AI models generate incorrect or fabricated information – which can have severe consequences in legal decision-making. By integrating external legal knowledge, NyayaRAG promotes trustworthy outputs and can be integrated into existing legal systems without needing to retrain core models or share sensitive data.
How NyayaRAG Works
The framework operates through a structured pipeline. First, a lengthy legal judgment document is summarized to extract essential factual meaning. This condensed information, along with retrieved legal statutes and similar past judgments, is then fed into a large language model (LLM), specifically LLaMA-3.1 8B Instruct. The model is tasked with two main objectives:
- Prediction Task: To predict whether an appeal is likely to be fully rejected (0) or fully/partially accepted (1).
- Explanation Task: To generate a justification for its prediction, logically incorporating the facts, cited statutes, and relevant precedents. This emulates how judges provide reasoned opinions.
The researchers compiled a large dataset of over 56,000 Supreme Court of India case documents from IndianKanoon, a trusted legal search engine. This dataset includes case texts, extracted cited precedents, statutory references, and even semantically similar cases identified through advanced retrieval techniques. This comprehensive dataset allows the system to learn from a rich tapestry of legal information.
Key Findings
The evaluation of NyayaRAG showed significant improvements. When predicting judgments, the pipeline that combined case text with statutes achieved the highest accuracy in single-label predictions, highlighting the importance of legal statutes. For multi-label predictions, the most comprehensive pipeline, combining case text, statutes, and precedents, performed best. This indicates that providing structured legal knowledge significantly improves the model’s ability to generalize across different outcomes.
In terms of generating explanations, the pipeline augmented with statutes consistently outperformed others. This underscores the critical role of statutory references in making AI-generated legal explanations more factually accurate and interpretable. While similar cases helped with surface-level language, statutes provided the deeper legal grounding needed for coherent reasoning. Conversely, pipelines relying solely on factual narratives performed poorly, reaffirming that facts alone are insufficient for reliable legal predictions or persuasive explanations.
Human expert evaluations, conducted by legal professionals, corroborated these findings, with the statute-enhanced pipeline receiving the highest scores for factual accuracy, legal relevance, and completeness. This human validation reinforces the practical utility and legal soundness of NyayaRAG’s approach.
Also Read:
- Smart AI Agents Boost Accuracy in Radiology Diagnostics
- Unlocking AI’s Potential: A New Approach to Self-Evolving Agents
Implications and Future Directions
NyayaRAG represents a significant step towards building AI systems that can genuinely assist in legal settings, particularly in common law systems like India’s. By closely mimicking judicial reasoning, it offers a foundation for more interpretable and reliable legal AI. The researchers hope this work opens new avenues for AI in resource-constrained yet precedent-driven judicial systems.
While promising, the system has limitations. It doesn’t fully eliminate inaccuracies, and currently supports only binary and multi-label outcomes, not the full spectrum of complex legal verdicts. Future work will explore hierarchical verdict structures, integrating symbolic or graph-based retrieval, and modeling the temporal evolution of precedents. The research paper can be found here.


