Retrieval
The stage of RAG at which the system finds the relevant fragments for a query.
Where It Fits in the RAG Pipeline
flowchart LR
A[Question] --> B[Retrieval]
B --> C[Fragments]
C --> D[LLM]
D --> E[Answer]
Retrieval is the bridge between the question and the model: the quality of the search directly determines the quality of the answer.
How the Search Is Organised
- The question is turned into an embedding.
- The nearest vectors are looked up in the vector DB.
- The top fragments are passed to the LLM.
Types of Retrieval
- Vector — by meaning;
- Keyword (BM25) — by exact match;
- Hybrid (hybrid search) — both approaches;
- Agentic (adaptive-rag) — the agent decides for itself what to search for.
Why It Matters
If the search finds the wrong thing, even the best LLM will answer badly. That is why in production you fix retrieval first, not the model.