Skip to Content
  • Proceeding Paper
  • Open Access

30 November 2026

5 Pages

RAG-Enhanced Chatbot for Information Security and Quality Standards Compliance †

,
and
1
Department of Computer Systems and Telematics Engineering, School of Industrial Engineering, Universidad de Extremadura, 06006 Badajoz, Spain
2
Department of Graphical Expression, School of Technology, Universidad de Extremadura, 10003 Cáceres, Spain
3
Department of Computer Systems and Telematics Engineering, School of Technology, Universidad de Extremadura, 10003 Cáceres, Spain
*
Author to whom correspondence should be addressed.

Abstract

Interpreting and applying information security standards such as ISO/IEC 27001 remains a knowledge-intensive task prone to error. This paper presents caliRAG, a locally deployed conversational assistant leveraging Retrieval-Augmented Generation (RAG) to answer compliance queries grounded in a curated corpus of 3376 normative segments drawn from 20 ISO standards. The system combines PostgreSQL/pgVector for vector storage, SentenceTransformers for semantic embedding, and locally served large language models via LMStudio. The pipeline is evaluated across five normative questions using two models, Llama 3 8B Instruct and Ministral 3 8B Reasoning, which act both as generators and as cross-model evaluators, and a parameter comparison over retrieval depth (k = 5, k = 10) indicates that broader context tends to improve response quality, although the effect depends on the model and the query. The fully local architecture ensures data sovereignty for organizations.

1. Introduction

Information security governance is underpinned by a dense framework of international standards, with ISO/IEC 27001:2022 [1] alone specifying 93 controls across four thematic domains. Security auditors and compliance managers must cross-reference multiple standards, map controls to business processes, and produce documented evidence, a knowledge-intensive workflow that is both costly and error-prone.
Large language models (LLMs) offer a compelling opportunity to assist this work through natural language interaction, and fine-tuned variants have shown promise across domains such as cybersecurity, medicine, and legal reasoning [2,3,4,5,6,7]. However, unaugmented LLMs hallucinate clause numbers and invent control identifiers, failures that are unacceptable in regulated environments. Retrieval-Augmented Generation (RAG), formalized by [8], addresses this by grounding responses in retrieved document segments. Nevertheless, RAG systems introduce retrieval entropy [9] and generation entropy [10], and controlling both is essential in compliance-critical settings.
This paper presents caliRAG, a fully local RAG chatbot specialized in ISO quality and information security standards, with a focus on ISO/IEC 27001 [1] compliance queries. The core contribution is an open, reproducible architecture combining a pgVector semantic store, a SentenceTransformer embedding model, and a locally served LLM into a single auditable pipeline that grounds every response in verifiable normative segments. To validate the system, we evaluate the pipeline across five normative questions using Llama 3 8B Instruct and Ministral 3 8B Reasoning as both generators and cross-model evaluators, and measure the impact of retrieval depth through a parameter comparison over k ∈ { 5 , 10 } .

2. System Architecture

caliRAG is structured in four loosely coupled layers. The document corpus comprises 20 ISO standards [11] (ISO 9000, 9001, 9004, 10002, 10003, 10005, 10006, 10007, 10012, 10013, 10014, 10015, 10017, 10019, and 19011, and ISO/IEC 9126-1, 90003, 12207, 15288, and 15504) preprocessed into 3376 JSON segments averaging approximately 700 characters each, with boundaries aligned to clause structure. Although the system targets ISO/IEC 27001 compliance, the evaluation uses a broader set of ISO quality and audit standards to stress-test the pipeline across diverse normative domains. The vector store is built on PostgreSQL 18 with the pgvector extension, where each segment is encoded using sentence-transformers/all-MiniLM-L6-v2 [12] (384 dimensions). The retrieval and prompt builder embeds the user query, retrieves the top-k nearest segments by exact Euclidean distance search, which is equivalent to cosine-similarity ranking for these normalized embeddings and runs in under a second at this corpus size, and assembles a structured four-part prompt covering role instructions, normative context, the user query, and output and hallucination guard instructions. Finally, the language model layer runs Llama 3 8B Instruct or Ministral 3 8B Reasoning locally via LMStudio, exposed on an OpenAI-compatible endpoint. The full pipeline is illustrated in Figure 1.
Figure 1. caliRAG RAG pipeline. ISO documents are converted from PDF to text, segmented into JSON chunks, and encoded into a pgVector database. On each user query, the RAG retriever fetches the most relevant normative segments, which are injected into a structured prompt consumed by a locally served LLM via LMStudio.
A FastAPI backend exposes three endpoints, namely /query for single-turn RAG queries, /chat for multi-turn conversations with RAG applied to the latest user message, and /upload_docs for dynamic PDF ingestion with automatic segmentation and embedding. A Streamlit frontend provides a chat interface with retrieved-fragment inspection and a document upload panel. The entire stack runs on an Apple M4 Pro with 24 GB of RAM without any internet access, ensuring full data sovereignty.
A key design decision is the structure of the prompt assembled by the retrieval and prompt builder. Rather than appending retrieved segments as raw context, the prompt is organized into four explicit blocks. The first sets the role of a technical ISO compliance assistant. The second contains the recovered normative fragments with their source norm and clause identifier, declared as the only valid source. The third presents the user query. The fourth defines the expected four-part output structure, covering normative summary, technical explanation, normative citations, and practical observations, together with hallucination guard instructions that forbid the model from citing clauses or identifiers not present in the retrieved fragments and require it to state explicitly when no normative reference is available. This structured design is intended to obtain consistent, auditable responses across both evaluated models.

3. Evaluation

Evaluation was conducted by posing five normative questions to the system. The questions covered quality management system requirements under ISO 9001 (Q1), auditor competence criteria under ISO 19011 (Q2), continuous improvement approaches comparing ISO 9004 and ISO/IEC 15504 (Q3), implications of uncalibrated measurement equipment under ISO 10012 (Q4), and multi-standard audit non-conformity handling under ISO 9001 and ISO 19011 (Q5). Although the system targets ISO/IEC 27001 compliance, the evaluation uses a broader set of ISO quality and audit standards to stress-test the pipeline across diverse normative domains. The retrieval depth parameter k controls how many normative segments are retrieved from the pgVector store for each query and injected into the prompt. The pipeline was evaluated with k ∈ { 5 , 10 } for Llama 3 8B Instruct (L3) and Ministral 3 8B Reasoning (MM), both served locally with temperature 0 and a limit of 6000 generated tokens per call. Each response was rated by both models, so that every output received a cross-model rating and a self-assessment. Table 1 reports the cross-model ratings, which avoid self-assessment bias. Evaluators received the question and the response, with the reasoning trace of Ministral removed, and were asked to assign a single overall rating on a five-level ordinal scale (Very Low to Very High), considering normative accuracy, clarity and structure, practical usefulness, and coherence with the question. The rating was returned in JSON together with a short justification.
Table 1. Cross-model evaluation scores by generator model and retrieval depth. L3 = responses of Llama 3 8B Instruct rated by Ministral 3 8B Reasoning; MM = responses of Ministral 3 8B Reasoning rated by Llama 3 8B Instruct.
Under cross-model evaluation, increasing k from 5 to 10 improved the rating of Llama 3 responses in Q2 and Q3 and left Q1 unchanged. In Q4 and Q5, no cross-model rating was obtained at k = 10 because the Ministral evaluator exceeded the token limit while reasoning. The self-assessment ratings showed the same trend more clearly, with Llama 3 rating its own k = 10 responses higher than its k = 5 responses in Q3, Q4 and Q5. Ministral responses were rated High by Llama 3 in nine of ten cases, with a single drop to Medium in Q3 at k = 10 , which suggests that additional, partly noisy segments can distract the model on comparative queries. The two evaluators behaved differently. Llama 3 used a narrow range of the scale (Medium to High), whereas Ministral was more generous and, where both ratings are available, rated its own responses equal to or higher than Llama 3 did, which illustrates the self-preference bias that motivates cross-model evaluation. Ministral was also less reliable as an evaluator, failing to produce a rating within the token budget in three of twenty evaluations, all of them on the multi-standard questions Q4 and Q5. Given the small number of questions and a single run per configuration, these results should be read as indicative trends rather than statistically significant differences, and they suggest that retrieval depth should be tuned per model.

4. Conclusions

Increasing retrieval depth from k = 5 to k = 10 tended to improve the responses of Llama 3, while its effect on Ministral was neutral or slightly negative, so retrieval depth should be tuned per model. The fully local deployment resolves data sovereignty concerns that prevent cloud AI adoption in security-sensitive contexts. Dynamic PDF ingestion via /upload_docs allows organizations to extend the corpus with internal artifacts such as risk registers, statements of applicability, and audit reports, enabling personalized compliance assistance without retraining.
caliRAG shows that locally deployed RAG systems can provide structured, normatively grounded responses to compliance queries on commodity hardware. The open-source architecture combining pgVector, SentenceTransformers, LMStudio, FastAPI, and Streamlit extends naturally to ISO/IEC 27001, GDPR, and other regulatory frameworks. Future work will incorporate a larger question set with repeated runs, automated metrics, larger-context models such as Llama 3.1 70B and human evaluations.

Author Contributions

F.B.: conceptualization, methodology, software, validation, investigation, data curation, writing—original draft preparation. A.C. (Aurora Cuartero): writing—review and editing. A.C. (Andrés Caro): conceptualization, validation, writing—review and editing, supervision, project administration, funding acquisition. All authors have read and agreed to the published version of the manuscript.

Funding

This initiative is carried out within the framework of the funds of the Recovery, Transformation and Resilience Plan, financed by the European Union (Next Generation), National Cybersecurity Institute (INCIBE), through the C109/23 UEx Strategic Project (School of Technology), INCIBE.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The source code is available at GitHub (https://github.com/fbroncano/caliRAG, accessed on 26 November 2026).

Acknowledgments

During the preparation of this manuscript, the authors used Claude (Anthropic, accessed April 2026) for drafting and language editing, and DeepL for Spanish-to-English translation. Llama 3 8B Instruct and Ministral 3 8B Reasoning were used as components of the system under study, as described in the System Architecture and Evaluation sections. The authors have reviewed and edited the output and take full responsibility for the content of this publication.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. ISO/IEC 27001:2022; Information Security, Cybersecurity and Privacy Protection—Information Security Management Systems—Requirements. International Organization for Standardization: Geneva, Switzerland, 2022.
  2. Allani, S.; Bou-Chaaya, K.; Rais, H. ELISAR: A Multi-Agent cybersecurity framework integrating retrieval-augmented generation for Blue, Red, and GRC operations. World Wide Web-Internet Web Inf. Syst. 2025, 29, 3. [Google Scholar] [CrossRef] [Scilit]
  3. Cerqueira, J.A.S.D.; Khan, A.A.; Rousi, R.A.; Xi, N.; Hamari, J.J.; Kemell, K.K.; Abrahamsson, P. Grounded Ethical AI: A Demonstrative Approach with RAG-Enhanced Agents. In Proceedings of the CEUR Workshop Proceedings; CEUR-WS Team: Aachen, Germany, 2025; Volume 3921. [Google Scholar]
  4. Torrecilla-Pinero, J.A.; Cuartero, A.; Cáceres-Merino, J.; Amores-Chaparro, V.; Broncano, F. Machine learning correction of C2-Net for chlorophyll-a retrieval in optically complex small reservoirs. Int. J. Appl. Earth Obs. Geoinf. 2026, 152, 105415. [Google Scholar] [CrossRef] [Scilit]
  5. Singhal, K.; Azizi, S.; Tu, T.; Mahdavi, S.S.; Wei, J.; Chung, H.W.; Scales, N.; Tanwani, A.; Cole-Lewis, H.; Pfohl, S.; et al. Large language models encode clinical knowledge. Nature 2023, 620, 172–180. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  6. Broncano-Morgado, F.; Cuartero, A.; Rodríguez, P.G.; Plaza, A. Analysis of the movement of permanent GNSS stations in Spain with directional statistics. Sci. Rep. 2026, 16, 11295. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  7. Guha, N.; Nyarko, J.; Ho, D.E.; Ré, C.; Chilton, A.; Narayana, A.; Chohlas-Wood, A.; Peters, A.; Waldon, B.; Rockmore, D.N.; et al. LEGALBENCH: A collaboratively built benchmark for measuring legal reasoning in large language models. In Proceedings of the 37th International Conference on Neural Information Processing Systems, New Orleans, LA, USA, 10 December 2023. [Google Scholar]
  8. Lewis, P.; Perez, E.; Piktus, A.; Petroni, F.; Karpukhin, V.; Goyal, N.; Küttler, H.; Lewis, M.; Yih, W.T.; Rocktäschel, T.; et al. Retrieval-augmented generation for knowledge-intensive NLP tasks. In Proceedings of the 34th International Conference on Neural Information Processing Systems, NIPS ’20, Red Hook, NY, USA, 6 December 2020. [Google Scholar]
  9. Wang, H.; Zhang, D.; Li, J.; Feng, Z.; Zhang, F. Entropy-Optimized Dynamic Text Segmentation and RAG-Enhanced LLMs for Construction Engineering Knowledge Base. Appl. Sci. 2025, 15, 3134. [Google Scholar] [CrossRef] [Scilit]
  10. Shi, F.; Chen, X.; Misra, K.; Scales, N.; Dohan, D.; Chi, E.; Schärli, N.; Zhou, D. Large language models can be easily distracted by irrelevant context. In Proceedings of the 40th International Conference on Machine Learning, ICML’23, Honolulu, HI, USA, 23 July 2023. [Google Scholar]
  11. International Organization for Standardization (ISO). ISO Standards Catalogue. Available online: https://www.iso.org/standards-catalogue/browse-by-ics.html (accessed on 26 November 2026).
  12. Reimers, N.; Gurevych, I. Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks. In Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing, Hong Kong, China, 3 November 2019. [Google Scholar]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.