# RAG Pipeline

Retrieve relevant documents at query time and ground the model's answer in them instead of relying on parametric memory.

## Why the CCAR-P exam tests this

RAG is the default pattern for giving Claude private, current knowledge, and P3 expects you to reason about each stage and its failure modes.

## Definition

A **RAG pipeline** has two phases. **Indexing (offline):** documents are loaded, split via a **chunking strategy**, embedded into vectors, and stored in a vector/hybrid index. **Retrieval + generation (online):** the user query is embedded, the top-k relevant chunks are fetched (often then **reranked**), and those chunks are injected into the prompt as grounding context for Claude to answer over.

RAG reduces hallucination and keeps knowledge fresh without retraining, but it introduces its own failure surface: bad chunking, weak retrieval, or stale indexes produce confidently wrong answers. Retrieval quality and generation quality are **separate concerns** and must be measured separately.

Evaluate **retrieval** with metrics like recall@k, precision@k, and MRR/nDCG — did the right chunks come back? Evaluate **generation** with **faithfulness/groundedness** — did the answer stay true to the retrieved context, or did it drift? A pipeline can retrieve perfectly and still hallucinate, or generate faithfully over the wrong documents.

## Exam trap

Don't collapse retrieval metrics and answer faithfulness into one number — a high final-answer score can hide broken retrieval, and vice versa.

## Commonly confused with

- **hybrid-retrieval** — Hybrid retrieval is one retrieval technique inside a RAG pipeline, not the whole pipeline.
- **mcp** — RAG feeds retrieved text into the prompt; MCP is a protocol for tool/data access — a RAG source can be served over MCP but they aren't the same thing.

## Related

- chunking-strategy
- reranking
- hybrid-retrieval
- data-layer-acls

---

Source: Claude Cert Prep — an independent, unofficial CCAR-P study resource (domain P3). Not affiliated with Anthropic.
