Intelligent Query System for Consumer Protection Regulations in Perú Using Hierarchical Vector Databases
摘要
This paper presents the design and implementation of an intelligent query system for the Consumer Protection and Defense Code of Peru (Law No. 29571). The system enables users to ask questions in natural language and receive legally grounded answers. A hierarchical vector database is employed, structured into chapters, subchapters, articles, and content, and indexed using semantic embeddings. The implementation integrates technologies such as ChromaDB with a SQLite backend and a Retrieval-Augmented Generation (RAG) pipeline, leveraging the GPT-4o-mini model, which was selected for its high efficiency and low token consumption. During validation, 60 representative queries were evaluated using the LLM-as-a-Judge technique, with faithfulness and answer relevancy metrics assessed via DeepEval. A comparative analysis among generative models (GPT-4o-mini, Claude 3 Haiku, and GPT-3.5-turbo) revealed that GPT-4o-mini provided the best balance between computational cost and semantic performance . The results confirm the system’s effectiveness in making legal information accessible to users without legal expertise. This approach contributes to the democratization of legal knowledge in everyday scenarios.