// ai & machine learning · intermediate

Retrieval-Augmented Generation (RAG) Explained

11 min read· Published 1 September 2026· Updated 1 September 2026 · By TechDirectory Editorial Team

Share with your friends:

In one line: RAG gives a language model an open-book exam. Instead of relying on what the model memorised in training, the system retrieves the most relevant passages from your own documents at question time and puts them in the prompt — so the answer is grounded in your data, current, and citable.

A general-purpose model knows a great deal about the world and nothing at all about your contract terms, your product catalogue or last quarter's board pack. Retrieval-augmented generation is the standard way to close that gap without retraining anything — and it is the architecture behind the large majority of enterprise AI assistants in production today.

This article assumes you know roughly what a language model is; if not, start with inside large language models, which covers the engine itself. Here we go one level down into the retrieval pipeline — the part that actually decides whether an enterprise RAG system is useful or embarrassing.

Why RAG exists

Three limitations of a bare model drive nearly every RAG project:

  • It does not know your data. Private documents were never in the training set, and putting them there is expensive and slow.
  • It goes stale. A model's knowledge stops at its training cut-off; retrieval reads whatever the source system says today.
  • It hallucinates. Asked something it does not know, a model will often produce a fluent, confident, wrong answer. Grounding the response in retrieved text — and citing it — is the most practical mitigation available, because the reader can check the source.

The RAG pipeline, stage by stage

Every RAG system, however it is packaged, does the same two-phase job. Indexing happens ahead of time; retrieval and generation happen per question:

  1. Ingest — collect the source documents (wikis, PDFs, tickets, databases) and extract clean text.
  2. Chunk — split that text into passages small enough to retrieve precisely and large enough to make sense alone.
  3. Embed — convert each chunk into a vector, a list of numbers capturing its meaning.
  4. Store — load the vectors into a vector database or index, alongside metadata such as source, date and access permissions.
  5. Retrieve — at question time, embed the question and find the closest chunks by similarity, often blended with keyword search.
  6. Re-rank — score the candidates more carefully and keep only the best few.
  7. Generate — put those passages in the prompt with the question, and have the model answer using them, with citations.

Chunking and embeddings

Chunking sounds trivial and is not. Chunks that are too large dilute the signal and waste context; too small and they lose the surrounding meaning — a paragraph that says "this does not apply to enterprise customers" is dangerous when retrieved without the clause it modifies. Sensible practice: split on natural boundaries (sections, headings), keep a little overlap between neighbours, and carry metadata on every chunk so you know where it came from.

Embeddings are what make meaning searchable. An embedding model maps text into a high-dimensional vector such that passages with similar meaning land near each other — so a question about "annual leave entitlement" can retrieve a passage titled "vacation policy" even with no words in common. That is semantic search, and it is why RAG finds things keyword search misses. Two practical notes: the same embedding model must be used for both indexing and querying, and changing that model means re-indexing the whole corpus.

Retrieval is where RAG succeeds or fails

The thing most teams get wrong: RAG projects are usually blamed on "the model" when they disappoint. In practice the failure is nearly always retrieval: if the right passage never reaches the prompt, no model can answer correctly — it can only guess fluently. Debug retrieval first, and only then the generation prompt.

The techniques that reliably improve retrieval quality:

  • Hybrid search — combine semantic (vector) similarity with keyword search, so exact identifiers, part numbers and names are not lost in meaning-space.
  • Re-ranking — retrieve a generous candidate set, then use a more precise model to reorder it and keep the top few.
  • Metadata filtering — restrict retrieval by date, source, product or, critically, by the user's access permissions.
  • Query rewriting — expand or rephrase a terse user question before searching.
  • Source hygiene — retrieval cannot fix a corpus full of outdated, duplicated or contradictory documents. Curation is part of the system.
Permissions are not optional: A RAG index flattens documents from many systems into one searchable store. If it does not carry and enforce the original access permissions, it becomes a very efficient way for any employee to read things they should not — HR files, salary data, board papers. Filter retrieval by the asking user's entitlements, at query time. See identity and access management.

RAG vs fine-tuning vs long context

Three ways to make a model useful on your material — they solve different problems and are often combined:

Grounding approaches compared
ApproachWhat it changesBest forWatch out for
RAGAdds retrieved passages to the prompt at query timePrivate, changing knowledge; answers that must cite sourcesRetrieval quality; permissions; corpus hygiene
Fine-tuningAdjusts the model's weights on your examplesTeaching style, format, tone or a narrow taskCost and re-training as data changes; it teaches behaviour, not fresh facts
Long contextPuts large documents directly in the promptOne-off analysis of a handful of documentsCost per call; degraded accuracy over very long inputs; does not scale to a corpus

The rule of thumb: RAG for knowledge, fine-tuning for behaviour. If the complaint is "it does not know our facts", that is retrieval. If it is "it knows, but answers in the wrong style or format", that is fine-tuning.

Evaluating a RAG system

The step most projects skip — and the reason so many pilots never become production systems. Evaluate the two halves separately, because they fail differently:

  • Retrieval quality — for a set of real questions, did the correct passage appear in the retrieved set at all, and how highly was it ranked?
  • Answer quality — is the answer faithful to the retrieved passages (not invented), relevant to the question, and complete?
  • A regression set — a fixed list of question/expected-source pairs, re-run whenever you change chunking, the embedding model, or the prompt. Without it, every 'improvement' is a guess.
  • Human review of failures — sample the bad answers regularly; the pattern is usually a corpus or chunking problem you can fix.

Private data, PDPA and AI governance

RAG is, by definition, a system that pipes your private documents into a language model — which makes it a data-protection and governance question as much as an engineering one. Under Singapore's PDPA, personal data inside a RAG corpus remains personal data: the protection obligation applies to the index and its backups, and if the model or vector store sits overseas, the transfer limitation obligation applies too.[3] Knowing where the vectors and the inference run physically happen is a real requirement, not a detail.

On the AI side, IMDA and the AI Verify Foundation published the Model AI Governance Framework for Generative AI in May 2024, which addresses exactly the risks RAG is often deployed to manage — hallucination, content provenance, and security among them.[2] It is a practical checklist for an enterprise deployment: know your data lineage, be able to explain and attribute an answer, and test the system before and after it goes live.

Why citations matter commercially: A RAG answer that links its sources is not just better UX — it is the audit trail. It lets a reviewer verify a claim, satisfies provenance expectations in the governance framework, and turns "the AI said so" into "here is the clause it read". Design citation in from the start; retrofitting it is painful.

Getting it right

A sequence that avoids the common dead ends:

  1. Pick one narrow, high-value question set — a single well-understood corpus beats an "ask us anything" bot that is vague at everything.
  2. Clean the corpus first. Remove outdated and duplicate documents; retrieval amplifies whatever is in there.
  3. Build the evaluation set before the demo. Real questions with known correct sources, so progress is measurable.
  4. Enforce permissions at retrieval time, filtered by the asking user — not after generation.
  5. Start simple, then tune. Basic chunking and hybrid search first; add re-ranking and query rewriting when evaluation shows where the gap is.
  6. Decide residency deliberately — where the vector store lives and where inference runs, with PDPA in mind.

Building an enterprise AI assistant?

RAG lives or dies on data engineering, retrieval quality and governance. Compare Singapore AI and system-integration partners who build and run production RAG systems.

Browse AI & Systems Integrators in Singapore

Frequently asked questions

What does RAG actually do?

It gives a language model an open-book exam. Rather than relying only on what the model memorised during training, a RAG system retrieves the most relevant passages from your own documents at question time and includes them in the prompt, so the answer is grounded in your data, reflects the current state of the source, and can cite where it came from.

Does RAG stop hallucinations?

It reduces them substantially but does not eliminate them. Grounding the model in retrieved text — and showing citations so a reader can verify — is the most practical mitigation available. A model can still misread or over-generalise from a passage, and if retrieval fails to surface the right passage the model may fall back on guessing. Retrieval quality and citation are what make the difference.

RAG or fine-tuning — which do we need?

RAG for knowledge, fine-tuning for behaviour. If the problem is "it does not know our facts", that is a retrieval problem and RAG is the answer, because your data changes and RAG reads it fresh. If the problem is "it knows, but answers in the wrong style, tone or format", that is fine-tuning. Many production systems use RAG for grounding and light fine-tuning for style.

Do we need a vector database?

You need a way to store and search embeddings, which may be a dedicated vector database or vector search built into a database or search engine you already run. For a small corpus, the built-in option is usually sufficient and simpler to operate. Dedicated vector databases earn their place at larger scale, with heavy filtering requirements or very high query volumes.

Why is our RAG system giving poor answers?

Nearly always retrieval, not the model. If the correct passage never reaches the prompt, the model can only guess fluently. Check whether the right chunk is retrieved at all and how highly it ranks; then look at chunking (too large or too small), missing hybrid keyword search, absent re-ranking, or an unclean corpus full of outdated and duplicated documents. Fix retrieval before touching the prompt.

Is it safe to put confidential documents into RAG?

It can be, with deliberate controls. A RAG index flattens many sources into one searchable store, so it must carry and enforce the original access permissions — filter retrieval by the asking user's entitlements at query time, or you have built an efficient way to leak HR and board material. Under the PDPA, personal data in the corpus stays personal data, so secure the index and its backups, and decide deliberately where the vector store and inference physically run.

Sources

  1. Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (Lewis et al., 2020) — the original RAG paperarXiv, 2020 reported checked 2026-09-01
  2. Model AI Governance Framework for Generative AI — IMDA and AI Verify FoundationIMDA, 2024-05 official checked 2026-09-01
  3. Overview of the PDPA — Personal Data Protection Commission (PDPC)PDPC official checked 2026-09-01

Related resources

Go deeper on this topic

Research cluster

Related analysis

Recent TechDirectory Insights coverage from the same research cluster.

New to this cluster? Start with the foundation article: Introduction to Artificial Intelligence: How AI Works and Where It Is Used.