# RAG (Retrieval-Augmented Generation)
**Retrieval-Augmented Generation (RAG)** is a technique that combines an AI language model with a search system: instead of relying solely on what the model learned during training, it retrieves relevant documents from an external knowledge base and includes them in the prompt, so the model can generate answers grounded in specific, up-to-date, or proprietary information.
RAG solves two fundamental problems with standalone LLMs: **knowledge staleness** (models only know what was in their training data, which has a cutoff date) and **hallucination** (models generate plausible-sounding but incorrect information when they don't know the answer). By giving the model real documents to reference, RAG grounds its responses in actual sources.
## How It Works
A RAG system has three components:
**1. Document processing.** The knowledge base (company documents, intelligence reports, legal filings, medical records — whatever the system needs to know about) is split into chunks and converted into [[Embeddings]] — numerical representations stored in a vector database.
**2. Retrieval.** When a user asks a question, the query is also converted into an embedding. The system searches the vector database for document chunks whose embeddings are most similar to the query — finding the most semantically relevant passages.
**3. Generation.** The retrieved passages are inserted into the LLM's [[Context Window]] alongside the user's question. The model generates a response using both its general knowledge and the specific retrieved information, ideally citing its sources.
## Why RAG Dominates Enterprise AI
RAG is the dominant architecture for enterprise AI applications because it addresses the core constraint businesses face: they need AI that knows about *their* data — proprietary documents, internal processes, customer records — without that data being shared with the AI provider or included in general training data.
Every major AI-powered enterprise product uses some form of RAG: Palantir AIP retrieves from intelligence databases, legal AI tools retrieve from case law, customer service bots retrieve from knowledge bases, and coding assistants retrieve from codebases. The pattern is universal because the problem is universal: general knowledge is necessary but insufficient.
## The Defense-Intelligence Application
RAG is particularly consequential in defense and intelligence contexts. [[Palantir AIP]] uses RAG to give LLMs access to classified intelligence databases — enabling analysts to ask natural-language questions ("What do we know about Iranian drone shipments to Houthi forces in the last 90 days?") and receive answers grounded in specific intelligence reports, satellite imagery analyses, and signals intelligence summaries.
This transforms the intelligence analyst's workflow from manually searching databases and cross-referencing reports to conversational querying of the entire intelligence corpus. The speed advantage is enormous; the risk is that the LLM may retrieve irrelevant documents, miss relevant ones, or generate confident-sounding synthesis that the analyst trusts uncritically.
## KB Significance
1. **The enterprise AI architecture.** RAG is how AI actually gets deployed in organizations — including the defense and intelligence organizations documented in the KB. Understanding RAG is prerequisite to understanding how Palantir AIP, Anduril's systems, and classified Pentagon AI tools actually work in practice.
2. **The accuracy vs. speed trade-off.** RAG reduces hallucination but doesn't eliminate it. The retrieval step can miss relevant documents or surface irrelevant ones; the generation step can misinterpret what it retrieves. In military contexts, these failure modes can have lethal consequences — a risk the KB's defense-tech analysis should track as AI-assisted targeting expands.
3. **The data-access power structure.** RAG's effectiveness depends on what's in the knowledge base. Whoever controls the document corpus controls what the AI "knows." In intelligence contexts, this means classification decisions and database access controls determine what the AI can see — and therefore what analysis it can produce.
## See Also
- [[Embeddings]] — The retrieval mechanism behind RAG
- [[Context Window]] — Where retrieved documents are processed
- [[Large Language Model]] — The generation component
- [[Palantir AIP]] — The most consequential RAG deployment for the KB