RAG in practice: connecting AI to company documents safely
Published 2 Jun 2026, updated 13 Oct 2026 · Oliver Žaigla · 5 min read
Short answer: RAG (retrieval-augmented generation) is a way to show a language model your documents without it learning from them. The documents stay in your infrastructure, the model receives only a few relevant passages with each question, and it backs its answer with a citation. The concern I hear most on consulting calls is "we don't want AI learning from our contracts". It is a fair concern, and RAG is exactly the answer to it.
The model knows nothing, the model reads
RAG separates two things that get mixed up in AI debates: knowledge and the ability to put things into words. The language model provides the second. Knowledge stays in your documents and only reaches the model at the moment of a specific question, as a few paragraphs attached to it.
Picture an excellent assistant who gets a key to your archive. They can find the right page in seconds and explain it clearly, but they never take the archive home.
How it works in five steps
- 1. Preparing the material. Documents are split into meaningful chunks: policy clauses, contract paragraphs, price list rows. Each chunk carries where it came from, its date and who may read it.
- 2. Fingerprints. Each chunk gets a numerical fingerprint of its meaning (an embedding). Chunks and fingerprints sit in a vector database in your infrastructure.
- 3. Retrieval. The user's question is turned into the same kind of fingerprint and the database finds the most similar chunks. For contract numbers, product codes and names, classic full-text search is added, because semantic similarity alone is not enough for exact strings.
- 4. Answer. The model receives the question and the retrieved chunks, with the instruction to answer only from them.
- 5. Citation. Every answer names the document and passage it is based on. When retrieval finds no support, the system answers "this is not in the material" instead of making something up.
Where the data goes: three modes by sensitivity
- An API with no data retention. The fastest start and the lowest cost. The question and retrieved passages pass through the provider's model, which in this contractual mode neither stores nor trains on them.
- A model in your cloud. The language model runs in your own cloud account, typically in an EU region. Data does not leave your environment.
- A model on your premises. An open model on your own hardware. Data never leaves the company, at the price of higher running costs.
I justify the choice in the proposal, based on data sensitivity and budget. Most internal knowledge bases are fine with the first mode, regulated industries go for the second or third.
Why the model does not train on your documents
Training means changing the model's internal weights based on data. That does not happen in a RAG deployment. Documents pass through the model only as input to a specific question, just like pasting text into a translator. Contractually this is covered by no-retention modes, technically by deployments where the model runs on your side.
Permissions: the most common hole in RAG deployments
Retrieval has to filter by the specific user's permissions before the model ever sees the passages. Someone who may not read the payroll policy must not get an answer composed from it either. The safest approach is to inherit permissions from where the documents live today, such as SharePoint, Google Drive or a file server, rather than maintaining them a second time somewhere else.
How to know it works before launch
- A test set. Fifty to a hundred real questions from your operations, each with the expected answer and the document it is in.
- Three measurements. Did the system find the right document? Is the answer factually correct? Does it admit when the answer is not in the material?
- Repetition. The set is rerun after every larger change to the material or the model.
A demo with five questions in a meeting is not proof. Measured accuracy on your own questions is.
When RAG is not enough
- Calculations over tables. Questions like "how much did we invoice company X last year" belong in a database, not in text. They are handled by an agent that can query the system and explain the result.
- A fixed output style or format. Fine-tuning a model can make sense, but only once RAG has proven insufficient.
- Outdated material. RAG mirrors your documents. An outdated policy means an outdated answer, which is why an update process is part of the deployment.
I consider RAG the default architecture for AI over company knowledge, for both security and cost. Training your own model is the exception, not the rule.
A checklist for choosing a vendor
- Where will documents, fingerprints and query logs be stored?
- In what mode will the model run, and does the provider store queries?
- How does the system respect user permissions?
- Does every answer cite a source and admit when it does not know?
- On what set of questions is accuracy measured, and with what result?
- Who owns the code, data and access after handover?
How I build private RAG and what it costs is on the private RAG over company documents page. Whether an agent over your documents pays off, you can work out with Will an AI agent pay off for your business?
Frequently asked questions
Does the language model learn from our documents if we use RAG?+
No. The model only reads the documents as input for a specific question and its weights do not change. With an API, you choose a contractual mode in which the provider neither stores queries nor trains on them.
Does our data have to be in the cloud?+
No. Both the vector database and the language model can run in your infrastructure. It costs more to run, but the data never leaves the company.
How much does private RAG cost?+
With me, from CZK 25,000 depending on scope, and deployment usually takes 4 to 6 weeks. You get an exact price in writing after the intro call.
Can RAG handle scanned PDFs and tables?+
Yes. Scanned documents go through text recognition and tables are processed separately. Scan quality affects accuracy, so I review the material during scoping.