Skip to content

What is RAG in AI? Pipelines, Uses and Limits

Published Updated

Retrieval-augmented generation (RAG) is a way to answer a question by finding relevant passages in a source and giving them to a large language model (LLM). A staff assistant can use it to answer from the current policy and link to the clause behind its answer. How well it works depends on what the search finds and what the model does with it.

What RAG Means in AI

RAG gives an LLM evidence it can use at the moment someone asks a question. A model’s training data has a cut-off and usually excludes your internal documents. If your leave policy changes, you can update the searchable copy so the same model can answer from the new version. In the original RAG paper, Patrick Lewis and colleagues paired a pretrained model with a searchable Wikipedia index.

Fine-tuning changes a model’s weights through additional training. It fits a repeatable task, such as classifying support requests into the categories your team uses. For a one-off question about a small set of known documents, you can put those files directly into the model’s context window, the space it has to read the input. RAG fits repeated questions across a larger collection where the relevant documents change from one question to the next.

How a RAG Pipeline Works

A RAG pipeline prepares documents for search, finds relevant passages when a question arrives and passes those passages to the model for a cited answer. The first three steps typically run as content is added or updated. The rest run when someone asks a question.

  1. Ingest and chunk. Read the source files, extract their text and divide it into passages called chunks. Keep the document title, version and source location with each passage.
  2. Embed. Use an embedding model to turn each chunk into a vector, a list of numbers that captures aspects of its meaning.
  3. Store. Put the vectors in a vector database or search index. Keep each vector tied to its text and document metadata, including access rules.
  4. Retrieve. Search for passages that match the question. Permission-aware retrieval uses the signed-in person’s access rights to restrict which chunks can enter the model’s context.
  5. Rerank. Score the retrieved candidates again against the question to decide which passages the model gets first.
  6. Generate. Give the model the question and selected passages. Ask it to answer from the evidence and attach citations that open the supporting sources.

Hybrid retrieval combines keyword search with semantic search. A keyword query can find an exact policy code. Vector matching can find the right passage when a staff member says “working from home” and the policy calls it “remote work”. Combining the rankings can recover relevant passages each method would miss on its own.

Suppose an employee asks, “Who approves two days of remote work each week?” The search finds the working arrangements policy among the files that employee can open. The reranker puts the recurring arrangements clause ahead of a section about occasional remote work. The assistant answers, “Your line manager approves a recurring two-day arrangement,” and links to that clause in the hypothetical policy.

RAG Architecture Choices

The design of a RAG system determines what evidence the model sees and which services handle your data. A short chunk can isolate a precise rule but lose the exception in the next paragraph. A larger chunk can keep the rule and exception together but bring unrelated material into the answer. Split by heading, policy clause or another meaningful boundary where the documents allow it.

Test the embedding model on the names, codes and language staff actually use. Choose a vector store that supports the metadata filters you need, and measure whether a reranker earns its extra time by moving the right passage up. Pick an LLM that can follow your evidence and citation rules. Map where each component runs, including where source text goes when you embed it, rerank it or send it to the LLM.

Azure AI Search (Foundry IQ) handles indexing, keyword and vector search along with semantic ranking. Its knowledge base APIs can also plan retrieval across sources.

Amazon Bedrock Knowledge Bases manages retrieval and can generate answers with citations. A customer-managed knowledge base gives you control over the vector store and ingestion settings.

Google Cloud’s Agent Search, formerly Vertex AI Search, searches enterprise content and can generate answers from the results.

You can also build with an open-source parser, an embedding model and a vector store you operate. That gives you control over how you parse difficult files, enforce access rules and host each stage. Your team then owns upgrades, failures and indexing jobs. Either way, work out how source permissions and changes reach the index before you choose the stack.

Graph RAG and Agentic RAG

Graph RAG builds a graph of entities and relationships so retrieval can follow connections across documents. It can join evidence about a project, its suppliers and the equipment they service even when those details appear in separate files. Microsoft Research’s GraphRAG work also groups related entities and summarises those groups to answer questions about a whole collection.

Agentic RAG lets an AI agent decide which searches to run. It can split a question into smaller searches, inspect what comes back and search again where the evidence is weak. Before returning an answer, the agent can check whether the cited passages support each part. That check can catch omissions, though the model can still misread the source.

Extracting and maintaining relationships can raise Graph RAG indexing costs, especially if it uses model calls to build or update the graph. Query speed depends on how far the system searches the graph and how much evidence it reads.

Agentic RAG adds work at question time. Extra searches and model calls can raise cost and make answers slower. Start with plain RAG if most questions point to a single policy or manual section. Add complexity when tests show repeated misses on questions that need several sources.

Where RAG Systems Fail

A RAG answer can fail because the system read the wrong text, found the wrong passage or drew the wrong conclusion from good evidence. Scanned pages may need optical character recognition before they can be searched. A parser can lose the heading over a table column and leave the model with a number whose meaning is unclear. An outdated copy can rank above the current version.

Even with good retrieval, a model can blend rules from two policies or produce an AI hallucination when the search finds nothing relevant. Test the retrieved passages separately from the answers. Require citations for material claims and check whether each citation supports the statement it follows. Tell the assistant to say when it lacks enough evidence and direct staff to a person or policy owner who can help.

A retrieved file can also contain text intended to steer the model away from its task. The Open Worldwide Application Security Project’s guidance on prompt injection calls this indirect prompt injection. Treat retrieved passages as data, enforce access outside the model and restrict any tools the assistant can use.

For organisations covered by Australia’s Privacy Act 1988, indexing personal information and passing it to an AI service can raise obligations under the Australian Privacy Principles. The Office of the Australian Information Commissioner’s AI privacy guidance covers personal information supplied to AI tools and personal information the tool generates. Before indexing, determine which records the assistant needs, who can access them and whether sending them to a provider is a permitted use or disclosure.

Making RAG Work on Real Company Documents

Start with the documents and their access rules. A stronger model cannot tell which of two copies your organisation treats as authoritative. Assign an owner to each SharePoint library you index. Inspect scanned PDFs and Excel tables for missing text or labels, mark superseded files and check that folder or document permissions carry through to the chunks.

Build a scored answer set from questions staff actually ask. For each question, have a subject expert record the applicable role, the expected answer and the clause or record that supports it. Engineering staff might ask which revision of a standard applies to a job. Insurance staff might check an exclusion in a particular policy wording. A clinical team might look up the local procedure for escalating an incident.

Run those questions with realistic staff access. Score whether search found the right evidence, whether the answer matched it and whether the citation opened the right place. Include cases where the user lacks permission and where the approved collection contains no answer. After rollout, monitor answer quality using the same scores, re-index amended files and retire old versions from retrieval. Repeat access checks after permission changes.

Microsoft 365 Copilot can answer from content available through Microsoft Graph. Switching it on by itself leaves disconnected operational systems outside that search. Microsoft’s Copilot connector documentation describes connectors that index external content or fetch it when someone asks. Microsoft’s data residency documentation includes Australia in its local storage commitments for eligible tenants’ stored interactions, including prompts and responses.

A custom RAG system fits when your team needs answers from an operational system with its own access rules or a mix of live records and approved policies. For example, a technician could ask which procedure applies to the machine on a work order. A knowledge assistant can look up the asset in the work-order system, retrieve the applicable procedure and cite it. Use a question like that in the pilot, and check that the answer changes when the source record changes.