RAG (retrieval-augmented generation) lets a language model answer based on your own documents. For each question the system first retrieves the relevant passages and passes them to the model, which answers with source references. You don't need to train the model, information is current immediately and you can decide per user which documents are included.
A language model knows a lot, but nothing about your organisation. It does not know your contracts, your manuals or your customer files. And when it does not know something, it sometimes makes up a convincing-sounding answer. RAG largely solves both problems.
How RAG works
The term comes from a 2020 paper by Meta AI. The principle is simple: instead of having the model remember everything, you give it the right information with every question.
- Preparation. Your documents are split into chunks and converted into embeddings: series of numbers that capture the meaning. These go into a vector database.
- Retrieval. For a question, the system finds the chunks that best match in meaning, often combined with ordinary keyword search.
- Answering. The model receives the question and the retrieved passages, and formulates an answer with references to the sources.
Why not just train a model on your data?
Training or fine-tuning sounds logical, but it has drawbacks:
- it is expensive and has to be redone with every change in your documents;
- you cannot see where an answer comes from;
- you cannot apply permissions per user: whatever is in the model, anyone can get out;
- removing data, for example at a customer's request, is practically impossible.
With RAG your documents remain the source. Change a document and the next answer is up to date. Remove a document and it no longer takes part. Fine-tuning is mainly useful to steer the style or format of answers, not to add knowledge.
What to watch for
Permissions per user. An employee must not see more through the AI than they may see without it. Carry over the permissions from the source system and filter during retrieval, not only when displaying.
Quality of the sources. RAG is as good as your documents. Outdated versions, duplicate files and contradictory information produce confusing answers. A clean-up round beforehand pays off.
Chunking documents. Chunks that are too small miss context, chunks that are too large dilute the meaning. Tables, scans and forms need their own approach.
Enforcing source references. Have the model answer only on the basis of the retrieved passages and cite the source. If nothing relevant was found, "I don't know" is the right answer.
Security. The OWASP Top 10 for LLM applications lists vector and embedding weaknesses as a separate risk: data leaking between users, or documents with hidden instructions that mislead the model. So treat documents from outside, such as customer emails, as untrusted input.
Typical applications
- an internal assistant for policies, procedures and manuals;
- service desk and customer service looking up answers in knowledge bases and tickets;
- searching contracts or files for specific clauses;
- technical documentation for engineers, including logs and changes.
RAG and privacy
Because the model is not trained on your data, and because you filter per user, RAG fits well with the GDPR. If you run it all on your own language model, your documents do not leave your own environment at all.
Want to know what this could mean for your documents? See our approach to private AI and integrations with your systems.
Frequently asked questions
How many documents can RAG handle?
From a few hundred to millions. The retrieval layer scales well. The challenge lies mainly in quality and permissions, not volume.
Does a model with RAG never make things up anymore?
The risk becomes much smaller, but not zero. Source references and the instruction to answer only from the retrieved passages make checking easy.
Which sources can you connect?
Almost anything with text: files, intranet, wiki, ticketing systems, email, CRM and databases. Through integrations they stay up to date automatically.
Sources
Consultant in cybersecurity, AI integration and cloud & infrastructure, and how the three work together.