What is RAG in AI?
RAG lets an AI look things up in your documents before it answers, so it can quote fresh, private facts instead of guessing from memory.
Rung 1 Explain like I'm 6
Imagine two kinds of tests at school. In a closed-book test you can only use what is in your head, so if you forgot something you might guess. In an open-book test you can flip to the right page first, read it, and then write your answer.
RAG turns an AI's test into an open-book test. Before it answers your question, it looks through a pile of pages, picks the few that matter, and reads them. Then it answers using those pages. That way it can talk about things it never learned, like your school's lunch menu for this week.
Rung 2 High-school level
A large language model (LLM) learns from a huge amount of text, then stops learning. Its knowledge is frozen at a cutoff date, and it never saw your company's private files. Ask it about either and it may make up a confident wrong answer, which people call a hallucination.
Retrieval-augmented generation (RAG) fixes this in three steps:
- Retrieve. Search a collection of documents for the passages most related to the question.
- Augment. Paste those passages into the prompt, next to the question.
- Generate. The model writes its answer from the pasted text, ideally citing it.
The search usually works on meaning, not exact words. Each passage is turned into a list of numbers called an embedding, and passages with similar meaning get similar numbers. These are stored in a vector database so the closest ones can be found fast.
People often ask about RAG vs fine-tuning. Fine-tuning changes the model itself by training it more. RAG leaves the model alone and changes what it reads. To update RAG you just add or edit documents.
Check yourself: In RAG, does the model's training change when you add a new document?
No. Only the document collection changes; the model reads the new text at answer time.
Rung 3 Undergraduate level
A basic RAG pipeline has an offline half and an online half.
Offline (indexing). Split documents into chunks, say a few hundred words each. Run each chunk through an embedding model to get a vector. Store vectors plus the original text in an index.
Online (query). Embed the user's question with the same model. Find the top-k chunks by similarity, usually cosine similarity or inner product. Build a prompt: instructions, the k chunks, then the question. Send it to the LLM.
A tiny example with 3-number embeddings:
- question q = (1, 0, 1)
- chunk A = (1, 0, 1) "Refunds take 5 days"
- chunk B = (0, 1, 0) "Our office is in Pune"
Cosine(q, A) = 2 / (√2·√2) = 1.0. Cosine(q, B) = 0 / (√2·1) = 0. So A is retrieved and pasted into the prompt, and the model answers "5 days".
Real embeddings have hundreds or thousands of dimensions, and exact search over millions of chunks is slow, so systems use approximate nearest-neighbour indexes. The original 2020 RAG paper indexed Wikipedia as 21 million 100-word chunks, searched them with a dense retriever, and fed the top results to a 400M-parameter BART generator [1].
Many systems mix dense search with keyword search (such as BM25) and then rerank the candidates with a slower, more accurate model before building the prompt.
Rung 4 Graduate level
The design choices are mostly about recall, precision and cost.
Chunking. Small chunks match questions precisely but lose context; large chunks keep context but dilute the match and eat prompt space. Overlapping windows and attaching section titles are common fixes.
Retriever. Dense embeddings handle paraphrase; keyword search handles rare names, codes and exact phrases. Hybrid retrieval plus a reranker is a common default because each covers the other's blind spots.
How much to retrieve. More passages raise the chance the answer is present but not that the model uses it. Liu et al. (2023) showed models do best when the relevant text sits at the start or end of a long input and noticeably worse when it sits in the middle [2]. So stuffing the context window is not free, even with long-context models.
RAG vs fine-tuning. RAG suits facts that change, need citations, or must respect per-user access rights, since you can filter what each user retrieves. Fine-tuning suits behaviour: tone, format, a narrow skill. They combine well: fine-tune for style, retrieve for facts.
RAG vs MCP. These are different layers. RAG is a pattern: fetch text, put it in the prompt. The Model Context Protocol (MCP), released by Anthropic in November 2024, is an open standard for connecting AI apps to data sources and tools [3]. An MCP server can be the thing a RAG system retrieves from, or it can expose actions that have nothing to do with retrieval.
Evaluation. Measure retrieval (did the right chunk make the top-k?) separately from generation (did the answer stay faithful to the chunks?). A failure in either looks the same to the user.
Check yourself: Why can retrieving more passages make a RAG answer worse?
Models tend to miss relevant text buried in the middle of a long context, and extra passages add noise and cost.
Rung 5 PhD level
Lewis et al. (2020) framed RAG as a model with two memories: parametric (the generator's weights) and non-parametric (a dense index over Wikipedia), trained end to end with the retrieved document treated as a latent variable [1]. Most production RAG today drops the joint training and bolts a frozen retriever onto a frozen LLM. That is cheaper but leaves a mismatch: the retriever optimises similarity, not usefulness to the generator.
Open problems:
- Faithfulness. Even with the right passage in context, models can ignore it in favour of what their weights say, or blend the two. Detecting which source an answer came from remains hard.
- Position and length effects. The U-shaped accuracy curve over context position [2] means retrieval quality and prompt layout interact; longer windows have not made ordering irrelevant.
- Multi-hop questions. One retrieval round fails when the answer requires chaining facts ("the CEO of the company that bought X"). Iterative retrieval, query rewriting and graph-structured indexes target this, at higher latency.
- Retrieval as a security surface. Retrieved text is untrusted input. A planted document can carry instructions the model may follow (indirect prompt injection), so access control and content isolation matter as much as relevance.
- Evaluation. Benchmarks with fixed corpora overstate real performance, where corpora are messy, duplicated and out of date.
A live research question is whether RAG survives as a fixed pipeline or becomes one tool that a reasoning model decides when and how to call.
Rung 6 State of the art: what experts work on now
Last checked 18 November 2026.
As of 2026-11-18.
The main shift since 2024 is from a fixed retrieve-then-generate pipeline to agentic RAG, where the model plans, decides whether to search, rewrites queries, checks results and searches again. A January 2025 survey maps these designs, from single-agent routers to multi-agent setups [4].
Retrieval is also being learned rather than hand-wired. Search-R1 (2025) trained models with reinforcement learning to interleave reasoning with search-engine calls, and reported 41% (Qwen2.5-7B) and 20% (Qwen2.5-3B) improvements over various RAG baselines across seven question-answering datasets [5].
The plumbing has standardised too. MCP, launched in November 2024 [3], gives models one protocol to reach data sources and tools, so a retriever is increasingly just one MCP server among many. On 9 December 2025 Anthropic donated MCP to the Agentic AI Foundation, a Linux Foundation directed fund co-founded with Block and OpenAI [6]. That is why "rag vs mcp" is a common search: MCP is the connector, RAG is one thing you do through it.
Long-context models have not replaced retrieval. Position effects documented in 2023 [2] still motivate retrieving a few good passages instead of pasting everything.
Sources
- Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks (NeurIPS) (2020)
- Liu et al., Lost in the Middle: How Language Models Use Long Contexts (2023)
- Anthropic, Introducing the Model Context Protocol (2024)
- Singh et al., Agentic Retrieval-Augmented Generation: A Survey on Agentic RAG (2025)
- Jin et al., Search-R1: Training LLMs to Reason and Leverage Search Engines with Reinforcement Learning (2025)
- Anthropic, Donating the Model Context Protocol and establishing the Agentic AI Foundation (2025)