Ask a general-purpose AI model about your company’s travel policy and it will produce a fluent, plausible answer that may have nothing to do with your actual policy. The model has never seen your documents. Retrieval-augmented generation (RAG) fixes that by looking up the relevant content first and giving it to the model along with the question.
RAG is the pattern behind many enterprise AI assistants, from HR policy bots to engineering runbook search. This guide explains how it works in plain terms, when to use it, why projects fail and how to measure whether yours is working.
What is RAG?
RAG is an architecture with two steps. Retrieval finds the passages most relevant to a question from a collection you control. Generation has a large language model write an answer using those passages as its evidence. The approach was described in a 2020 research paper by Patrick Lewis and colleagues and is now widely used to connect language models to private knowledge.
Think of it as an open-book exam. A model without RAG answers from memory, which is broad but frozen at its training date and blind to your private data. A model with RAG is handed the right pages of the right book before it answers, and can show you which pages it used.
Three properties make RAG attractive for business:
- Current knowledge. Update a document and the next answer reflects it, with no retraining.
- Traceability. Answers can cite their sources, so users and auditors can check them.
- Access control. Retrieval can respect existing permissions, so people only get answers drawn from content they are allowed to see.
How RAG works, step by step
A RAG system has two pipelines: one that prepares your content and one that answers questions.
Preparing the content
- Connect sources such as SharePoint, Confluence, file shares, ticketing systems, product databases or a document management system.
- Parse each document into clean text, preserving headings, tables and page references. Scanned PDFs need OCR, and complex tables need special handling.
- Chunk the text into passages small enough to be precise but large enough to keep their context, ideally following the document’s own sections.
- Enrich each chunk with metadata: source, owner, date, version, document type and, critically, who is allowed to see it.
- Embed and index the chunks. An embedding model turns each passage into a vector that captures its meaning, and a search index stores vectors and text for fast lookup.
- Keep it in sync with incremental updates, so changed or deleted documents are reflected within hours, not months.
Answering a question
- Interpret the question, optionally rewriting it into a better search query or splitting it into parts.
- Retrieve candidates with hybrid search, combining keyword matching with vector similarity, filtered by the user’s permissions.
- Rerank the candidates with a model that scores relevance more precisely, and keep the best few.
- Assemble the prompt: instructions, the question and the selected passages with their source labels.
- Generate an answer that cites its sources and says so when the sources do not contain the answer.
- Check and log the output against guardrails, and record the question, sources and answer for evaluation.
RAG vs fine-tuning vs long-context prompting
| Approach | What it changes | Best for | Watch out for |
|---|---|---|---|
| RAG | What the model sees at answer time | Facts that change, citations, permission-aware answers | Retrieval quality, content hygiene, index freshness |
| Fine-tuning | How the model behaves | Consistent style or format, narrow classification or extraction | Does not reliably add new facts; retraining when data changes |
| Long-context prompting | What fits in a single prompt | Small, stable document sets and one-off analysis | Cost and latency on every call; weak permission control |
These approaches combine well. A common production pattern uses RAG for knowledge, a small fine-tuned model for a high-volume classification step, and long context only when a task genuinely needs a whole document, such as summarising one contract.
Business use cases for RAG
- Employee policy and HR assistants that answer leave, travel and benefits questions with links to the governing policy.
- Customer support knowledge for agents and customers, grounded in product documentation, known issues and approved responses.
- Sales and bid support that drafts answers to security questionnaires and RFPs from previously approved responses.
- Engineering and IT operations search across runbooks, architecture decision records and incident reviews.
- Contract and regulatory research that finds and compares clauses across large sets of agreements or policies, with a lawyer or compliance officer reviewing the output.
RAG is also one of the most common tools inside AI agents: before an agent acts, it often retrieves the policy or record it needs. If you are heading in that direction, read What is agentic AI? next.
Why RAG projects fail
When a RAG assistant gives poor answers, the model is rarely the main cause. The usual culprits:
- Bad source content. Three versions of the same policy, outdated pages nobody owns and drafts mixed with approved documents. The assistant faithfully retrieves the wrong one.
- Poor parsing. Tables flattened into nonsense, headers and footers repeated in every chunk, scanned documents with no text layer.
- Vector-only search. Embeddings capture meaning well but handle exact terms poorly. Product codes, policy numbers, names and acronyms need keyword matching too, which is why hybrid search and reranking matter.
- Ignored permissions. If the index does not carry each document’s access rules, the assistant can surface board papers or salary data to anyone who asks the right question.
- No evaluation. Without a test set of real questions and expected answers, every change is a guess and regressions go unnoticed.
- Stale indexes. A one-time load that is never refreshed turns a helpful assistant into a confident source of outdated answers.
The permissions problem deserves emphasis. An assistant that reveals documents to the wrong people has caused a data breach, and IBM’s Cost of a Data Breach Report 2025 puts the global average cost of a breach at $4.44M. Enforce permissions at retrieval time, using the identity the user signs in with, and test that enforcement explicitly before launch.
Data governance: the foundation RAG depends on
RAG turns your document estate into answers, so its quality and safety can never exceed that of the underlying content. Before scaling an assistant, put these basics in place:
- Ownership: every source collection has a named owner responsible for accuracy and for retiring outdated content.
- Classification: sensitive content is labelled so it can be excluded or restricted, using tools such as Microsoft Purview or your cloud’s data classification services.
- Approved sources only: the index includes curated, current collections rather than everything a crawler can reach.
- Retention and deletion: when a document is deleted or expires, its chunks leave the index too.
- Lineage: each answer records which document versions it used, so you can explain and correct it later.
Our data governance service covers this groundwork, and our article on data governance for AI goes deeper.
How to measure RAG quality
Measure retrieval and generation separately, because they fail for different reasons. Start with 100 to 200 real questions, each with an expected answer and source documents agreed by subject-matter experts, and track these metrics on every change:
| Metric | What it tells you |
|---|---|
| Retrieval hit rate | Whether the right source appears in the top results |
| Groundedness | Whether every claim in the answer is supported by retrieved text |
| Answer correctness | Whether the answer matches the expert-approved answer |
| Citation accuracy | Whether the cited sources actually support the statements |
| Appropriate refusals | Whether the assistant says it does not know when the sources lack the answer |
| Permission leakage | Whether test users ever receive content they should not see |
| Latency and cost per answer | Whether the experience and economics hold at production volume |
Automated scoring with a language model as the judge speeds this up, but calibrate it against human reviews before you trust it. Global Commit treats this test set as a release gate: a change to chunking, prompts, models or sources ships only if the scores hold.
What drives the cost of a RAG system
RAG is inexpensive per question but adds up at scale. Four components drive the bill:
- Generation tokens. Retrieved passages usually make up most of the prompt, so sending five long chunks instead of three precise ones raises the cost of every answer. Reranking often pays for itself here.
- Index hosting. An always-on search cluster costs the same at midnight as at noon. Serverless or tiered options suit spiky internal assistants.
- Embedding. Embedding the corpus is largely a one-time cost, but changing the embedding model or chunking strategy means re-embedding everything, so settle those choices during the pilot.
- Operations. Connectors, sync jobs, evaluation runs and the people who curate content are recurring costs that belong in the business case.
Building RAG on AWS, Azure and Google Cloud
Each major cloud offers managed building blocks: Amazon Bedrock Knowledge Bases on AWS, Azure AI Search with Azure OpenAI in Microsoft Foundry, and Vertex AI Search with Gemini on Google Cloud. They cover ingestion, embedding, hybrid search and grounded answers with citations, and they integrate with each cloud’s identity and private networking. Teams with existing search or database skills can also build on OpenSearch or PostgreSQL with pgvector. Platform choice matters less than the content, permissions and evaluation work described above.
How Global Commit can help
Global Commit builds RAG systems that answer from approved content, respect existing permissions and are measured before and after every release. Our RAG and enterprise search service covers source connection, parsing, hybrid retrieval, evaluation and monitoring on AWS, Azure or Google Cloud, and our data governance work makes sure the content behind it is owned, classified and current.
Start with a free Cloud & AI assessment. We review your candidate knowledge sources, access model and highest-value questions, and outline a pilot with a clear evaluation plan.