Retrieval-augmented generation, or RAG, is a way of making an AI model answer from your own documents. Before it answers, the system searches your files for the passages that matter and hands them to the model with the question. The model then writes its answer from those passages and can point to where each part came from.
Planning a first AI project? Get our free guide by email.
How RAG works
- Prepare. Your documents are split into short passages and indexed so they can be searched by meaning, not only by exact words.
- Retrieve. When someone asks a question, the system finds the passages most related to it.
- Generate. A large language model receives the question and those passages, and writes an answer based on them.
The method was described in 2020 by researchers at Facebook AI Research, University College London and New York University.
Why businesses use it
- Answers about your company. Policies, contracts, product manuals and past cases, which a general model has never seen.
- Up to date without retraining. Change a document and the next answer uses the new version.
- Answers you can check. Each answer can show its source passages, which reduces hallucinations and makes the rest easier to spot.
Where it goes wrong
- Bad documents, bad answers. Outdated or contradictory files are retrieved as faithfully as good ones.
- Missed passages. If the search does not find the right passage, the model may answer from general knowledge instead.
- Access rights. A RAG tool must not show a user a document they are not allowed to open, and GDPR applies to personal data in the files.
Before you start
Pick one set of documents with a clear owner, such as the HR policy handbook, and twenty real questions people ask about it. Measure how many the tool answers correctly with the right source before you widen it.
Planning a document AI project
Our guide covers which project to start with, what to check in your data, what the law already requires, and how to measure results honestly.
The AI-first business: 10 decisions to make before, during and after your first AI project, with worked tools and a one-page checklist. 18 pages, sent as a PDF by email. See what is inside.
Sources
- Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks", NeurIPS 2020.
Found an error? Tell us and show your working — we correct in place and record what changed. Contact us.