Retrieval-augmented generation (RAG) connects a generative AI model to a database: retrieve relevant facts, add them to the user’s prompt, and direct the model to answer from that context. It can let an AI answer questions using private company documents rather than relying only on what it learned before. section 9.4.5 section 8.2.3
RAG addresses a basic mismatch: databases retrieve stored information, while AI models predict likely answers and may confidently invent facts. Retrieval helps, but it brings tradeoffs:
- Vector search finds approximate nearest neighbors, not guaranteed exact truth; a close match can be dangerously wrong in medical or legal applications. section 8.2.3
- Vector indexes can require substantially more memory and computing power than simple text indexes, making a dedicated vector database costly for some projects. section 8.2.3
Figure 9.3 AI models are probability engines, not databases. Without RAG guardrails, they will confidently improvise the wrong answer. RAG turns the AI from an "improv actor" into an "open-book test taker”.

The open-book-test analogy captures the idea: give the model relevant facts to use rather than trusting it to remember them. section 9.4.5













































