RAG explained: how an AI answers from your documents and cites its sources
An AI model does not know your documents. The RAG technique lets it answer from them, and cite its sources.
The problem: a model does not know your documents
A language model has been trained on large amounts of public text. It knows neither your internal procedures, nor your contracts, nor your files. Asked about them, it may invent an answer that is plausible but wrong. This is called a hallucination.
The idea behind RAG
RAG stands for retrieval-augmented generation. The principle works in two stages. First, the relevant passages are retrieved from your documents. Then the model is asked to write an answer based on those passages. The model no longer answers from memory: it has the useful extracts in front of it.
The five steps
- The documents. PDF, Word, Excel, sometimes scans.
- Extraction. The text and tables are retrieved. Scanned documents go through optical character recognition (OCR). The quality of this step determines everything else.
- Indexing. Each passage is converted into a numerical representation of its meaning, called an embedding, then stored in a database. This database sits within your perimeter.
- Retrieval. For each question, the system finds the passages whose meaning is closest, then reorders them by relevance (re-ranking).
- The answer. The model writes from these passages and cites its sources, so that the user can check.
Why cite sources
A citation turns a statement into verifiable information. The user opens the passage, reads the context and decides. It is also a safeguard: an answer without a solid source should prompt caution.
What RAG does not do
- It does not eliminate errors, it reduces them. A misinterpreted passage produces a wrong answer.
- It does not correct your documents. Outdated or contradictory files produce outdated or contradictory answers.
- It does not replace human review, especially for decisions that affect people.
- It does not manage access rights on its own. Each user must only find the documents they are allowed to see.
Five questions to ask before you start
- Which documents, and are they up to date? A clean knowledge base is better than a complete one.
- Who is allowed to see what? Permissions must follow the documents.
- Where do the model and the index run? On your premises, or on servers in Europe under contract. Involve your data protection officer from the outset.
- How do you measure quality? Prepare a list of real questions with the expected answer, and test before deployment.
- What happens when the answer falls short? Someone has to correct the document base.
See the assistant on your documents
A demonstration of about 30 minutes shows what the tool produces on documents similar to yours.
Further reading
The ROI of an AI project: why you should not add up budget, time freed up and risk avoided
A single ROI figure often mixes three different realities. Separating them makes the decision more honest.
Read the article →Automate, yes, but what? A method for choosing the first 5 use cases
Not every repetitive task deserves to be automated. Here is a simple method for identifying the ones that deliver the most for the effort required.
Read the article →Preparing an AI project?
Tell us about your use case: we will tell you whether it justifies a pilot.