Learn AI /Search, Embeddings and RAG /Retrieval-augmented generation
Retrieval-augmented generationRAG
- Intermediate
- Search, Embeddings and RAG
- Policy officers
- Programme & data teams
- Technical readers
Also called: RAG, grounded generation.
Back to the milestone you came from
In five seconds
What it is
A method that first finds relevant source passages and then asks a language model to answer using that material.
In plain words
It is like giving the AI an open folder of relevant pages before asking it to answer, so the reply can be based on those pages instead of memory alone.
An everyday example
Aisha needs a short summary of last month’s meeting decisions. Instead of relying on memory, she asks Mateo to pull the most relevant pages from the meeting notes, highlight the lines about budget, timelines and responsibilities, and then write a brief summary using those pages. Mateo’s summary is more useful because it is tied to the notes on the table, and Aisha can check the highlighted pages if anything looks wrong.
A human colleague can notice subtle organisational context, ask follow-up questions and judge whether the notes are trustworthy. A RAG system does not check truth in the human sense. It retrieves text that looks relevant and then generates wording from that input. If the source documents are incomplete, outdated or poorly retrieved, the answer can still be wrong or misleading.
Remember thisRAG retrieves source passages and places them in the model’s prompt before it answers. This can improve relevance and traceability, but retrieved material may still be missing, outdated or misranked.
Understand it
Understand it
Why it matters
For non-specialists, this method matters because it can make AI answers more checkable. Instead of relying only on patterns learned during training, the system can pull current source material at answer time. That can improve usefulness for policies, manuals, technical documents and large knowledge collections that change often. It also changes what you should ask before trusting a system. You should ask: What documents can it access? How recent are they? Can I inspect the cited passages? What happens when nothing relevant is found? A polished answer without good retrieval can still be wrong. Good governance therefore depends not only on the model, but also on document quality, indexing, access controls and human oversight.
How retrieval-augmented generation works
After using this explainer, a reader should be able to say that the system first retrieves relevant passages from a document collection and then generates an answer from those passages, often with citations.
The question
Without retrieval
With retrieval (RAG)
The explainer shows a question moving through three panels: document store, retrieved passages and answer box. Readers can change the question, retrieval quality and number of passages to see how the final answer changes and why citations appear or fail.
Readers can type or choose a question, drag a slider for retrieval quality, change how many passages are retrieved, and click citation markers to reveal the exact supporting passage.
Describe this without the diagram
This interactive explains the process in four stages. First, a user asks a question. Second, the system searches a prepared collection of document chunks and selects the most relevant passages. Third, it combines the question and those passages into a prompt for a language model. Fourth, the model produces an answer that may include citations back to the retrieved passages. Controls let the user change the question, the quality of retrieval and the number of passages. When retrieval quality is high, the answer is more likely to stay close to the sources. When retrieval quality is low or the wrong passages are selected, the answer may be incomplete, off topic or unsupported even if it sounds fluent.
With reduced motion: A static four-panel layout replaces animation. Panel 1 shows the question. Panel 2 shows the indexed document collection with the selected passages highlighted. Panel 3 shows a prompt box containing the question plus those passages. Panel 4 shows the generated answer with citation markers and notes showing which sentences are supported or unsupported.
This approach combines two parts: finding useful information and writing a response. A user starts with a question. The system searches a set of documents, such as reports, manuals or web pages, to find passages that are likely to help.
The search usually works by meaning, not only exact words. To do that, the system turns text into numeric representations called embeddings, which place similar meanings near each other. It then retrieves the most relevant chunks, meaning smaller sections of documents, rather than whole files.
Those retrieved passages are given to a large language model together with the user’s question. The model then generates an answer that is guided by that supplied material. In a well-designed system, the answer may also show citations so the reader can check the source.
What goes in: a question and a collection of approved documents. What happens: retrieval, selection and answer generation. What comes out: a drafted answer grounded in retrieved text, often with references. This is different from fine-tuning, which changes model behaviour through training, and different from plain semantic search, which stops at finding documents rather than drafting an answer.
How “Asking a colleague to summarise the right pages first” maps onto the real thing
| In the story | In the AI system |
|---|---|
| Mateo pulling the most relevant pages | Retrieval step finding relevant text chunks |
| Highlighted lines on budget, timelines and responsibilities | Selected passages provided as grounding context |
| Writing a brief summary from those pages | Language model generating an answer from retrieved material |
| Aisha checking the pages | User verifying citations or source passages |
A worked example
A political affairs officer drafting the note for the file after a bilateral asks an approved internal assistant to find the previously agreed wording on follow-up and any commitments already recorded.
Starting from: The indexed collection contains cleared talking points, an earlier note for the file, a circulated aide-memoire and a superseded background note.
- The system divides the documents into chunks and creates embeddings for semantic search. It represents the officer’s question in the same way and retrieves chunks concerning agreed wording, follow-up and earlier commitments.
- The candidate set contains relevant passages from the cleared talking points and earlier note, but also similar wording from the superseded background note.
- A reranker orders the candidates by relevance. The highest-ranked passages, their source details and the officer’s question are placed in the language model prompt as context.
- The model drafts a short account based on that context and provides source links. This does not itself establish that every linked passage is current or that each citation fully supports the sentence beside it.
- The officer opens the sources, checks their status and surrounding text, and compares the draft with their own record of the bilateral before placing the note on the file.
Result: The officer has a source-linked first draft without reopening several folders at close of business. Retrieval has narrowed the search, but the superseded passage shows why document status, access controls and human verification remain part of the process.
In a United Nations workplace
A political affairs officer in a country office is completing the note for the file after a bilateral before close of business. An approved internal assistant searches cleared talking points, an earlier note and a circulated aide-memoire, then drafts the agreed follow-up with links to the passages it used.
Retrieval-augmented generation searches the indexed file before drafting, rather than relying only on the model’s general training. The source links let the officer check the precise wording, document status and context before the note goes on the file.
Before you try thisDo not index, paste or upload confidential bilateral records, personal information or security-sensitive material into a tool that is not explicitly approved for that material and purpose. The retrieval index needs appropriate access controls. A citation shows what was retrieved, not that the passage is current, complete or correctly interpreted.
Where you may hear it
- During a vendor demonstration to a procurement unit testing an internal document assistant
- At an ICT governance board review of retrieval permissions and source links
- In a regional bureau session reviewing a pilot across cleared records
- During a first reading of the terms of reference for an internal knowledge assistant
Avoid confusion
Avoid confusion
Often confused with
Semantic search
A search method that finds material by similar meaning, not just shared words, and returns the most relevant passages for review or further AI use.
Fine-tuning
Updating a pre-trained model's parameters with additional examples to improve performance on a narrower task, style or domain.
Prompt engineering
The practice of writing and refining instructions so a language model is more likely to produce a useful, safe and well-structured reply.
Side-by-side
Common misconceptions
Common misconception: RAG guarantees factual answers because it uses sources.
Correction: It can improve traceability, but it does not guarantee accuracy. The system may retrieve the wrong passage, miss an important document, use outdated material or generate wording that goes beyond the source. Citations help checking; they do not replace checking.
Common misconception: RAG is the same as semantic search.
Correction: Semantic search mainly finds relevant documents or passages. RAG adds another step: a language model uses the retrieved text to draft an answer. That extra generation step can be helpful, but it can also introduce unsupported wording if not well controlled.
Common misconception: RAG and fine-tuning solve the same problem.
Correction: Fine-tuning changes a model by additional training on examples. RAG usually leaves the base model unchanged and gives it relevant source text at run time. RAG is often better for changing knowledge bases because you can update documents without retraining the model.
Quick check
What best describes retrieval-augmented generation?
RAG combines retrieval with generation. It finds relevant passages first, then uses them as context for a model’s answer. It is not the same as retraining, not limited to exact keyword search, and citations help checking but do not guarantee correctness.
Go deeper
Go deeper
The simple version
It is like giving the AI an open folder of relevant pages before asking it to answer, so the reply can be based on those pages instead of memory alone.
The technical version
A typical pipeline indexes a document collection as chunks, often with embeddings that place semantically similar text near each other in vector space. At query time, the system converts the question into the same kind of representation, retrieves candidate chunks through search, may rerank them, and inserts the top passages into the model prompt as context. The language model then generates a response conditioned on that retrieved context. In many systems, the output also includes citations or links back to the retrieved chunks. The quality of the final answer depends on several connected parts: chunking, indexing, retrieval, reranking, prompt construction, model behaviour and source quality. This is why evaluation should test not only answer style but also retrieval accuracy, citation faithfulness and failure handling when no good evidence is found.
Reviewed external resources
EncyclopaediaRetrieval-augmented generation (opens in a new tab)Wikipedia
This Wikipedia page gives a broad overview of the concept and suits readers who want a quick orientation before going deeper.
Intermediatelink checked 2026-07-31
CourseEmbeddings (opens in a new tab)Google
This Google course resource explains embeddings, which suits readers who want to understand how meaning-based retrieval is often built.
Intermediatelink checked 2026-07-31
InteractiveEmbedding Projector (opens in a new tab)TensorFlow
This interactive Embedding Projector lets readers explore how similar items cluster in vector space, which suits visual learners and technical beginners.
Starterlink checked 2026-07-31
VideoVideo explanations: Retrieval-augmented generation (opens in a new tab)YouTube search
This YouTube search results page helps readers compare different video explanations of the topic and suits people who prefer audiovisual introductions.
search results, not one pagelink checked 2026-07-31
DiscussionCommunity discussion: Retrieval-augmented generation (opens in a new tab)Reddit search
This Reddit search results page shows community discussions and practical questions about the topic, which suits readers who want informal perspectives alongside formal sources.
search results, not one pagelink checked 2026-07-31
Where this came from
Drafted with a language model through an offline pipeline, checked against this site's schema, and every external link above fetched to see whether it answers. Treat it as a starting point and check anything that matters against the primary sources. How this site is built and what that means.
The one thing to remember
RAG retrieves source passages and places them in the model’s prompt before it answers. This can improve relevance and traceability, but retrieved material may still be missing, outdated or misranked.