Skip to content
All articles
Fundamentals 9 min read· by Lars Zimmermann

RAG: connecting your company data to a language model

RAG links a language model to your documents. How it works, why permissions are the real construction site and how to audit it under ISO/IEC 42001.

In short

RAG means the system searches your documents for passages that fit each question and passes them to the language model, which answers from them. The model is not retrained. What matters are permissions that apply to every retrieval, a deletion path for the copy in the index and tests with known answers. Hallucinations become rarer but do not disappear.

Auf Deutsch lesen: deutsche Fassung

A scenario, freely chosen. Sales asks the new company assistant about the payment terms of a major customer. The answer comes with a reference: framework agreement, section 7. Correct. A week later, an apprentice asks what people in her department earn. The assistant delivers the salary overview from the HR folder, also with a reference. Also correct. And that is exactly the problem.

The technique behind it is called RAG, retrieval-augmented generation: generating text with a search step in front. It is the usual way to connect manuals, contracts, product data or tickets to a language model. I show how it works, why permissions are the real construction site, what data protection requires, why RAG still invents things and how you audit and evidence the whole setup under ISO/IEC 42001. The terms are explained briefly in the glossary; this article is about the project. As of November 2026.

Search first, then write: how RAG works

The method was described by Lewis and colleagues in 2020. Their starting point was a weakness of large language models: they store knowledge in their parameters but can only access it precisely to a limited extent. Providing provenance for a statement and updating that knowledge were open research problems, the authors wrote. They therefore combined the model with a second store, a searchable index, at the time over Wikipedia. In their tests, the generated texts became more specific, more diverse and more factual than with a model without search.

How a language model breaks text into tokens, where its knowledge comes from and what counts towards the context window:

How a language model works

In operation, this runs in six steps:

  • Select sources: which folders, systems and document types go into the knowledge base.
  • Split: each document is divided into passages.
  • Index: each passage usually gets an embedding, a numerical vector for its meaning, and lands in a vector database together with its source and date. Some systems also use classic keyword search.
  • Search: for each question, the system fetches the most similar passages.
  • Pass on: the question and the passages found go into the model’s context window together.
  • Answer: the model formulates the answer on that basis and, at best, names the references.

Anthropic sums it up briefly in its glossary. The data is retrieved at runtime and passed into the context window with the question, and how well this works depends on the quality of the knowledge base and of the passages retrieved. The model itself remains unchanged. That is exactly what makes RAG attractive for company knowledge. An updated manual is in the next day, a deleted document disappears, and nobody has to retrain a model. Fine-tuning, by contrast, trains the model further on additional data, and what it learns then sits in its parameters.

The term in brief, with security questions and checkpoints:

Glossary: RAG

The real construction site: who may see what

Back to the apprentice. The assistant did nothing wrong. It found what was in its knowledge base. A RAG system is only as discreet as its permissions. And permissions grow over the years. A folder is shared with everyone because it had to be quick, a project drive loses its owner, a sharing link goes to the whole department. As long as nobody searches, this hardly shows. An assistant that searches everything in seconds brings these legacy issues to light.

Microsoft states this openly for its Copilot in Microsoft 365. According to the documentation, the assistant only surfaces organisational data for which the individual user has at least view permissions. The same paragraph contains the task for you: use the permission models, for example in SharePoint, so that the right people have access to the right content. In other words, Copilot sticks to your permissions. If they are too broad, so are its answers.

For your own RAG systems, ISO/IEC 27090:2026 sets the direction. Under its zero trust principles, it states that in RAG every single document retrieval request is authenticated and authorised on its own, even when the application as a whole is authorised (5.3). On model input leaks, the standard recommends aligning the selection of the data added with the usage rights of those who use the system and read its outputs (B.7.1). OWASP, an open community for secure software, gets even more concrete in its list of risks for applications built on language models. According to OWASP, the access boundary belongs inside the search query to the index itself, because a filter applied after the search can already leak hints about other people’s documents, for example through the number of hits. And permissions apply per passage, because a mostly public document can contain a confidential paragraph.

In practice, this means the assistant searches with the permissions of the person asking. A technical account with read access to everything is the wrong approach, even if it simplifies the setup. OWASP cites exactly this pattern as an example of excessive permissions: a tool meant to read the current user’s documents that uses a privileged account with access to all users’ files. ISO/IEC 27001:2022 lists controls in Annex A for controlling access and restricting access to information (5.15 and 8.3). An assistant is simply one more access route.

Data protection: the knowledge base is a copy of your data

Building a knowledge base means copying data. The passages sit in the index, along with their vectors. ISO/IEC 27090 draws a clear conclusion from this: the data in a RAG repository controls the model’s behaviour like training data, so the same security controls apply to it in operation (7.6).

The vectors on their own are no protection either. Morris and colleagues showed in 2023 that 92 per cent of short 32-token inputs can be recovered word for word from text embeddings. OWASP therefore advises treating a leak that only affects embeddings like a leak of the source documents when assessing and notifying it under Article 33 GDPR.

This results in four points I go through before every launch:

  • Data minimisation: only what is necessary for the defined purpose goes into the knowledge base (Article 5(1)(c) GDPR). The entire drive almost never is.
  • Defaults: personal data must not be made accessible by default to an indefinite number of people without the individual’s intervention (Article 25(2) GDPR). An assistant that searches the HR folder for the whole workforce is, in my reading, exactly the case the provision is meant to prevent.
  • Deletion: when a document is deleted or corrected, its passage and vector must follow, otherwise the assistant keeps finding what should no longer exist (Articles 16 and 17 GDPR). OWASP advises deletion within a bounded time and regular reconciliation checks that prove it.
  • Processing on behalf: if a cloud service computes the embeddings or runs the index, every document leaves the house at least once, and you need a contract under Article 28 GDPR. If you want to avoid that, compute locally.

This is my interpretation from practice. For legal advice, please turn to the appropriate professionals.

What language models and search can do on your own computer and where it falls short:

Local AI for SMEs

RAG invents things too: what the measurements show

Providers of legal research tools advertised RAG, some with words such as “hallucination-free”. Magesh, Ho and colleagues checked this in 2024 in a preregistered study. According to their measurements, the AI tools from LexisNexis and Thomson Reuters made up content in 17 to 33 per cent of cases. That is less than GPT-4 as a general-purpose chatbot and a long way from the advertising promise.

For your organisation, the reasons matter more than the rate. There are four, and each has a countermeasure:

  • The search misses. If it finds the wrong passage, the model answers fluently on the wrong basis.
  • The answer is not in the documents. The model then fills the gap from its training, as long as nobody allows it to say “not found”.
  • Old and new versions contradict each other. OWASP describes sources that contradict one another and models that do not replace old knowledge from training with the newly retrieved passages.
  • Someone manipulates the knowledge base. According to OWASP, anyone who can get content into the index can steer what is found for a specific question with just a handful of prepared documents. A single blocker document can be enough for the assistant to say nothing at all on a question. And a document can contain hidden instructions that the model follows (ISO/IEC 27090, 6.9).

The countermeasures are known: answers only with a reference, “not found” as a permitted result, one valid version per document, an incoming check for external content and removing hidden text before indexing, as OWASP recommends. A reference in the answer is still a claim about a source. It is only verified once someone opens it.

Why AI invents facts, what courts have said about it and how to catch it:

AI hallucinations

Auditing and evidencing under ISO/IEC 42001

The word RAG does not appear in ISO/IEC 42001. I counted: “retrieval” occurs exactly once, in the control of documented information. ISO/IEC 27090, by contrast, names RAG explicitly. ISO/IEC 42001 does not need the word. Annex A has its own block on data for AI systems, A.7, and its objective covers the role of data in development, provision and use. For a knowledge base, I translate the five controls as follows; the mapping is my own:

  • A.7.2, data for development and enhancement: a described process for how documents enter the knowledge base, are changed and leave it again, with a responsible person.
  • A.7.3, acquisition of data: a list of the connected sources with a justification of why each one is needed for the purpose.
  • A.7.4, quality of data: requirements such as valid version, owner and review date. The control explicitly names data used to operate the system. In my reading, the knowledge base falls squarely under it.
  • A.7.5, data provenance: source, version and date of ingestion for every passage. OWASP recommends the same for every embedding, adding trust tier and pipeline version.
  • A.7.6, data preparation: defined rules for splitting, cleaning and removing hidden text.

Two life cycle controls come on top. For verification and validation (A.6.2.4), you need a test set: thirty real questions with a known answer and a known reference, including some whose answer is deliberately not in the documents. Two things are measured: whether the search finds the right passage and whether the answer matches the source. The test runs before launch and after every change to sources, splitting or model. In the event logs (A.6.2.8), you record which passages were retrieved for which answer, for whom and with what result.

In the audit, I then make four requests. Show me the list of sources with their owners. Show me the test set and the latest result. Show me, for any answer, which passages were retrieved and that the person asking was allowed to see them. And delete a test document in front of me, then ask the assistant. If it still finds it, that is the first finding.

What you define before launch

The technology is the smaller part. Before the first document is indexed, you define six things:

  • Purpose and questions: what is the assistant for, and which ten questions should it answer reliably?
  • Sources: which folders and systems, with an owner per source. A folder without an owner does not go in.
  • Permissions: clean up before connecting. Searches run with the permissions of the person asking, checked per passage.
  • Versions: one valid version per document, drafts and archives stay out.
  • Deletion path: who deletes, and how do you check that passage and vector are really gone?
  • Test and log: test set, acceptance criterion and a record of every answer with its passages.

Start small, with one source that is maintained and whose permissions are right, such as the quality manual. As the assistant grows, the list grows with it. Which folder in your organisation would show an assistant more today than you would like?

AI projects with your own documents, implemented as tested software, optionally with local AI so that texts and vectors stay in-house:

AI implementation

Primary sources

Share: LinkedIn E-Mail

Frequently asked questions

Do I need to train my own model for RAG?+

No. The model remains unchanged; the matching passages enter the context window at runtime for each question. That is why content can be changed or deleted at any time without anyone retraining.

Does RAG prevent hallucinations?+

It reduces them without preventing them. In a 2024 study, legal research tools using RAG made up content in 17 to 33 per cent of cases. Answers with references, “not found” as a permitted result and a test set with known answers help.

Does Copilot in Microsoft 365 respect my permissions?+

According to Microsoft, Copilot only surfaces data for which the individual user has at least view permissions. It therefore takes over overly broad sharing just the same. Clean up permissions before the rollout.

How do I test whether my RAG system is good enough?+

With a test set of real questions whose answer and reference you know, including some with no answer in the documents. Check whether the search finds the right passage and whether the answer matches the source. Repeat the test after every change to sources, splitting or model.

Author & expert review: Lars Zimmermann · ISO/IEC 42001 Senior Lead Auditor & Senior Lead Implementer · ISO 9001 Senior Lead Auditor · ISO/IEC 27001 Lead Auditor & Lead Implementer (PECB)

An auditor with shop-floor experience and managing director of a manufacturing company, who audits and builds AI management systems and information security. Author of “Stallgeruch” (in German). Verify the credential on Credly · More about me.

Last updated: 02 December 2026. Researched and reviewed to the best of my knowledge. This is my interpretation from practice. For legal advice, please turn to the appropriate professionals.

Questions about your own case?

In a free 15-minute intro call we assess where you stand on ISO 42001, ISO 27001 and the EU AI Act, honestly and without a sales pitch.

Continue reading