Understanding RAG — The Big Idea 6 topics
- Why plain LLMs aren't enough
Ask ChatGPT (or any large language model) "What is our refund policy?" and it will confidently make something up — because it has never seen your company's refund policy. It was trained on a huge slice of the public internet up to some cutoff date, then frozen. It doesn't know about documents it has never read, and it doesn't automatically know when it's wrong. This shows up as two separate problems: - **Hallucination** — the model states something false with total confidence, because generating a plausible-sounding sentence is literally what it was built to do. It isn't lying; it simply has no built-in concept of "I don't actually know this." - **Staleness** — even what the model *does* know is frozen at its training cutoff. A model trained in early 2024 has never heard of a product you launched last month, a policy you changed last week, or an internal wiki page that has always been private. ```mermaid %% title: What a frozen model can and cannot see flowchart LR T["Public internet,<br/>up to the training cutoff"] --> M["Language model<br/>(frozen after training)"] M --> ANS["Answers from memory<br/>— and guesses when unsure"] P["Your private documents"] -. never seen .-> M R["Last week's policy change"] -. never seen .-> M W["Your internal wiki"] -. never seen .-> M ``` > 🏢 **Business case:** A telecom company's support chatbot, built on a plain LLM, once told a customer their unused data would "roll over automatically" — that had never been true. The team spent more on the resulting complaints and refunds than the chatbot project had cost to build. The fix wasn't a smarter model; it was giving the *existing* model the actual, current policy document to read before it answered. Retrieval-Augmented Generation (RAG) exists to solve exactly this pair of problems: it hands the model your real, current, private documents at the moment it's asked a question, instead of asking it to answer purely from memory. > 🌍 **In the wild:** This problem is well known enough that major cloud providers sell products specifically to fix it. Google Cloud's Vertex AI platform ships a feature literally called "grounding" that retrieves real, current sources before the model answers — the exact RAG idea you're about to learn, offered as a paid, managed product because so many businesses hit this exact wall. > 💡 **Tip:** Whenever you catch a language model confidently stating something you know to be wrong or outdated, ask yourself: "did this model actually have access to the source document, or was it guessing from training data?" That question is the seed of every RAG use case you'll design in this course. - What RAG actually is — the open-book exam metaphor
Imagine two students taking the same history exam. Student A has to answer purely from memory — anything they don't remember, they have to guess. Student B is allowed to bring the entire textbook into the exam room, look up the relevant chapter for each question, and then write their answer using both what they remember *and* what's on the page in front of them. Student B will always be more accurate, especially on obscure or recently-added facts. Retrieval-Augmented Generation turns every language model into "Student B." Concretely, RAG is a two-step process for answering any question: 1. **Retrieve** — search your own collection of documents for the handful of passages most relevant to the question being asked. 2. **Generate** — hand those passages to the language model *along with* the question, and ask it to answer using only what's in front of it. The name is literally a description of the process: **R**etrieval, **A**ugmented (the prompt is "augmented" with real content), **G**eneration (the model then generates the final answer). ```mermaid %% title: The three steps of every RAG answer flowchart LR Q["User question"] --> R["Retrieve:<br/>search your documents"] KB[("Your documents")] --> R R --> A["Augment:<br/>question + retrieved passages<br/>go into one prompt"] A --> G["Generate:<br/>language model writes<br/>the answer from that prompt"] G --> ANS["Grounded answer<br/>(+ citation)"] ``` > 💡 **Tip:** When you're explaining RAG to a non-technical stakeholder, skip the acronym entirely and use the open-book exam line — "we give the model the right page of the textbook before we ask it the question." It lands every time. > 🌍 **In the wild:** You've likely already used RAG without knowing its name. Reddit's own "Reddit Answers" feature retrieves real posts and comments from across the site before writing a summary answer — the "textbook" is the site's own content. Gmail's built-in Gemini assistant works the same way when you ask "when is my flight" — it retrieves the actual confirmation email from your inbox rather than guessing. And on X (formerly Twitter), the Grok assistant answers questions about "what's happening right now" by retrieving real, live posts from X first, then writing an answer grounded in them. Crucially, RAG doesn't change the language model itself at all. The same underlying model — say, a general-purpose assistant — becomes an expert on *your* company's HR policy, *your* product catalogue, or *your* medical guidelines purely because of what it's shown at answer time, not because it was retrained. - RAG vs. fine-tuning vs. plain prompting — choosing the right tool
There are three broad ways to make a language model behave the way you need. Beginners often reach for the most expensive one first, so it's worth knowing all three before you commit to anything. | Approach | What it does | Good for | Not good for | |---|---|---|---| | **Plain prompting** | You just ask well — clear instructions, maybe an example or two, in the message itself | Formatting, tone, simple reasoning tasks | Anything requiring facts the model was never trained on | | **RAG** | Retrieves relevant documents and includes them in the prompt at answer time | Grounding answers in current, private, or frequently-changing information | Teaching the model a brand-new *skill* or *style* it fundamentally lacks | | **Fine-tuning** | Retrains (part of) the model's internal weights on examples of the behaviour you want | Teaching a durable new skill, tone, or output format at low cost per call | Keeping the model up to date with fast-changing facts (you'd have to retrain constantly) | > 🏢 **Business case:** A legal-tech startup initially planned to fine-tune a model on their entire contracts database so it would "know" every clause. It was slow, expensive, and — worse — every time a contract was amended, they'd need to retrain again. They switched to RAG: the model stayed exactly as it was, and every answer simply retrieved the current version of the relevant clause. Cost dropped by an order of magnitude and answers became *more* accurate, because they were always based on the latest document, not a snapshot from training day. A useful rule of thumb: if the problem is **"the model doesn't know this fact"**, reach for RAG. If the problem is **"the model doesn't know how to do this kind of task at all"**, fine-tuning (or better prompting) is the right lever. Many production systems eventually use both — but nearly everyone should start with RAG, because it's cheaper, faster to build, and easier to keep current. ```mermaid %% title: Which lever to reach for flowchart TD START["The model isn't behaving how I need"] --> Q1{"Is it missing a<br/>FACT it was never taught?"} Q1 -- "Yes" --> Q2{"Does that fact change<br/>often, or is it private?"} Q2 -- "Yes" --> RAG["Use RAG<br/>(retrieve the current document<br/>at answer time)"] Q2 -- "No, it's fixed & small" --> PROMPT["Just put the fact<br/>in the prompt"] Q1 -- "No, it lacks a SKILL,<br/>tone or output format" --> Q3{"Can better instructions<br/>or examples fix it?"} Q3 -- "Yes" --> PROMPT2["Improve the prompt<br/>(few-shot examples)"] Q3 -- "No, it needs it baked in" --> FT["Fine-tune"] ``` > ⚠️ **Watch out:** RAG cannot fix a model that is bad at reasoning, or teach it a tone of voice it can't already produce. It only ever adds *facts* to a prompt — it doesn't change how the model thinks. - Real-world RAG in action — five industries, five examples
RAG is not a lab curiosity — it's already the backbone of many assistants you may have used without realising it. Five concrete examples, one per industry: ```mermaid %% title: Where RAG shows up in the real world mindmap root((RAG in<br/>the wild)) Customer support Return & refund policy Product manuals Internal knowledge HR handbook IT runbooks Legal & compliance Contract clause lookup Regulatory filings Healthcare Clinical guideline lookup Sales enablement Battlecards & pricing Public products Reddit Answers Gmail Gemini X Grok ``` 1. **Customer support (e-commerce).** A shopper asks "can I return this after the holiday season?" The assistant retrieves the exact, current return-window policy for that product category and answers from it — instead of guessing from generic e-commerce knowledge. 2. **Internal knowledge search (any large company).** An employee asks "how do I file an expense claim over ₹50,000?" The assistant searches the company's internal wiki/HR portal and answers with the actual current process, including who needs to approve it. 3. **Legal and compliance research.** A paralegal asks "what does clause 14.2 of the vendor agreement say about liability caps?" The assistant retrieves that exact clause from the actual signed contract, rather than describing what such a clause "typically" says. 4. **Healthcare guideline lookup.** A nurse asks "what's the current dosage guideline for this medication in paediatric patients?" The assistant retrieves from the hospital's current, approved clinical guidelines document — never from general internet knowledge, which could be outdated or region-specific. 5. **Sales enablement.** A sales rep asks "what's our competitive positioning against Competitor X for the enterprise tier?" The assistant retrieves the latest battlecard the marketing team uploaded last week. > 💡 **Tip:** Notice the pattern across all five: a *specific* question, about *specific*, *changeable* information, that lives in a document somewhere. That pattern — "a real document holds the true answer" — is the single best signal that a use case is a good fit for RAG. > 🌍 **In the wild:** The same pattern shows up at companies you already know. LinkedIn uses retrieval-style techniques in its "Collaborative Articles" AI features, pulling from real member-contributed knowledge rather than generating from scratch. Reddit's Answers feature retrieves real community discussions before answering. AWS sells a managed product for exactly this — Amazon Bedrock Knowledge Bases and Amazon Kendra — so that any company can plug their own document library into a retrieval pipeline without building one from scratch, and Google Cloud offers the direct equivalent with Vertex AI Search. You'll pick one of these (or a similar use case of your own) as your working example for the rest of this course — the same knowledge base will follow you from the concept modules all the way to your capstone. - The business case: cost, ROI and risk reduction
Before you build anything, it helps to be able to make the case for *why* a business should invest in a RAG assistant at all. Three angles matter most: ```mermaid %% title: Three ways a RAG assistant pays for itself flowchart TD RAG["RAG assistant"] --> D["Cost deflection:<br/>fewer repeat questions<br/>reach a human"] RAG --> S["Speed & availability:<br/>answers in seconds, 24/7,<br/>no manual retraining"] RAG --> G["Grounding & audit:<br/>every answer cites a<br/>fixable source document"] D --> ROI["Lower cost per<br/>answered question"] S --> ROI G --> TRUST["Enough trust to<br/>expand the assistant's scope"] ``` **1. Cost deflection.** Every question a RAG assistant answers correctly is a question a human support agent, HR generalist, or paralegal didn't have to spend time on. Teams typically track this as a *deflection rate* — the percentage of incoming questions fully resolved by the assistant without a human. Even a modest 20–30% deflection rate on a high-volume support queue can be a large recurring saving. **2. Speed and availability.** A RAG assistant answers in seconds, at 3 a.m., in any timezone, without needing to be trained on every policy update by hand. For a global business, this alone can be the deciding factor. **3. Risk reduction through grounding.** Because a well-built RAG system answers *from* a specific document and can *cite* it, mistakes are traceable and auditable — you can always find out exactly which document produced a wrong answer and fix that document, rather than trying to "un-teach" a fine-tuned model. > 🏢 **Business case:** An HR team estimated that 40% of employee queries to the People team were repeat questions already answered in the employee handbook. They built a RAG assistant over the handbook. Within a quarter, first-line HR queries to actual humans dropped by a third, and — because every assistant answer cited the exact handbook section — HR could trust it enough to expand it to benefits questions the following quarter. > 💡 **Tip:** When pitching a RAG project internally, don't lead with the technology. Lead with a number: "X% of our support tickets are questions our own documentation already answers." That's your business case in one sentence — and it's exactly the memo you'll write for this course's first assignment. - Where RAG shines and where it struggles
RAG is powerful, but it is not magic, and setting the right expectations early will save you a lot of frustration later. ```mermaid %% title: Good fit vs. poor fit for basic RAG flowchart TB Q["A user question"] --> C{"Does the answer live in one<br/>findable, current document?"} C -- "Yes" --> SHINE["RAG shines:<br/>policy / price / spec lookup,<br/>answered with a citation"] C -- "No" --> S2{"What kind of question is it?"} S2 -- "Needs many docs<br/>synthesised" --> HARD1["Needs extra design<br/>(multi-document reasoning)"] S2 -- "Live system state" --> HARD2["Not a retrieval problem<br/>at all"] S2 -- "Docs contradict<br/>each other" --> HARD3["Fix the knowledge<br/>base first"] ``` **Where it shines:** - Answering questions where the true answer lives in a specific, findable document. - Domains that change often (policies, prices, product specs) where retraining a model constantly would be impractical. - Situations where you need to *show your work* — a citation back to the source document builds trust. **Where it struggles:** - **Questions that require reasoning *across* many documents** — e.g. "summarise how our returns policy has changed over the last three years" requires synthesising several versions, which a simple retrieve-then-answer pipeline handles poorly without extra design. - **Documents that are poorly organised or contradictory.** If your knowledge base itself has two conflicting versions of a policy, RAG will faithfully retrieve and repeat the confusion. - **Very short, ambiguous questions** with no clear match in the knowledge base — the retriever may return irrelevant passages, and the model may still try to answer from them. - **Real-time facts that no document captures** — "how many people are in the support queue right now" is a live-systems question, not a document-retrieval question. > ⚠️ **Watch out:** The single most common beginner mistake is assuming RAG will be accurate simply because it "has access to documents." It's only as good as (a) how well those documents are chunked and organised, and (b) how good the underlying retrieval and prompt design are — both of which you'll practise hands-on later in this course. > 💡 **Tip:** Keep a running list of the *bad* answers your system gives while you're building. In this field, a well-kept "why did it get this wrong" log is worth more than a dozen textbook examples of it going right.