Why LLMs Forget — and How RAG Remembers
Chapter 1: Why LLMs Forget — and How RAG Remembers
In June 2023, a federal court in New York was forced to do something no judge had ever needed to do: sanction a lawyer for submitting a brief that cited six completely fictional court cases. The lawyer had used ChatGPT to draft a legal motion, and the model had invented the cases — complete with plausible-sounding captions, realistic citation formats, and confident paragraph-long summaries of decisions that had never been written. The cases did not exist. The judges did not exist. The legal reasoning was assembled from statistical patterns, not from any lookup of legal reality. The lawyer later said, under oath, that he had "did not comprehend" that the chatbot could fabricate sources. He lost his case, his credibility, and his professional standing in a single afternoon.
This is not a one-off mistake. It is the predictable, structural failure mode of every large language model in production today. The same model that can explain quantum entanglement to a ten-year-old, write a working Python script for sorting algorithms, and compose a sonnet in the style of Emily Dickinson will, when asked about a niche topic, blend plausible vocabulary with invented facts at a speed and confidence that makes the falsehoods nearly indistinguishable from the truth. The model is not lying. It does not know what lying is. It is doing exactly what it was trained to do: producing the most statistically likely next token. When the training data runs thin, the model fills the gap with a fluent dream.
Retrieval-Augmented Generation, the technique this entire book is built around, exists because of that one stubborn fact. It is the engineering answer to a question that no amount of model scaling has solved: how do you give a closed-box language machine a reliable memory that does not fade, drift, or hallucinate? This chapter is your opening move. By the end of it, you will understand exactly why raw LLMs are dangerous for serious knowledge work, what RAG actually does, how it evolved from libraries and search engines you have probably never thought about, and where it fits in the landscape of real-world applications. You will also see the high-level architecture of a RAG system, drawn plainly enough that you can sketch it on a napkin or explain it to your parents over dinner.
1.1 The Hallucination Problem Is Not a Bug — It Is the Architecture
The first thing to internalize is that an LLM "hallucinating" is roughly as surprising as a calculator producing a number when you press its buttons. The model was designed to produce text. It was not designed to know whether that text was true.
To understand this, strip away the marketing. A large language model is a function with somewhere between a few billion and a few trillion numerical parameters. You feed it a sequence of tokens — words, parts of words, punctuation marks, the occasional special symbol — and it computes a probability distribution over every possible next token. The training process adjusted those numerical parameters across months of computation on giant corpora of text so that the next-token probabilities match the patterns observed in human writing. There is no database. There is no fact table. There is no retrieval. There is only an enormous network of weighted sums and nonlinearities that has learned, with eerie precision, the statistical texture of language.
This means the model's "knowledge" is implicit, distributed, and lossy. When you ask, "Who won the 2022 World Series?", the model does not look up the answer. It activates patterns associated with the phrase "2022 World Series winner," and those patterns make the tokens "Houston Astros" overwhelmingly likely compared to "Atlanta Braves" (the actual 2021 winners). It gets the answer right because the relevant pattern is dense in the training corpus. But ask about the score of a game played last Tuesday, and the training data simply does not contain it. The model must guess. And because it has been trained to always produce a fluent answer, it will produce one — a fluent, confident, and almost certainly wrong answer.
This is hallucination. It is not a temporary engineering flaw that a future model version will eliminate. It is an inevitable consequence of what the model is. A pure language model cannot, by construction, distinguish between "this fact is in my training distribution and I can recall it" and "this fact is not in my distribution and I am pattern-matching to invent something plausible." Both cases produce tokens with high probability. Both cases look identical from the model's perspective.
The Mata v. Avianca case is the canonical example, but the phenomenon shows up everywhere if you know where to look. In February 2024, Air Canada was ordered by a Canadian tribunal to honor a refund policy that its own chatbot had invented — the airline argued it could not be held responsible for what its customer service AI said, and the tribunal disagreed, ruling that the company was liable for the AI's hallucinated promise. In February 2023, Google's promotional demo of Bard produced a confidently wrong answer about which satellite first photographed a planet outside our solar system, costing the company an estimated one hundred billion dollars in market capitalization within a day. These are not edge cases. They are the central failure mode of the technology.
For a teenager reading this, the analogy is straightforward. Imagine a student who has read every textbook in the school library, absorbed every Wikipedia page, and studied every published essay — but has never opened a single notebook during class, has never taken a test with notes allowed, and has never had a conversation with anyone after graduation. Now put that student in front of a research question about a recent event. The student is brilliant. The student has encyclopedic knowledge of things that happened before a certain date. But the moment the question touches anything outside that vast but closed library, the student will invent a plausible-sounding answer rather than admit ignorance, because the student has been graded their entire life on producing fluent text, not on knowing what is true. That is a hallucinating LLM.
The severity spectrum matters too. A hallucination can be a trivial error — slightly wrong year for a movie release, a misspelled author name that almost looks right — and these are often tolerable. But it can also be a fabricated medical dosage, a nonexistent legal precedent, a made-up source for a school paper, or a confidently stated false statistic about a public figure. The same architecture produces both the harmless and the catastrophic. From inside the model, they feel identical. The model is doing the same thing in both cases. The only difference is what is at stake on the receiving end.
This is the fundamental problem RAG exists to solve. Not by making the model smarter. Not by adding more parameters. But by changing the architecture of the answer itself: instead of asking a closed-box predictor to remember everything, you give it a window — a small, targeted, current window — into the actual facts of the world, and you tell it to answer using what it sees in that window. You are giving the brilliant student an open-book exam and grading them on what they wrote down, not on what they claim to know.
1.2 A Brief History of Looking Things Up
Before we go further into RAG, it helps to understand that the idea of "augmenting" a question-answering system with retrieved documents is older than the deep learning revolution that produced modern LLMs. Information retrieval — the discipline of finding relevant documents in a large collection — has a sixty-year history, and every concept RAG uses today descends from that lineage.
In the 1960s, the cutting edge of information retrieval looked like a librarian with a card catalog. Documents had assigned keywords, either by the author or by a human inde