RAG (retrieval-augmented generation) is a way to build AI assistants where the system first searches your own content for the passages that answer a question, then has a language model write the answer from those passages and cite each one. The model works from your documents instead of from what it remembers from training, so answers stay current and anyone can check them against the source.
Why does RAG exist?
A language model knows what was in its training data, up to a cutoff date, and nothing about your business. It has never read your return policy, your price list or last week’s change to the onboarding procedure. Ask it anyway and you may get a confident answer that’s simply made up.
RAG fixes this by changing the question the model gets. Instead of "What is our return policy for opened items?", the model gets "Using only these three passages from our policy documents, answer: what is our return policy for opened items? If they don’t say, reply that you don’t know." That small change turns a general model into a specialist on your content, and it’s at the heart of most assistants our LLM and RAG development team builds.
How does RAG work, step by step?
Every RAG system, from a weekend prototype to an enterprise RAG platform, follows the same four steps. The first one happens ahead of time. The other three happen on every question.
-
Index your content
-
Retrieve relevant passages
-
Generate a grounded answer
-
Cite the sources
1. Index
Documents are pulled from wherever they live (shared drives, wikis, help desks, PDFs, databases), cleaned of duplicates and boilerplate, and split into passages along their natural structure: sections, articles, clauses. Each passage is turned into an embedding, a list of numbers that captures its meaning, and stored in a search index along with metadata like title, date, owner and who’s allowed to see it.
2. Retrieve
When someone asks a question, the question gets turned into an embedding too, and the index returns the passages closest in meaning. Good systems pair this semantic search with keyword search so exact terms like part numbers and policy codes don’t slip through, then re-rank the results and filter them by the user’s permissions and by date.
3. Generate
The top few passages go into the prompt along with the question and firm instructions: answer only from these passages, and if they don’t contain the answer, say so. The model writes the reply in plain language.
4. Cite
The answer comes back with references to the passages it used, so the reader can open the source and check. This step is what makes RAG usable for policies, contracts and support answers, where "the AI said so" doesn’t cut it.
What does a RAG answer look like?
Here’s the whole loop in one illustrative example. A resident asks a property manager’s assistant about the pet policy. The system scores the knowledge base, picks two passages and writes an answer where every sentence points back to its source.
Illustrative example Fictional business, people and data. Not a real client, conversation or result.
Notice what the assistant does not do: it doesn’t fill gaps with plausible guesses. Questions the documents don’t cover go to a person. That behavior is designed, tested and measured. It doesn’t happen by default.
What does a RAG system need?
Most of the work in a RAG project goes into the content and the plumbing around it. The model is the smaller part.
| Ingredient | What it means in practice |
|---|---|
| Source content | The documents and records answers should come from, reasonably current and not contradicting each other |
| A content owner | Someone who keeps the content up to date, because the assistant will faithfully repeat whatever is out of date |
| Access rules | Who can see which documents, carried over from the source systems |
| A search index | Embeddings plus keyword search, often in a vector database or a search engine that handles both |
| A language model | Any capable model; with RAG you can switch models later without redoing the content work |
| An evaluation set | Real questions with known correct sources, used to measure quality before launch and after every change |
A vector database is only one of these ingredients. Buying one doesn’t give you RAG, any more than buying a filing cabinet gives you an organized office.
Where does RAG fall short?
RAG is the right tool for "answer from our content," but it has limits you should know about before you scope a project.
- Questions that need math. "How many orders shipped late last month?" calls for a database query, not a document search. The usual fix is a tool the assistant can call, alongside retrieval.
- Questions that span everything. Summarizing themes across thousands of tickets is a different job from finding the right three passages.
- Misreading a correct source. The model can still get a retrieved passage wrong. Citations, strict instructions and regular evaluation keep this in check.
- Behavior and format. RAG changes what the model knows, not how it writes. If you need a very specific style or output format at scale, that’s where fine-tuning can help.
How does RAG compare with fine-tuning and long prompts?
People mix these three up because all of them "give the model your data." They go about it in very different ways.
RAG vs fine-tuning vs pasting everything into the prompt
| Criterion | RAG | Fine-tuning | Long prompt |
|---|---|---|---|
| What changes | What the model can see when it answers | How the model behaves | What the model sees in one conversation |
| Keeping content current | Update the index, minutes | Retrain the model | Paste the content in again |
| Source citations | Built in | Not available | Possible but unreliable |
| Per-user permissions | Filtered at search | Not possible inside the model | Manual |
| Works at large scale | Yes, thousands of documents | Yes, for behavior | No, limited by context size and cost |
| Best for | Answering from company knowledge | Consistent style, format or classification | One-off analysis of a few documents |
RAG
- What changes
- What the model can see when it answers
- Keeping content current
- Update the index, minutes
- Source citations
- Built in
- Per-user permissions
- Filtered at search
- Works at large scale
- Yes, thousands of documents
- Best for
- Answering from company knowledge
Fine-tuning
- What changes
- How the model behaves
- Keeping content current
- Retrain the model
- Source citations
- Not available
- Per-user permissions
- Not possible inside the model
- Works at large scale
- Yes, for behavior
- Best for
- Consistent style, format or classification
Long prompt
- What changes
- What the model sees in one conversation
- Keeping content current
- Paste the content in again
- Source citations
- Possible but unreliable
- Per-user permissions
- Manual
- Works at large scale
- No, limited by context size and cost
- Best for
- One-off analysis of a few documents
For the full decision framework, read our guide to RAG vs fine-tuning. You’ll also hear about variants: hybrid RAG (semantic plus keyword search, which we use by default), agentic RAG (an agent that decides when, where and how many times to search) and graph RAG (retrieval over relationships between entities). They refine the same idea; none of them replaces it.
A small-business example
Picture a plumbing and HVAC supply distributor in Texas whose counter staff get questions all day: which replacement part fits a given model, what the warranty says for a certain brand, what the return rules are for special-order items. The answers are scattered across manufacturer spec sheets, warranty PDFs and the company’s own policy documents. (This is an illustrative scenario, not a client.)
With RAG, someone at the counter asks: "Is the warranty on brand X water heaters still valid if a non-licensed installer did the install?" The system pulls the relevant warranty clause and the company’s own claims policy, and the answer quotes both, with links. If neither one covers the case, the assistant says so and tells them who to ask.
When should you use RAG?
Use RAG when the answers already exist in your content, the content changes, and people need to trust or check what the AI says. That covers internal knowledge assistants, customer-facing help, sales enablement and search inside software products. If you want to see what building one involves, our walkthrough on how to build a RAG chatbot covers the architecture and the evaluation loop. And when an outside assistant like Claude or ChatGPT needs to search your content, the bridge is often an MCP server that exposes a RAG-backed search tool; see what MCP is and how it works.
If the answers should come from your documents, with sources and permissions, our team can start with a slice of your content and a list of real questions, then show you measured results before anything goes live. For drafting and summarizing on top of the same knowledge, see our generative AI development work, or tell us what your assistant should know.