Retrieval augmented generation, usually shortened to RAG, lets an AI model answer from your own documents instead of from memory. This guide explains the problem it solves, how it works step by step, when to choose it over fine-tuning and where projects tend to go wrong.

The problem RAG solves

A language model knows what was in its training data. However, it does not know your pricing, your policies, your contracts or what you decided in last week’s meeting. Asked about any of those, a model without access to your information may produce a plausible but incorrect answer, in the same confident tone it uses when it is right.

Retrieval augmented generation fixes this by changing the order of operations. Instead of asking the model to answer from memory, the system first searches your documents for relevant passages. Then it hands those passages to the model with the question attached, and asks it to answer using only what it was given.

As a result, you get an answer grounded in a source you can click through to. That single property, citation, is why RAG became the default architecture for business AI rather than an interesting option. In fact, the approach goes back to the research paper “Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks” by Lewis and colleagues.

How retrieval augmented generation works, step by step

Five stages. The interesting engineering is in stages two and three, not in the model.

  1. Ingest and chunk

    The system splits your documents into passages small enough to be precise and large enough to keep their meaning. In practice, chunking badly is the most common cause of a RAG system that returns irrelevant material.

  2. Embed

    Next, the system converts each passage into a vector, a numeric representation of its meaning, and stores it in a vector database. Two passages about the same idea end up near each other even if they share no words.

  3. Retrieve

    The system embeds the question the same way and pulls the passages closest to it. Production systems combine this with keyword search, because pure vector search is weak on names, codes and exact figures.

  4. Generate

    The model receives the question plus the retrieved passages, with an instruction to answer from those passages and to say so when they do not contain the answer.

  5. Cite

    The response carries links back to the source passages. Therefore, the output is checkable, and this step turns a demo into something a compliance team will approve.

Retrieval augmented generation flow: documents are chunked, embedded and retrieved for a question, then cited in the answer
RAG retrieves relevant passages first, then generates an answer that links back to its sources.

RAG or fine-tuning?

A frequent and consequential fork. However, they solve different problems and are not substitutes.

RAG Fine-tuning
Teaches the model Facts it can look up Style, format and behavior
Updating information Add the document Retrain the model
Citations When source links are implemented No
Setup cost Lower Higher
Best for Policies, docs, product data Tone, structured output, niche tasks

If your requirement is “answer from our knowledge, accurately, with sources”, the answer is RAG. Fine-tuning is for when the model needs to behave differently, not know different things. That said, plenty of production systems use both.

Where retrieval augmented generation pays off

RAG earns its keep wherever people spend time looking things up in documents they already own. In our work, these use cases come up most often:

  • Internal knowledge assistants. For example, staff ask about policies, procedures and past decisions, and get an answer with the source attached.
  • Customer support. The assistant answers from your help center, so its replies match what your documentation actually says.
  • Sales and product questions. Teams find specifications, pricing rules and approved wording without searching three shared drives.
  • Contract and document lookup. Reviewers jump straight to the clause that answers the question, then read it in full.

In each case, retrieval augmented generation works because the answer already exists somewhere. So the system simply finds it faster and shows its working.

A worked example

Here is a hypothetical case. An employee asks, “How many days of bereavement leave do we offer?” Without retrieval, a general model might guess a common figure, which may not match your policy at all.

With RAG, by contrast, the system first finds the leave section of your current handbook. Then it passes that passage to the model, which answers in one sentence and links to the page. If the handbook does not cover the question, the system says so and points the employee to HR. As a result, the employee gets your answer, not a plausible one, and can check it in one click.

Where RAG projects go wrong

The failures are consistent and almost all of them happen before the model is involved.

  • Bad chunking. Splitting a table across two passages, or cutting a clause in half, can remove needed context and increase the risk of incorrect answers.
  • Vector search alone. Semantic search misses exact identifiers such as part numbers. Hybrid retrieval, vector plus keyword, is the production standard for a reason.
  • Stale content. A knowledge base nobody maintains produces confidently outdated answers, which are worse than no answer because they look authoritative.
  • Contradictory sources. Three versions of the same policy in the index means the system picks one, effectively at random. Deduplicate before you embed.
  • No “I do not know” path. If nobody explicitly instructs and evaluates the system on refusing when the retrieved passages are irrelevant, it will fill the gap.

How we test retrieval augmented generation before launch

A demo that answers five friendly questions proves very little. So before launch, we test retrieval augmented generation against real questions in four steps.

  • Build a question set. First, we collect real questions from tickets, emails and staff, and note where each answer lives.
  • Check retrieval on its own. For each question, we check whether the right passage came back at all. If the right passage is missing, no model can fix the answer, because the evidence never arrived.
  • Check the answers. Then we compare each answer with its cited source. Specifically, the answer should say what the passage says, and nothing more.
  • Test the refusals. Finally, we ask questions the documents do not cover. The correct result is a clear “I do not know” with a route to a person.

Teams that rely on a vector database should rerun this test set whenever chunking, embeddings or sources change.

Frequently asked questions

How much does a RAG system cost to build?
A straightforward internal knowledge assistant over well-organized documents runs $20k to $50k. In general, complexity comes from document variety, access-control requirements and accuracy targets, not from volume. A million clean documents can be easier than ten thousand messy ones.
Does RAG eliminate hallucinations?
No. RAG can reduce unsupported answers, but retrieval can miss relevant evidence and generated answers or citations can still be wrong. Evaluate both retrieval and answer quality. With citations, a wrong answer can be checked against its source. Without them, you have no way to tell. Well-built systems also refuse when retrieval returns nothing relevant.
Can RAG respect our existing permissions?
Yes, and it must. The system filters retrieval by the requesting user’s access rights before anything reaches the model, so a system that indexes everything cannot leak a document to someone who could not otherwise open it. Retro-fitting this is painful, so specify it up front.
How often does the knowledge base need updating?
It should update automatically when source documents change, which is an ingestion pipeline decision made at build time. By contrast, manual re-indexing is a maintenance burden that teams abandon within a few months.
Do we need to train a model to use RAG?
No. Retrieval augmented generation works with existing models, because the knowledge lives in your documents rather than in the model. That is also why updating it means adding a document, not retraining anything.

For implementation support, explore our RAG development services or discuss your workflow in a free consultation.

For a structured approach to AI risks and evaluation, consult the NIST AI Risk Management Framework.