Foundations: Why RAG, and What 'Good' Looks Like
Chapter 1: Foundations: Why RAG, and What "Good" Looks Like
A language model that cannot be updated without a multi-million-dollar retraining run, that confidently invents citations that do not exist, and that has never seen a single byte of your company's data, is not an enterprise knowledge system. It is, at best, a sophisticated autocomplete. This chapter names the problem precisely, defines the architectural shape of the solution, and demonstrates, through a concrete case study, why the obvious fifty-line baseline fails on real corpora. By the end of this chapter, you should hold a reference architecture in your head, a vocabulary for discussing its stages, and a checklist of failure modes that you can apply to any RAG system you encounter, including your own.
1.1 The Three Failure Modes of Parametric LLMs
Parametric LLMs store all of their knowledge in the weights of a neural network. That single architectural choice produces three independent failure modes, each of which is fatal for production knowledge work. Understanding them separately is important because RAG does not solve all three equally well, and conflating them leads to architectural mistakes.
1.1.1 Stale Knowledge
The knowledge inside a model is frozen at the moment its training run ends. GPT-4's training data effectively stops in late 2023; Claude 3.5 Sonnet's knowledge cutoff is April 2024; Llama 3.1 was trained on a corpus whose latest snapshot predates most of 2024. Whatever happened in your domain after that moment—new regulations, new products, new CVEs, new internal documentation—does not exist in the model's parameters. Asking a frozen model about post-cutoff facts produces one of three outcomes, in roughly decreasing probability: a hedged refusal, a confident fabrication, or a correct answer derived from incidental patterns in the training data (for example, a news article that happened to be in the corpus). None of these is reliable.
Consider a regulated financial services firm that needs to answer questions about Basel IV final rules, published in late 2023 and partially revised in 2024. A model trained before the revision will confidently assert compliance requirements that no longer apply. The cost of a wrong answer here is not a downstream hallucinated paragraph; it is a regulatory finding. This is the failure mode that motivated the entire field of "knowledge grounding" research at Meta and Google circa 2020: rather than retrain, retrieve.
1.1.2 Hallucination
Hallucination is the failure mode where the model produces fluent, syntactically valid, semantically wrong text. It comes in three flavors that the literature distinguishes but practitioners often collapse:
1. Factual hallucination: the model asserts something false about the world (e.g., "the Eiffel Tower is 450 meters tall" when it is actually 330 meters, or a citation to a paper that does not exist with an arXiv ID that resolves to nothing). 2. Faithfulness hallucination: the model's response is inconsistent with its own context. You give it a passage, it summarizes a different passage. This is the most common failure in RAG systems and is more insidious because the model looks superficially correct. 3. Instruction hallucination: the model invents tool calls, JSON structures, or API parameters that were never specified. Common in agentic systems.
Hallucination rates on closed-book benchmarks are substantial. On factual QA tasks like TriviaQA and Natural Questions, frontier models in 2023–2024 hover around 40–65% accuracy without retrieval, with a non-trivial fraction of the wrong answers being confidently stated falsehoods rather than expressed uncertainty. Even on tasks where the model "knows" the answer, faithfulness hallucination can corrupt retrieved-context-grounded responses: studies have shown that on summarization tasks, transformer models produce summaries unfaithful to the source document roughly 5–10% of the time, and that rate increases when the source is long or unfamiliar.
The deeper problem is that hallucination is not a bug to be patched; it is the default behavior of a system that has learned to maximize the likelihood of plausible continuations. Decoding strategies like nucleus sampling, beam search, and even temperature zero all produce hallucinations; they just produce different ones.
1.1.3 Private Corpus Blindness
The third failure mode is the one that actually drives enterprise adoption. Parametric LLMs cannot, by construction, answer questions about your internal wiki, your customer support tickets, your proprietary codebase, your supplier contracts, or your internal M&A memos. None of that data is in the training set, and—setting aside legal and ethical issues—fine-tuning on it is expensive, slow, and creates a new frozen snapshot every time you retrain. Even when fine-tuning is feasible, it does not actually solve the knowledge freshness problem; it merely pushes the staleness horizon forward by the duration of one training run.
This is the failure mode where RAG provides the most direct leverage. Retrieval-augmented systems can answer questions about a document that was added to the index thirty seconds before the query. They can cite their sources, they can be audited, and they can be rolled back by deleting a document from the index.
1.1.4 Why These Failures Are Not Independent
The three failure modes interact in ways that complicate system design. A model with stale knowledge that hallucinates about private data is the worst combination: confident, wrong, and unverifiable. This is why the engineering community has converged on RAG not as a "make the model smarter" intervention but as a "make the system auditable and grounded" intervention. The metric you should care about is not whether the model knows the answer; it is whether the system can produce a verifiable chain from question to evidence to answer.
That distinction—between model knowledge and system knowledge—is the conceptual foundation for everything that follows.
1.2 The Five-Stage Canonical Architecture
Retrieval-Augmented Generation is not an algorithm. It is an architecture, and at its core it has five canonical stages. Different frameworks package these differently. LangChain, LlamaIndex, Haystack, and bespoke enterprise systems all draw the same box diagram with slightly different names. Getting the canonical shape right is more important than any individual technique, because it determines where you can intervene when quality regresses.
The five stages are: Ingestion, Indexing, Retrieval, Augmentation, and Generation. Feedback loops run between them in production systems. The figure below shows the canonical pipeline.
```mermaid flowchart LR A[Ingestion] --> B[Indexing] B --> C[Retrieval] C --> D[Augmentation] D --> E[Generation] E --> F[User] F -. feedback .-> A F -. feedback .-> C C -. feedback .-> B E -. feedback .-> D ```
1.2.1 Stage One: Ingestion
Ingestion is the process of acquiring documents and converting them from whatever format they live in—PDF, DOCX, HTML, Confluence export, Slack thread, scanned image, audio file—into a normalized, machine-readable representation. The naive assumption is that ingestion is trivial: pull text out of a PDF, move on. The reality is that ingestion is where most production RAG systems silently lose 30–60% of their available signal.
Concrete ingestion problems:
- **PDF tables**: a typical financial 10-K contains dozens of nested tables. Most PDF text extractors flatten them into a stream of words in the wrong reading order, which is worse than dropping them. A row labeled "Total" ends up in a context window with no associated numbers.
- **Headers and footers**: page numbers, document titles, "Page X of Y" footers, confidentiality stamps, and recurring section headers get repeated thousands of times in the corpus. If you do not deduplicate or filter them, they consume embed