Information Technology | Artificial Intelligence » BharatLex, Custom AI Chatbot for Legal Query-Driven Using RAG and Optimized LLM Fusion

Please log in to read this in our online viewer!

BharatLex, Custom AI Chatbot for Legal Query-Driven Using RAG and Optimized LLM Fusion

Please log in to read this in our online viewer!


 2025 · 9 page(s)  (774 KB)    English    0    November 18 · 2026    Shri Shankaracharya Institute of Professional Management  
       
Comments

No comments yet. You can be the first!

Content extract

BharatLex: Custom AI Chatbot for Legal Query-Driven Using RAG and Optimized LLM Fusion Manoj Kumar Singh1, Aakhya Singh2, Suman Choudhary3, Palak Singh4 Shri Shankaracharya Institute of Professional Management & Technology, Raipur, India msingh@ssipmt.com Abstract. BharatLex is an AI-driven chatbot designed to enhance access to legal information, offering legal query resolution, court judgment summaries, and document-based information retrieval. Supporting the Indian Constitution, it ensures inclusivity across India’s linguistic diversity. Leveraging advanced Large Language Models (LLMs) with Ollama and machine learning, BharatLex excels in delivering precise, context-aware responses and simplifies complex legal language for diverse users. Integration with legal databases enables real-time access to accurate, up-todate information, vital for legal professionals and the public alike Its multilingual interaction capability ensures seamless user experiences across cultures,

fostering greater legal literacy and awareness. BharatLex achieved 9999% accuracy, demonstrating its robust design, effective query resolution, and transformative potential in bridging the gap between India’s legal system and its people. With its ability to simplify legal complexities and empower users, BharatLex represents a significant advancement in AI- powered legal technology and a step forward in democratizing access to justice. Keywords: AI Chatbot, BharatLex, Indian Constitution, legal Queries, LLM (Large Language Model), OLLAMA, OpenAI, RAG (Retrieval Augmented Generation). 1 Introduction In today’s digital age, accessing legal information remainsa challenge, particularly in linguistically diverse countries like India. Complex legal terminology, technical language, and limited resources in regional languages hinder public understanding of legal rights and justice. BharatLex, an AI- driven multilingual chatbot, addresses these challenges by leveraging advanced Large

Language Models (LLMs) [1][2], machine learning, and the Retrieval- Augmented Generation (RAG) [2] approach to provide accurate and context-aware legal assistance. BharatLex simplifies legal queries, summarizes court judgments, and offers knowledge in English and all scheduled Indian languages. It serves both individuals and legal professionals, delivering document summarization, efficient retrieval, and scalable features like real-time updates on laws and judgments. Future enhancements may include voice-based interactions for wider accessibility. By bridging the gap between complex legal systems and the general public, BharatLex aims to democratize legal information, empowering users across linguistic and educational background. Overall, BharatLex represents a pioneering effort in harnessing AI for legal empowerment in India. The Author(s) 2025 S. K Swarnkar and Y K Rathore (eds), Proceedings of the International Conference on Advances and Applications in Artificial Intelligence

(ICAAAI 2025), Advances in Intelligent Systems Research 194, https://doi.org/102991/978-94-6463-738-0 39 BharatLex: Custom AI Chatbot for Legal Query-Driven Using RAG 487 Fig. 1 RAG Model Architecture The diagram illustrates the Retrieval-Augmented Generation (RAG) framework, integrating external knowledge with Large Language Models (LLMs) [3] for enhanced AI capabilities. Documents are processed by an embedding model, converting them into vectorembeddings, which are stored in a vector database (vector store). When a user submits a query, it is also converted into a vector and matched against the stored embeddings to retrieve the most relevant results. 1.1 Objectives BharatLex simplifies access to India’s legal systems, bridging the gap between legal knowledge and the public. Using AI technologies like RAG, Ollama, and machine learning, it provides accurate, multilingual, and context-aware responses [4]. Supporting multiple Indian languages, it aids individuals and

professionals by automating tasks like legal research and document summarization. BharatLex promotes legal literacy, focusing on accuracy, scalability, and accessibility, aiming to foster informed engagement and justice. 1.2 Problem Statement Accessing legal information in India is difficult due to complex jargon, technical language, and limited regional resources, hindering public understanding of legal rights. Legal professionals also struggle with inefficiencies in document summarization and research. A scalable, multilingual solution is needed to simplify legal knowledge and improve efficiency for legal practitioners. 488 M. K Singh et al 2 Literature Review 2.1 Overview A BharatLex is an AI-driven multilingual chatbot that simplifies legal information access in India, helping users understand their rights and assisting legal professionals with tasks like document summarization and research. The evolution of chatbots started with ELIZA (Weizenbaum, 1966), followed by

PARRY (1970s) and ALICE (1990s), leading to consumer bots like Smarter Child (2000s) and virtual assistants such as Siri (2011) and Alexa (2014) [5]. Recent advancements in Large Language Models (LLMs), like ChatGPT and Bard (2022–2023), have expanded chatbot capabilities, enabling them to address complex queries and provide specialized knowledge in fields like law and healthcare (Labadze et al., 2023) [6] Developing legal chatbots tailored for India presents unique challenges. Legal documents often contain complex terminologies and require precise interpretation to ensure accurate responses [7] Legal chatbots in India face challenges like complex legal terms, multilingual support, and ethical issues like privacy and AI reliability. Despite this, they can democratize legal access by simplifying tasks and bridging the publiclawyer knowledge gap with advanced AI [8]. The Retrieval-Augmented Generation (RAG) approach enhances traditional LLMs by integrating external knowledge retrieval,

ensuring responses are contextually accurate and up-to-date with legal developments like court judgments and legislative changes [9]. In legal applications, where precision is crucial, RAG provides factually grounded and reliable answers [10]. By dynamically retrieving relevant content, it ensures BharatLex remains a dependable source of constitutional law information 2.2 Problem Identification This research presents BharatLex, an AI chatbot that simplifies legal queries, summarizes judgments, and provides multilingual access to Indian legal documents. Using RAG [11], LLMs with Ollama [12], and machine learning, it aids users by automating tasks like research and document summarization [13]. Future plans include enhancing contextual understanding and expanding features while ensuring ethical compliance [14]. 3 Proposed Methodology The dataset for this research includes the full text of the Constitution of India from The India Code [15] and National Archives [16], covering the

preamble, articles, schedules, and amendments, preprocessed for NLP to ensure privacy and accuracy. BharatLex, an AI chatbot using the RAG framework, combines LLMs with real-time data retrieval [17]. Supporting English and Hindi, it answers queries, summarizes judgments, and interprets legal texts to improve legal access in India. BharatLex: Custom AI Chatbot for Legal Query-Driven Using RAG 3.1 489 Methodology choice and justification BharatLex uses an Agile SDLC [18] for its adaptability and focus on user-cantered design. Agile’s iterative sprints (2-4 weeks) enable incremental development, testing, and deployment of features, ensuring faster progress compared to the Waterfall model, which delivers the final product after all phases are complete. Fig.2 Agile Process Model 3.2 Explanation of the Flow Diagram: The machine learning pipeline for BharatLex consists of three stages: Preprocessing, Learning, and Prediction. Here's a concise explanation tailored to my project

displayed in figure 3 Legal data, including judgments and statutes, is prepared using NLP techniques such as tokenization, stop word removal, and NER to extract key legal entities [19]. The dataset is split into training (70-80%) and testing (20-30%) sets, with features like keywords, legal phrases, and contextual relationships extracted for analysis. Transfer learning with pretrained language models was applied, using Ollama embeddings to convert documents into dense vectors for accurate query classification Key evaluation metrics such as accuracy, recall, and F1 score were optimized for improved performance on legal data. In prediction, user queries are embedded using Ollama embeddings and matched with document embedding’s via PyTorch cosine similarity to retrieve relevant documents [20]. OpenAI’s API generates responses, with summarization applied for lengthy texts to ensure concise answers An AI based hybrid retrieval and generation approach was implemented. The legal knowledge

base was built using Ollama embeddings, pretrained models classified intent and extracted legal entities, and query-document matching ensured precise retrieval. OpenAI models generated humanlike responses based on the retrieved content 490 M. K Singh et al Fig. 3 BharatLex model architecture 4 Results Model Evaluation and Comparison: BharatLex: The accuracy of the responses fromBharatLex is very high because it pulls content directlyfrom the official Constitution of India document (PDF), ensuring that the legal text is exactly what is written in the Constitution without any room for errors, interpretation, or omission. ChatGPT: ChatGPT provides generally accurate answers but lacks BharatLex's precision for legal texts. Unlike BharatLex, ChatGPT offers generalized explanations or paraphrased information rather than exact constitutional wording 4.1 Query :- "What is the Preamble of the Indian Constitution?" BharatLex's Answer :BharatLex directly extracts

and displays the verbatim Preamble from the Constitution, declaring India as a Sovereign, Socialist, Secular, and Democratic Republic. It emphasizes justice, liberty, equality, and fraternity, ensuring individual dignity and national unity. The Preamble also references its formal adoption on November 26, 1949, by the Constituent Assembly. ChatGPT's Answer:ChatGPT's response summarizes the Indian Constitution's Preamble, highlighting its principles: Sovereign, Socialist, Secular, and Democratic Republic. It emphasizes justice, freedom, equality, brotherhood, dignity, unity, and the historic adoption date, November 26, 1949 Comparison:BharatLex provides the exact text as extracted from the government. ChatGPT gives almost the same response but begins with an introductory phrase and BharatLex: Custom AI Chatbot for Legal Query-Driven Using RAG 491 uses slightlydifferent formatting. Accuracy:BharatLex: 100% ChatGPT: 98% Response Time:BharatLex: 2.3 seconds ChatGPT: 1.8

seconds Formulas Used:Accuracy (%) Accuracy = (Correct response/Total response)*100 Response Time(%) Average response time = Total Response Time for all queries/Number of queries Table 1 Comparative analysis of proposed model with ChatGPT Metric Recall (%) Accuracy (%) Response Time Methodology BharatLex (Proposed Model) High (~98-99%) ChatGPT Moderate (~85-90%) High (100%) Moderate to High (92-98%) ~2-3 seconds ~1.8-22 seconds Extracts verbatim text Best Use Case Legal research, precise answers Summarizes with context General explanations, simplifiedunderstanding Figure 4 shows comparison of the proposed model BharatLex is ideal for precise, legally accurate responses, while ChatGPT is better suited for simplified explanations. Fig. 4 Evaluation comparison of proposed model with ChatGPT 492 5 M. K Singh et al Conclusion BharatLex is an innovative AI-powered legal assistant designed to simplify complex legal information and make constitutionalknowledge accessible to

all. It empowers individuals to understand their rights and navigate legal challenges while supporting legal professionals with efficient research, document summarization, and information retrieval. Currently, BharatLex achieves an accuracy rate of 9999% in providing legal responses, ensuring high reliability for most queries. Its response time averages 2-3 seconds, offering swift legal insights for users. By incorporating a broader legal database, including case law and localized resources, BharatLex could further improve its accuracy and comprehensiveness. Advanced features like voice-based interactions, personalized assistance, offline accessibility, and mobile deployment would make it invaluable to rural andunderserved communities BharatLex’s transformative potential lies in democratizing access to legal information, bridging digital divides, and empowering more users with legal knowledge. With ongoing refinement and expansion, it could evolve into a comprehensive legal

assistant, setting a benchmark for integrating AI in the legal domain. Disclosure of Interests. Every author states that they have no competing interests in any similar works. Every authors states that no funding from any organization was obtained for this work This article does not contain any studies with animals performed by any of the authors. References 1. Alexander Tobias Neumann, YueYin, Sulayman Sowe, Stefan Decker, Matthias Jarke, “An LLM-Driven Chatbot in Higher Education for Databases and Information Systems”, IEEE Transactions on Education, 2024 2. Patrick Lewis, Ethan Perez, +9 authors DouweKiela, “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks”, Published in Neural Information Processing 22 May 2020 3. Hause Lin, Tawab Safi, “OLLAMA: AN Rpackage FOR RUNNING LARGE LANGUAGE MODELS” 4. Adam, M, Wessel, M, Benlian, A, 2020 “AI-based chatbots in customer service and their effects on user compliance.Electron” Mark 1–19 5. Dilmegani, C, 2021

“Top 30 successful chatbots of 2021 & reasons for their suc- cess”. AI Multiple Available at:https://researchaimultiplecom/top-chatbotsuccess/#industry-specific-chatbots 6. Robinson, S, Orsingher, C, Alkire, L, De Keyser, A, Giebelhausen, M, Papamichail, K N, Shams, P, Temerak, M S,2020 “Frontline encounters of the AI kind: an evolved service encounter framework”. J Bus Res 116, 366–376 7. S K Maher, S G Bhable, A R Lahase and S S Nimbhore, "AI and Deep Learning-driven Chatbots: A ComprehensiveAnalysis and Application Trends," 2022 6th International Conference on Intelligent Computing and Control Systems (ICICCS), Madurai, India, 2022, pp. 994-998, doi: 10.1109/ICICCS5371820229788276 8. Singh, Netra Pal, and Devender Singh "Chatbots and virtual assistant in Indian banks" Industrija 474 (2019) BharatLex: Custom AI Chatbot for Legal Query-Driven Using RAG 493 9. Abdul-Kader, S A, & Woods, J C (2015) "Survey on chatbot design techniques

in speech conversation systems. International Journal of Advanced Computer Science and Applications, 6(7), 72–80 10. G K Vamsi, A Rasool and G Hajela, "Chatbot: A Deep Neural Network Based Human to Machine Conversation Model," 2020 11th International Conference on Computing, Communication and Networking Technologies (ICCCNT), Kharagpur, India, 2020, pp. 1-7, doi: 10.1109/ICCCNT4923920209225395 11. Hildebrand, C, Bergner, A, 2020 “Conversational robo advisors as surrogates of trust: onboarding experience, firm perception, and consumer financial decision making”, J. Acad Market Sci 1–18 12. [online] Available: https://mediumcom/@researchgraph/how-to-run-ollama-onwindows-8a1622525ada 13. S Rozga, "Chat Bot Natural Language Understanding" in Practical Bot Development, Berkeley, CA:Apress, pp 29-46,2018 14. Siddhant Singh and Hardeo K Thakur, "Survey of Various AI Chatbots Based on Technology Used", 2020 8th International Conference on Reliability

Infocom Technologies and Optimization (Trends and Future Directions) (ICRITO), 2020 15. Constitution of India PDFhttps://www.indiacodenicin/bitstream/123456789/16124/1/the constitution of indiapdf 16. Nationalarchicvesnic PDF- https://nationalarchivesnicin/sites/default/files/2023-07/ConstitutionofIndia342pagespdf 17. Wang, B (2024) “Real-Time Data Informed Traffic Analytics Framework Powered by Large Language Model (LLM)” (Master's thesis, University of Washington). 18. Waseem, M, Das, T, Ahmad, A, Fehmideh, M, Liang, P, & Mikkonen, T (2023) “Using ChatGPT throughout the Software Development Life Cycle” by Novice Developers. arXiv preprint arXiv:2310.13648 19. Quevedo, E, Cerny, T, Rodriguez, A, Rivas, P, Yero, J, Sooksatra, K, & Taibi, D (2023). Legal Natural Language Processing From 2015 to 2022: “A Comprehensive Systematic Mapping Study of Advances and Applications” IEEE access, 12, 145286-145317 20. Landgren, M, & Giljegård, O (2024) Real-time

Relevance: RAG with Dynamic Context for Improved Natural Language Responses. 494 M. K Singh et al Open Access This chapter is licensed under the terms of the Creative Commons AttributionNonCommercial 4.0 International License (http://creativecommonsorg/licenses/by-nc/40/), which permits any noncommercial use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made. The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder