Quintessentia Network logo QuintessentiaNetwork Inc.
AI basics

What is RAG? Retrieval-augmented generation, explained

The short answer

RAG, retrieval-augmented generation, is a way of getting an AI model to answer from your own documents instead of from memory. When someone asks a question, the system first searches your documents for the passages most likely to hold the answer, then hands those passages to the model with the question and asks it to answer from them, ideally citing which passage says what.

Binders and highlighted documents beside a laptop showing a chat answer whose citation markers link to document pages
Illustration (AI-generated): an answer drawn from your own documents, each claim pointing back to its source.

The name comes from a 2020 research paper, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks by Patrick Lewis and colleagues. The idea has since become the standard way businesses build AI assistants over their own policies, contracts, manuals and files.

Why plain AI models need it

A language model on its own knows only what was in its training data. It has never seen your price list, your procedures manual or last month's policy change, and when asked about them it may produce a confident answer that is simply wrong. RAG addresses both problems at once: the model is given the relevant text at the moment of the question, so it can answer from your current documents, and its answer can point back to the passage it came from so a person can check it.

How RAG works, step by step

  1. Collect the documents. Policies, contracts, manuals, tickets, wiki pages: whatever the assistant should answer from.
  2. Split them into passages. Long documents are cut into smaller pieces, ideally along their own structure (sections, headings, table rows) rather than at an arbitrary number of words.
  3. Index the passages. Each passage is turned into a numerical representation of its meaning (an embedding) and stored so it can be found by meaning, often alongside an ordinary keyword index so exact terms such as product codes are not missed.
  4. Retrieve at question time. The question is matched against the index and the most relevant passages are pulled back, often re-ranked in a second pass for precision.
  5. Apply permissions. Passages the person asking is not allowed to see are removed before the model ever sees them.
  6. Generate the answer from the retrieved passages, with a citation for each claim, and say "I don't know" when the passages do not contain the answer.
  7. Keep the index current. When documents change, the affected passages are re-indexed, or the assistant answers from yesterday's version.

RAG compared with the alternatives

RAGFine-tuningA bigger prompt
What it doesFinds the relevant passages and gives them to the model at question timeTrains the model further on your examplesPastes whole documents into every request
Good forAnswering from many documents that changeTeaching a style, a format or a narrow taskA handful of short documents
CitationsYes, to the passage usedNo; the knowledge is blended into the modelPossible, but costly to repeat on every request
When documents changeRe-index the changed passagesTrain againChange the prompt

For answering questions from a company's own documents, RAG is usually the right starting point. Fine-tuning is for changing how a model behaves, not for keeping it up to date.

What RAG is good for in a business

  • Internal policies and procedures. Staff ask how to handle a refund, a leave request or a safety incident and get the answer with the policy section cited.
  • Contracts and precedents. Finding the clause, the term or the earlier matter that answers a question, with the source document linked.
  • Support and service. Agents answer from the manuals and past tickets instead of searching folders.
  • Onboarding. New staff ask the questions they would otherwise ask a busy colleague.
  • Regulated work. Where an answer must be traceable to a source, a citation on every claim makes review possible.

Where RAG goes wrong

  • Retrieval misses the passage. If the search step does not find the right text, the model cannot answer from it. Most RAG failures are retrieval failures, not model failures.
  • Bad splitting. A table cut in half or a clause separated from its heading loses its meaning.
  • Citations that do not support the claim. A citation placed next to an answer is not proof the passage says that. It has to be checked.
  • Leaked permissions. If access rules are not applied when passages are retrieved, the assistant can quote a document the person asking should never see.
  • Stale documents. An index built once and never updated answers from old versions.
  • No measurement. Without a fixed set of real questions with known answers, scored before launch and again over time, no one knows whether the assistant is right.

How to measure a RAG system

Build a set of real questions your staff ask, with the correct answer and the document that holds it. Run the assistant against the set before launch, and score two things separately: did it find the right passage, and did its answer match the passage it cited? Count a made-up or mismatched citation as a failure. Then re-run the same set on a schedule, because documents, models and questions all drift. Our article on why self-graded AI accuracy isn't accuracy explains why the score has to come from labelled answers, not from the model marking its own work.

Questions to ask before you buy or build one

Many products now promise "chat with your documents". The demos look alike; these questions separate them:

  1. Which documents, exactly? File types, scanned pages, tables, spreadsheets, wikis, email. Ask to test with your own messiest files, not the vendor's samples.
  2. How are documents split and searched? Splitting along headings and tables, and combining meaning-based search with keyword search, matters more than which model writes the answer.
  3. Does every claim carry a citation, and is the citation checked? A link next to an answer is not the same as a passage that supports it.
  4. How are permissions applied? The answer must only ever draw on documents the person asking is allowed to open, enforced when passages are retrieved, not filtered afterwards.
  5. What happens when the answer is not there? A useful system says it does not know. One that always answers will sometimes make things up.
  6. How is accuracy measured, and on whose questions? Ask for the score on a labelled set of your own questions, before and after launch.
  7. How quickly do changes show up? When a policy changes this morning, when does the assistant stop quoting the old one?
  8. Where do the index and the model run? Region, provider, and whether your documents are used to train anyone's model.

Start with one department and one collection of documents, measure it against real questions, and widen it only when the numbers hold.

Where the data goes

A RAG system holds copies of your documents in its index and sends passages to a model to answer each question. For a Canadian business, where the index and the model run decides where that data goes, and it matters for privacy law and for clients' contracts. The rules are in where your data goes.

How we build it

We build AI knowledge bases that answer from your own documents, with a citation on every claim, your existing permissions enforced at retrieval, and an honest "I don't know" when the answer is not in the documents. Accuracy is scored against a labelled question set, and a fabricated or mismatched citation counts as a failure. Every price is on our AI knowledge base page:

  • Departmental assistant: from CAD $24,000, five to seven weeks, for one document collection and one access tier.
  • Multi-source and permissioned: $52,000, nine to twelve weeks.
  • Hosting and care: from $2,200 a month, in a Canadian or U.S. region, or run it in your own cloud account.

To start, book a scoping call.

FAQ

Questions worth asking first

What is RAG in AI?

RAG, retrieval-augmented generation, is a way of getting an AI model to answer from your own documents. The system first searches the documents for the passages most likely to hold the answer, then gives those passages to the model with the question, so it answers from them and can cite which passage says what.

What is the difference between RAG and fine-tuning?

RAG gives the model the relevant passages at the moment of the question, so it can answer from current documents and cite them. Fine-tuning trains the model further on examples, which suits teaching a style or a narrow task but does not keep it up to date and gives no citations.

Does RAG stop AI hallucinations?

It reduces them but does not remove them. If retrieval misses the right passage, the model has nothing correct to answer from, and a citation placed beside an answer still has to be checked. A good system says "I don't know" when the passages do not contain the answer, and is scored against real questions.

What does a RAG knowledge base cost?

It depends on the documents, the number of sources and the access rules. With us, a departmental assistant for one document collection and one access tier is from CAD $24,000 over five to seven weeks, and a multi-source, permissioned system is $52,000 over nine to twelve weeks.

Who introduced retrieval-augmented generation?

The term comes from a 2020 research paper, Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, by Patrick Lewis and colleagues, first submitted in May 2020. The approach has since become the standard way to build AI assistants over a company's own documents.