How AI Searches Before It Answers
A ground-up guide to retrieval-augmented generation: how documents become searchable evidence, how a model uses retrieved passages, what DoorDash’s cache-first gateway measured, and how retrieval can fail. This audio was created with Boson AI's Higgs Audio — https://www.boson.ai/higgs-audio
Listen on Spotify · Watch on YouTube · Pocket Casts
Why AI needs to look things up
Eris: <|emotion:enthusiasm|>Retrieval-augmented generation, or RAG, lets a model search source material before it answers. It finds relevant passages, places them beside the question, and asks the model to use that evidence; a company travel policy is one example.
Vestra: The distinction starts with two different stages. Training is when a model learns patterns from a large collection of examples by adjusting its internal numerical settings. Those settings are called parameters. They capture patterns and associations, including many facts, but they are not a live, complete database that the model can browse or update one record at a time.
Eris: <|prosody:pause|>Then inference is what happens when the trained model is being used: you send a question, and it produces an answer. If a policy changed yesterday, the model’s training may not contain that change. Even when it has encountered an older policy, its parameters don’t give it a dependable way to look up the current paragraph and show where a claim came from.
Vestra: External knowledge means material kept outside those parameters: a policy folder, product catalog, help center, research archive, or current web pages. RAG gives the model selected pieces of that material at inference time. That can make answers more current or more specific without retraining the model every time a document changes. The catch is that the search and the answer are two separate jobs, and each can fail.
Eris: So if I ask, “Can I expense a hotel for the conference?”, the system can search the current employee handbook and travel policy first. The answer has a chance to reflect the actual rule instead of a familiar-sounding pattern from training. <|emotion:fear|>The word “chance” matters: having the policy available is not yet proof the right passage was found or followed.
Vestra: The original RAG research makes that combination concrete. It paired a text-generating model, which the paper calls parametric memory, with a separate searchable collection of Wikipedia passages, called non-parametric memory. The researchers tested question answering, fact verification, and text generation. Their result was that this combination could use external passages while still generating a complete answer; replacing the searchable index could also update the knowledge source without retraining the generator.
Eris: “Memory” here is an engineering description, not a claim that a model remembers like a person. One store is encoded in learned parameters; the other is text the system can retrieve and inspect. That second store is useful precisely because someone can update the documents and, with the right pipeline, rebuild the search index. <|emotion:relief|>I like that distinction: changing a source is a concrete operation, not a metaphor for retraining a mind.
Vestra: <|prosody:pause|>But the 2020 paper used a particular setup: a December 2018 Wikipedia collection split into 100-word pieces and searched with a dense vector index. Its experiments show what that design did on the paper’s tasks. They do not establish that every current RAG system will be accurate, current, or suitable for private company policies.
Turning documents into a searchable library
Eris: Before an AI can search a policy library, someone has to make that library searchable. The system takes documents in formats such as web pages or PDFs, extracts their text, and divides it into smaller passages. Those passages are often called chunks. A chunk is just a manageable piece of a document that can be retrieved and shown to the model.
Vestra: <|emotion:enthusiasm|>Chunking creates a tradeoff. A large chunk keeps more surrounding explanation, which can preserve an exception or definition. But it also carries extra text that may distract the model and consumes more of its limited input space. A tiny chunk can be precise, yet cut a rule away from the sentence that explains who it applies to. Splitting at section or paragraph boundaries, keeping some overlap, and linking every chunk back to its source are ways to reduce those problems; none is universally best.
Eris: Picture a handbook sentence saying, “Contractors may use the lab after approval from the safety lead.” If the chunk contains only “may use the lab,” retrieval could lose the condition that changes the rule. A slightly wider passage may preserve the approval requirement. If the chunk is an entire hundred-page handbook, the key sentence can get buried in unrelated benefits and procedures. <|emotion:surprise|>That tiny boundary choice can decide whether the approval condition survives the search.
Vestra: <|prosody:expressive_high|>Next, an embedding model turns each chunk into an embedding: a list of numbers meant to represent aspects of its meaning. The same model, or a compatible paired model, turns a search query into a vector in the same numerical space. A vector is a point represented by numbers. Comparing the query point with stored chunk points gives a way to rank passages by semantic similarity, meaning similarity of subject or idea rather than exact wording.
Eris: That helps when the employee asks, “Can temporary staff access the lab?” and the handbook uses “contractors.” The words differ, but an embedding may put those ideas near each other. It is a similarity signal, though, not a truth detector. A passage can be close in meaning and still answer the wrong part of the question.
Vestra: The system stores the vector alongside the original text and information such as the document name, section, date, and access permissions. The searchable collection is often called an index or vector index. In a simplified exact search, the index compares the query with every stored vector and returns the nearest ones. A library such as FAISS provides index structures for storing vectors and searching with measures such as distance or dot product. <|emotion:elation|>That link back to the original text is the part I want to see preserved; otherwise similarity gives you a route with no destination to check.
Eris: Once that library grows, comparing every vector can take too long. Approximate nearest-neighbor search uses an index structure or compressed representations to search faster without comparing every candidate exactly. FAISS describes the tradeoff directly: index choices can change search time, quality, memory use, and the time it takes to build or update the index. A faster search can miss a passage that exact comparison would have ranked higher. <|emotion:fear|>So “faster” can quietly mean the missing exception never reaches the answer stage.
Vestra: Similarity search is not the only route. Keyword search looks for matching words or terms. It can be especially useful for a policy number, product code, surname, or exact phrase that an embedding might blur. Hybrid search combines keyword and semantic results, then merges or reranks them. The RAG survey describes these approaches as complementary: rare names and domain terms can be hard for dense semantic search, while semantic search can find related wording with few shared keywords.
Eris: Metadata can narrow the search too. “Only the current handbook, only for the US office” can become filters for document version and location. A timestamp can help rank recent policy above an archived copy. That makes freshness partly an indexing and maintenance problem: if the old document remains marked current, a clever retriever can faithfully find the wrong version. And it can do that perfectly, by the labels it was given.
Vestra: The survey lays out the wider design space: how documents are cleaned, how chunks are formed, what embedding model represents them, what index searches them, and whether keyword search supplements vectors. These are choices to test on the actual documents and questions. The source corpus is still the authority; the vector index is a route to it, not a replacement for it.
How a question becomes a short evidence packet
Eris: <|emotion:enthusiasm|>In retrieval-augmented generation, the system first turns a user’s query into a search representation compatible with the indexed passages. It searches for candidates, then returns a limited set. That is the retrieval step: finding material likely to help answer the question, before the language model writes the response.
Vestra: The basic pipeline might encode “Can temporary staff use the lab?” and compare that query vector with all the chunk vectors. It could take the highest-ranked handful. A more careful pipeline may also run exact keyword search for “contractor,” filter out an archived handbook, or apply a second ranking step to the candidates.
Eris: That second step is reranking. The first search is often built to retrieve candidates quickly; a reranker examines those candidates more closely against the query and moves the best evidence higher. Then the system selects a limited number to pass to the model. More passages can bring in a missing condition, but they also add latency, processing cost, and irrelevant text. <|emotion:enthusiasm|>That extra ranking stage is a useful rescue, but it still only reshuffles what the first search found.
Vestra: Metadata filters can enforce boundaries that semantic similarity cannot: a company region, a product version, an access role, or an effective date. The system should apply permission checks as well as relevance checks. A relevant document is not automatically one this user is allowed to see.
Eris: And a broad question may need more than one search. “Can I use the lab, and what training do I need first?” could require locating the access rule and then finding the separate training requirement. One fixed search can return a chunk about lab access and miss the training section entirely. <|emotion:surprise|>A single neat evidence packet may be incomplete before the model sees it.
Vestra: <|prosody:pause|>That is a multi-step question. An iterative retrieval system can use what it learned from one set of passages to form another query, retrieve again, and build a fuller evidence set. The survey distinguishes this from the simple one-search pattern. Iteration can uncover linked facts, but it can also accumulate unrelated passages or carry forward a mistaken first interpretation. Each step still needs evaluation.
Eris: The order of operations also affects speed and cost. A vector index trades memory and index-building work against search time and the closeness of its matches. The embedding model affects what “similar” means. Chunk size affects what can be found together. Reranking can improve selection but adds another computation. And the number of final passages decides how much evidence and noise the answer model sees.
Vestra: So there is no universal setting called “retrieve the right amount.” A team can measure whether the needed evidence appears among the candidates, whether its filters exclude valid material, how long a query takes, and what each retrieval stage costs. That gives the engineering team evidence for its choices instead of treating a library default as a quality guarantee.
Eris: <|emotion:relief|>I like that this makes the first half of a RAG answer inspectable. You can ask, “Did the right policy section arrive?” before asking whether the model explained it well. Those are distinct questions, and collapsing them hides where the failure started.
Vestra: Yes, and that gives the team a place to look before blaming the answer model for a passage it never received.
What the model does with retrieved evidence
Eris: In retrieval-augmented generation, selected passages are placed beside the original question in the model’s input. That surrounding material is called context. The language model then generates an answer using the question and retrieved text together. This is the generation step, after retrieval.
Vestra: In the original RAG paper, the generator could condition on the question plus a retrieved passage. One version used the same passage for the whole answer; another could combine information from different passages across the answer. The important general idea is simpler: give the model external text at inference time so it can use more than what was stored in its parameters during training. <|emotion:elation|>That range—from one passage to combining several—is a concrete mechanism, not just a promise to “ground” the answer.
Eris: If the prompt includes “Contractors may use the lab after approval from the safety lead,” a good answer can say access is allowed after that approval. The answer could also name the handbook section or link to the page. That source pointer is provenance: information about where a claim came from, so a person can inspect the original material.
Vestra: <|emotion:fear|>A citation or link improves traceability, but it does not certify the answer. The retrieved passage may be stale, mistaken, or only partly relevant. The model may ignore a condition, combine two passages incorrectly, or state something beyond what the text supports. The retrieval mechanism made evidence available; it did not force the generator to reason correctly from it.
Eris: <|emotion:fear|>And if the right paragraph never arrives, the answer stage can’t use it. It might still answer from patterns stored during training, or it might produce a plausible unsupported statement. That’s the uncomfortable seam: a polished response can conceal a retrieval miss.
Vestra: <|prosody:pause|>There is also the reverse failure. Search may return something that is related to the topic but does not contain the answer. Similarity is about closeness in representation, not whether the passage is accurate or sufficient. RAG evaluations therefore need to test both whether useful evidence was retrieved and whether the final answer is supported, correct, relevant, and properly sourced.
Eris: <|emotion:relief|>It helps to keep an “I don’t have enough evidence” option. If the passages cover lab hours but say nothing about contractor eligibility, the system should be able to say that eligibility isn’t established by the material it found. Otherwise retrieval becomes decoration around a guess.
Vestra: This evidence boundary also matters when documents conflict. A current signed policy and an old copied FAQ may say different things. The system needs rules for versions and source authority, and the answer should make uncertainty visible when the available records disagree. A citation that points to the wrong or weaker document can make an unsupported answer look more credible.
Eris: <|prosody:pause|>The original RAG study found that its generated answers were more specific and factual than a parametric-only baseline on some tasks it tested. That supports the idea that retrieved evidence can help. The authors also note that outside knowledge sources may be incomplete or biased, and their experiments used one particular Wikipedia snapshot. We should treat the result as evidence for that design and those tasks, not a promise attached to the label RAG.
DoorDash separates search from the model that reasons
Eris: <|emotion:surprise|>DoorDash’s Decoupled Search Grounding is one company’s engineering example of separating evidence retrieval from the model that reasons about it. Its Query Intent Understanding system interprets ambiguous marketplace searches. In the company’s example, “450 north” looked like a restaurant to the ungrounded model; catalog evidence and web search identified a craft brewery, helping the system route the intent toward alcohol listings.
Vestra: DoorDash reports that its gateway first normalizes a query, then checks an exact cache, followed by a semantic cache. An exact cache reuses the result for the same normalized query. A semantic cache can reuse a prior result for a sufficiently similar query. Only when both miss does the gateway call a configured search provider.
Eris: After a provider responds, DoorDash converts the result into a consistent package with a title, source URL, and snippet. The reasoning model remains separate from the retrieval gateway, so the company can change its search provider or reasoning model without rebuilding each application’s search integration. <|emotion:elation|>That boundary is elegant: each side can change without threading a new search integration through every application.
Vestra: <|emotion:amusement|>The structured response is also meant to protect output formats. DoorDash says native search sometimes caused a model asked for only “Yes” or “No” to add an explanation that broke a machine-readable contract. Returning search evidence as a separate tool result appeared to reduce that issue in their tests. It is a reported mitigation, not a guarantee that formatting will never fail.
Eris: <|prosody:pause|>What did the headline measure? DoorDash compared its gateway using Serper with Gemini’s integrated Google search on two query-intent data sets. Across both, DoorDash reports search-provider charges fell to around one-seventieth of the previous cost while measured accuracy stayed similar.
Vestra: Those are DoorDash’s results for those evaluated sets. The cost comparison covers search-provider charges. It excludes model inference, cache and gateway operation, embedding work, storage, and maintenance, so it does not establish the same total-cost change. The report also describes evaluation data sets; it does not report a randomized live-traffic experiment establishing the same outcome for every query.
Eris: There’s a useful counterexample in DoorDash’s own post. On FreshQA, a test built around recency-sensitive questions, native search beat DSG across the five models they tested. A provider with fresher indexing can be worth its cost when the answer changes quickly. DoorDash’s reported result is a case for choosing retrieval per workload, not one search design for every question.
Vestra: The cache sequence also creates a freshness decision. An exact or semantic match can be fast and avoid a new provider call, but a cached result can age out of date. How long a system keeps a result should depend on how quickly the answer can change and the cost of using stale information.
Eris: <|emotion:fear|>The example makes retrieval part of the system’s economics and reliability, rather than a hidden switch inside the model call. But the measured boundary stays important: their provider charges, their intent labels, their query mix, and their freshness test. Another organization would need to measure its own evidence quality, cache hit rate, total cost, and stale-answer risk.
Measuring evidence separately from answers
Eris: <|emotion:enthusiasm|>To evaluate retrieval-augmented generation, first inspect what the retriever found. Did it return the passages needed for the question? Were they relevant and sufficient, from the right source and version? This is a separate measurement from whether the final answer is good.
Vestra: The RAG survey describes retrieval measures such as whether a relevant result appears in the returned set and how high it ranks. It also separates generation questions: is the answer supported by the passages, does it address the user’s question, and is it factually correct? Those measures can disagree. A retriever can find the correct rule while the model misstates its exception; a correct answer can also come from the model’s learned knowledge even when retrieval missed.
Eris: A useful evaluation set should include fresh facts, private or domain-specific questions, exact names, questions with no answer in the corpus, distracting passages, and questions that need evidence from more than one section. Then you can measure retrieval relevance and coverage, answer support and correctness, source links, response time, and the complete cost. One workload result only describes that workload: a catalog-intent test doesn’t establish how the system handles current medical guidance or a multi-step policy question.
Vestra: <|emotion:fear|>It’s also important to check refusal when evidence is missing, conflicting, or stale. And to inspect citations, not just count them: does the cited source actually support the sentence it accompanies? A source list can be present while the key claim has no support.
Eris: The simplest RAG pipeline retrieves a fixed number of passages for every query, then generates once. That can waste search and crowd the prompt with irrelevant text when the question is simple or creative. It can also fail to retrieve enough evidence when a question has several parts. One fixed setting can be wasteful and still come up short.
Vestra: <|prosody:expressive_high|>Self-RAG is a research design that trains a model to make retrieval decisions and critique generated segments. It uses special reflection tokens: one signals whether retrieval would help; others rate whether a retrieved passage is relevant, whether the generated statement is supported by that passage, and whether the response is useful. At inference time the system can retrieve on demand, compare candidate continuations, and favor ones with better relevance and support judgments.
Eris: In the lab-policy example, a model could answer “What are the office’s usual hours?” from its current context, but decide to retrieve for “What is the current evacuation procedure?” It could then assess whether each returned passage really describes evacuation, and whether its answer is supported by that passage. That is more selective than always attaching the same five chunks to every question.
Vestra: Self-RAG learns those reflection signals from labeled examples. The researchers first train a separate evaluation model, called a critic, to predict judgments, then use it to prepare generator training examples that include the reflection tokens. At answer time, the generator produces those signals itself, decides whether to retrieve, and can rank candidate continuations by relevance, support, and usefulness. That design does not require a separate critic service for each answer. The authors report improvements over their tested baselines across several tasks, including answer and citation measures. Those results describe their model sizes, data, baselines, and evaluation settings. They do not show that ordinary deployed RAG systems already use this method, or that a model’s self-critique is always correct.
Eris: <|emotion:fear|>That worries me: a model can judge its own evidence and still miss when a citation doesn’t support its claim. A query needing two linked facts may also need iterative retrieval: find the first fact, use it to search for the next, then check that both sources support the conclusion. Self-RAG offers one way to decide when to retrieve and critique; it doesn’t make source maintenance or independent evaluation optional.
Vestra: <|emotion:determination|>RAG is most useful when a question depends on a changing or private collection that the model cannot reliably carry in its parameters. Its quality still depends on complete, current documents; faithful chunking; appropriate retrieval; and an answer that stays within the evidence. Missing, irrelevant, fragmented, or stale passages can all break the chain. A semantic match can be related and false. A cache can be quick and outdated. A fluent response can still outrun its sources.
Eris: <|emotion:relief|>The way to trust the system more is to find where its evidence came from, test whether retrieval found enough, and check whether each important answer claim follows from that evidence. That turns “the AI searched” into questions we can actually answer.
Wrap-up
Eris: <|emotion:contentment|>The separate December 1 news brief covers today’s headlines. Ground Truth at groundtruth.day follows every story we cover, every day, with the sources behind them.
Vestra: <|emotion:affection|>Thanks for listening. Follow AI in Detail, and tell us in the comments where retrieval fails in the systems you use.