Skip to content
Back to insights

RAG · AI integration

RAG for companies: how it works, examples and data protection

A RAG system finds the relevant passages in your documents and has a language model answer from them, with sources. How it works, examples, limits, GDPR.

Updated 10 min readResponsible: Mehdi Bornak

A RAG system (retrieval-augmented generation) searches your own documents for relevant passages before every answer and hands them to a language model. The model then answers on the basis of that evidence and can cite the source, without being retrained. RAG fits when internal knowledge has to be current, verifiable and accessible only to people with the right permissions. It reduces hallucinations, but cannot rule them out.

What is a RAG system?

A RAG system connects a language model to a search over your own data. OpenAI sums up the principle in one sentence: retrieve content to augment the model’s prompt before generating an answer.

Put simply, RAG is an open-book exam. Without RAG, a language model can only answer from what it learned in training. With RAG, it may look up the right chapter before every answer, in your manuals, policies or tickets rather than on the internet. OpenAI uses exactly this picture of a textbook on the desk in its guide to model accuracy.

RAG models were introduced in a research paper by Patrick Lewis and colleagues, submitted in May 2020 and accepted at the NeurIPS 2020 conference. The authors named two open problems of pure language models: they struggle to show where a statement comes from, and their knowledge is hard to update. Their solution combined the knowledge stored in the model with a searchable vector index, at the time built over Wikipedia.

Germany’s data protection authorities (Datenschutzkonferenz, DSK) describe a RAG system in their October 2025 guidance as a system whose core consists of a retriever, an embedding model, a vector database and a generative language model. One point matters in particular: the augmented request is rebuilt from the data source for every question and does not change the language model. New or changed documents can therefore be retrieved once indexed, with no training involved.

How does a RAG system work?

A RAG system works in two phases: documents are prepared and indexed up front and whenever they change; for every question, the system searches, augments and answers.

Phase 1: prepare and index documents

  1. Clean up: convert documents to running text and remove clutter such as headers, footers and page numbers. Remove or anonymise personal data that the purpose does not require.
  2. Chunking: split texts into sections (“chunks”). Rigid chunks with a fixed character count can tear context apart; chunks that each contain a complete unit of meaning work better. For comparison, OpenAI splits files in its vector stores into 800-token chunks with a 400-token overlap by default.
  3. Embeddings: an embedding model turns each chunk into a vector of numbers that represents its meaning. For German documents, the DSK recommends a model trained on German text; otherwise the search matches fewer relevant passages.
  4. Store: vectors, original text and metadata such as source, date and permissions go into the vector database.

Phase 2: search, augment, answer

  1. Encode the question: the question is turned into a vector with the same embedding model.
  2. Search: the retriever finds the chunks closest in meaning. Because embeddings can miss exact matches such as product numbers or error codes, hybrid search adds classic keyword search to vector search.
  3. Re-rank: a re-ranking step scores the hits again by meaning; a threshold keeps out passages with low relevance.
  4. Answer: the best hits go to the language model together with the question and the instruction to answer only from these sources and to cite them.

An example from Anthropic shows how much depends on tuning the retrieval step: with “Contextual Retrieval”, where every chunk gets a short explanation of its place in the document before indexing, failed retrievals fell by 49 percent in Anthropic’s tests, and by 67 percent when combined with re-ranking.

Is ChatGPT a RAG system?

Not in itself, but ChatGPT uses the RAG principle whenever it looks things up. ChatGPT has its own web search; when it uses it, search results and citations appear in the chat. In ChatGPT projects, chats can also draw on uploaded files and connected sources. Without such tools, the model answers from its training knowledge.

A RAG system for your company goes further: it searches the collections you choose, enforces your permissions and can be tested, updated and cleaned up in a targeted way. Web search is no substitute. The DSK notes that the requirements for lawfulness, suitability and accuracy of external sources are regularly not met when web search is included.

What RAG systems are there?

RAG systems differ mainly in who runs the search and how much you control yourself. Four routes, with examples from official documentation as of 4 November 2026:

TypeExamplesA good fit when …
Built-in RAG feature from the model providerOpenAI file search: files in a vector store are automatically chunked, embedded and indexed; search combines semantic and keyword search.you need a quick prototype over a manageable set of files
Search and RAG service on a cloud platformAzure AI Search (classic RAG with hybrid search and semantic ranking, plus “agentic retrieval” in preview), Google Agent Search and RAG Engine on the Gemini platformdata comes together from SharePoint, databases and storage, and permissions should carry over
FrameworksLlamaIndex, LangChaina development team builds the pipeline itself and connects it to your systems
Self-hosted systemopen embedding models such as BGE-M3 (more than 100 languages, inputs up to 8,192 tokens, MIT licence), your own vector database, your own or a hosted language modeldata should stay in-house; according to the DSK, a RAG system can under certain circumstances run entirely on-premise

RAG systems also differ by method. Alongside the classic pattern of hybrid search and ranking, there is agentic retrieval, where a language model breaks complex questions into several targeted sub-queries. And not every RAG system needs vectors: the DSK also mentions implementations based on API queries or classic database access.

RAG system examples: when is it worth it, and when not?

RAG is worth it when the answer is in your documents but people need time to find it, and when it must be clear where the answer comes from. Typical examples:

  • Internal knowledge base: staff ask about policies in their own words. Microsoft gives a typical example: someone asks about time-off rules for remote workers, but the documents use different terms. Pure keyword search fails here; a search by meaning finds the passage.
  • Technical support: service staff look up error codes and fixes in manuals and tickets. This is where hybrid search pays off, because a code like “TS-999” has to be found exactly.
  • Customer service with evidence: answers based on knowledge-base articles, with a link to the source, so staff can check before sending.

RAG is not always the best choice. Anthropic wrote in 2024 that a knowledge base under 200,000 tokens, about 500 pages, can simply go into the prompt in full, without RAG. According to the DSK, semantic search can miss complex if-then chains across long passages, because the related passages are not close enough in meaning. For analyses across many records, a query over structured data can be a better fit. The DSK itself names another approach: agents that send several search requests in turn. How such agents work is covered in AI agents: what they do and how to build one safely.

RAG or fine-tuning: do you need to train your own AI?

For questions about your company knowledge, you usually do not need to train your own AI. RAG gives an existing model the relevant passages with every request; fine-tuning changes the model itself. The DSK quotes Fraunhofer IESE as saying that fine-tuning should not be used to teach a language model knowledge.

RAGFine-tuningEverything in the prompt
What happensRelevant passages are supplied with every requestThe model is trained further on examplesThe entire knowledge base is part of every request
Good forknowledge that changes and has to be backed upconsistent behaviour, format or style; the same accuracy with a smaller modelsmall knowledge bases
Updating and deletingchange or delete the document or database entryrequires retrainingswap the text
Citing sourcesyes, if the passages used are recordednoonly if the model names them

The two are not mutually exclusive. OpenAI describes how fine-tuning and RAG can come together in a production solution: fine-tuning for consistent behaviour, RAG for recent and specialised knowledge. For fine-tuning, OpenAI recommends starting with at least 50 good examples. At the same time, OpenAI notes that many of its largest customer deployments were built with prompt engineering and RAG alone.

How do you build a RAG system yourself?

You build your own RAG system in eight steps, from a list of questions to ongoing operation. The steps draw on the DSK guidance and on documentation from OpenAI, Microsoft, Anthropic and OWASP.

  1. Define the use case and test questions: collect real questions from your users with the expected answers and sources. This list becomes your yardstick.
  2. Select and clean sources: include only trustworthy documents that are current and complete. The DSK advises against using documents from unknown or untrustworthy sources and calls for regular checks of the reference documents.
  3. Choose a chunking approach: start with sections that capture whole units of meaning, then adjust size and overlap against your test questions.
  4. Choose an embedding model: one that covers the language of your documents well, for example a multilingual model.
  5. Map permissions: users and agents may only retrieve content they are authorised to see. Store group or user identifiers as metadata and filter the results on every search, as Azure AI Search does with security filters, for example.
  6. Combine search methods: pair vector search with keyword search, re-rank the hits and set a relevance threshold.
  7. Instruct the answer: state in the system prompt that answers come only from the sources supplied, that every statement gets a source and that “not found” is an acceptable answer.
  8. Test and operate: look for errors separately: did the search return the right passage, or did the model do the wrong thing with the right passage? OWASP recommends checking answers for context relevance, groundedness and answer relevance. New, changed and deleted documents flow into the index continuously.

How such an assistant connects to your CRM, ticketing system or document storage is covered in integrating AI into existing business systems.

Data protection and security: what do you need to consider?

RAG can improve data protection, but it does not replace an assessment. Germany’s data protection authorities (DSK) published dedicated guidance on it in October 2025. Its key points:

  • Accuracy: RAG can reduce hallucinations and inaccurate output, but cannot rule them out completely. With contradictory content, the model may even prefer its training knowledge.
  • Access and purpose: role and permission concepts can be enforced in the vector database and on the reference documents, but not inside the language model. Purpose limitation can be implemented technically by separating data sets.
  • Deletion and access requests: entries in the vector database are directly addressable and can therefore be deleted selectively. For data subject rights inside the language model itself, the DSK considers the problem largely unsolved.
  • Legal basis: a RAG system needs a legal basis too, and RAG does not make an unlawfully trained model lawful.

If parts of the system run with a service provider, the DSK notes that further questions arise; for processing personal data on your behalf, you need a contract under Article 28 GDPR. The hosting options for the language model, from EU cloud to your own hardware, are compared in GDPR-compliant AI: EU cloud, hybrid or own hardware?

Security deserves attention too. OWASP describes a case in which an attacker modifies a document in the knowledge base and thereby manipulates the answers. Countermeasures are vector stores with fine-grained permissions, strict separation of data sets and regular checks of the knowledge base for injected content.

Conclusion: retrieval first, then the model

Whether a RAG system holds up in daily use depends less on the language model than on clean documents, good search, correct permissions and honest testing with real questions. Get these foundations right and you get answers with sources instead of guesswork. RAG assistants that answer from your company data with source citations are part of our AI integration service.

Sources

  1. Orientierungshilfe zu datenschutzrechtlichen Besonderheiten generativer KI-Systeme mit RAG-Methode, Version 1.0 (guidance on data protection aspects of generative AI systems using RAG, in German) – Datenschutzkonferenz (DSK), October 2025
  2. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks – Patrick Lewis et al., arXiv, 2020 (version 4, April 12, 2021)
  3. Optimizing LLM Accuracy – OpenAI API documentation, accessed November 4, 2026
  4. Retrieval – OpenAI API documentation, accessed November 4, 2026
  5. Retrieval-augmented generation (RAG) in Azure AI Search – Microsoft Learn, updated August 4, 2026
  6. Introducing Contextual Retrieval – Anthropic, September 19, 2024
  7. LLM08:2025 Vector and Embedding Weaknesses – OWASP Gen AI Security Project, accessed November 4, 2026
  8. Web search – ChatGPT documentation, OpenAI, accessed November 4, 2026

Responsible

Mehdi Bornak, AI Manager (IHK)

Mehdi Bornak is the owner of Rocket-Monkeys and an IHK-certified AI manager. Rocket-Monkeys was founded in 2022 and builds custom software and AI solutions for companies.

More about us

Frequently asked questions

Frequently asked questions

01What is a RAG system?

A RAG system (retrieval-augmented generation) connects a language model to a search over your own documents. For every question it first finds relevant passages, passes them to the model and has it answer on that basis, ideally with a source. At its core it consists of a retriever, an embedding model, a vector database and a language model. The model itself is not changed; new documents can be retrieved once indexed.

02Is ChatGPT a RAG system?

Not in itself, but ChatGPT uses the RAG principle when it looks things up: with its built-in web search, search results and citations appear in the chat, and in projects, chats draw on uploaded files and connected sources. A RAG system for your company goes further: it searches selected internal collections, enforces your permissions and can be tested, updated and cleaned up in a targeted way.

03How can I build a RAG system myself?

Start with a list of real questions and their expected answers. Then select and clean your sources, split the texts into meaningful sections, choose an embedding model that handles your language and store vectors with text and metadata. Add permissions as filters in the search, combine vector and keyword search, and instruct the model to answer only from the sources. Finally, test retrieval and answers separately.

04What RAG systems are there?

There are four routes: built-in RAG features from model providers such as OpenAI file search, search and RAG services on cloud platforms such as Azure AI Search or Google Agent Search, frameworks such as LlamaIndex and LangChain for your own pipelines, and self-hosted systems with open embedding models and your own vector database. Methods range from the classic pattern of hybrid search and ranking to agentic retrieval with several sub-queries.

Let’s talk about your project.

20 minutes, free and without obligation – with a person from the team.