What Is RAG?

Retrieval-Augmented Generation — how AI searches external data to answer accurately, instead of guessing from memory.

Watch It

Why RAG? The Problem It Solves

WITHOUT RAG
Q: "What was the Q3 revenue for Acme Corp? A: "Based on my training, Acme Corp Q3 revenue was $47 million. " Wrong! Actual was $52M
The model guesses from its training data. It sounds confident but gets the date wrong. RAG solves this by letting the AI look up the correct information from a trusted source before answering. <sup style='font-size:0.7rem'><a href='https://en.wikipedia.org/wiki/Retrieval-augmented_generation' style='color:var(--accent)'>[1]</a></sup>
Pipeline

How RAG Works: 4 Steps

The AI does not guess — it retrieves, reads, then answers.

🔍
1. User Asks a Question
Tap to flip
The user submits a query (e.g. “What’s our Q3 revenue?”). This is passed to the RAG system, which recognises it needs fresh or specific information beyond the model’s training data.
📁
2. Retrieve Relevant Documents
Tap to flip
The system searches a knowledge base (vector database, enterprise docs, internal data) for the most relevant content. Usually this uses semantic search — finding documents by meaning, not keywords.
🧠
3. Augment the Prompt
Tap to flip
The retrieved documents are inserted into the LLM prompt as context. The model sees: “Using the following documents, answer the question: [docs] [query]”. This is the “augmentation” step — giving the model the facts it needs.
✍️
4. Generate the Answer
Tap to flip
The LLM generates an answer grounded in the provided documents. Since the docs contain the facts, the model does not need to recall from memory. This drastically reduces hallucinations and keeps answers current.
🔄
Optional: Chunking + Embedding
Tap to flip
Before retrieval, documents are split into chunks (e.g. 500 tokens each) and converted to vector embeddings — dense number arrays that capture meaning. These are stored in a vector database for fast similarity search.
🔒
Optional: Guardrails & Filtering
Tap to flip
Production RAG systems add security layers: access control (who can see which docs), toxicity filtering, and relevance verification. Some use a secondary LLM to check if the retrieved documents actually answer the question.
Compare

RAG vs Fine-Tuning vs Base LLM

Each approach has trade-offs. RAG is often the best starting point.

📄
Base LLM (No RAG)
Tap to flip
The model answers entirely from its training data. No external data, no real-time info. Fast but prone to hallucination on recent or niche topics. Knowledge is frozen at the training cut-off date.
⚙️
Fine-Tuning
Tap to flip
The model is further trained on domain-specific data to adapt its behaviour or knowledge. Expensive and time-consuming, but improves tone and style. Knowledge still becomes stale over time. [2]
🛠️
RAG (Retrieval-Augmented)
Tap to flip
The model retrieves fresh data at query time. Keeps answers current without retraining. Much cheaper than fine-tuning. Reduces hallucinations. Best for customer support, knowledge bases, internal search.
🪄
RAG + Fine-Tuning (Blend)
Tap to flip
The best of both worlds: fine-tune for tone/format compliance, then use RAG for factual retrieval. The model sounds right AND stays current. This is the most common production architecture for enterprise AI.
⚠️
RAG Limitation: Latency
Tap to flip
RAG adds retrieval time (100ms–2s per query). The system needs to search, fetch, and embed documents before the LLM can answer. Not ideal for real-time applications that need sub-second responses.
💡
RAG Limitation: Garbage In
Tap to flip
RAG is only as good as the quality of the retrieved documents. If the search returns irrelevant or incorrect documents, the LLM will confidently incorporate that bad data. “Garbage in, garbage out” applies to RAG too.
Quiz

RAG Knowledge Check

6 questions. Test your understanding of retrieval-augmented generation.

About how RAG works:

RAG retrieves information from the internet in real time every time you ask a question.

About training:

Using RAG requires retraining or fine-tuning the LLM.

About accuracy:

RAG can help reduce AI hallucinations by grounding answers in retrieved documents.

About history:

RAG was introduced by Meta AI in a 2020 paper.

About document quality:

RAG always improves response quality regardless of the documents retrieved.

About the retrieval step:

RAG typically uses semantic search (vector similarity) rather than keyword matching to find relevant documents.

Use Cases

When to Use RAG

The more your AI needs current or specific knowledge, the more RAG helps. Slide to see use cases.

30
050100
Slide the dial
Key Takeaways

RAG: What to Remember

Tap to check off each concept you have understood.

RAG = Retrieve + Augment + Generate
The system searches external data, adds it to the prompt, then the LLM answers using that context. Three distinct steps.
No retraining needed
RAG works with any LLM without modifying it. Just change the documents in the knowledge base to update answers.
Reduces hallucinations
By giving the LLM the facts in the prompt, RAG reduces the chance of it guessing from memory. Source: Wikipedia [1]
Introduced by Meta in 2020
The RAG paper was published by Meta AI. It has since become the standard architecture for production LLM applications.
Quality depends on retrieval
RAG is only as good as the search system. Bad documents = bad answers. Invest in your knowledge base quality.
Latency is the trade-off
RAG adds retrieval time (100ms–2s). For real-time apps, consider caching or hybrid approaches.
Blend with fine-tuning for best results
Fine-tune for tone and format. RAG for facts. Together they produce the best enterprise AI systems.