Skip to content
derpx06Notes on systems, models & learning
5. Retrieval & RAG Patterns · lesson 38 of 68 · 1 min · January 10, 2026

The Retriever Interface

Retrieval is a pipeline, not a query. The gatekeeper of truth.

Retrieval is not "Search + LLM." It is the Gatekeeper of Truth.

If your retriever fails to find the relevant document, the LLM hallucinates. If your retriever finds irrelevant documents, the LLM gets confused. The quality of your RAG system is bounded by the quality of your retrieval, not the intelligence of your model.

In LangChain, a Retriever is anything that adheres to this interface: get_relevant_documents(query: str) -> List[Document]

This abstraction is powerful because it hides the complexity. Behind that simple function call, you might have:

  • A Vector Store (Semantic Search)
  • A Keyword Search (BM25)
  • A SQL Database
  • The Internet (Google Search)

Precision is "How much of what I found is useful?" Recall is "Did I find everything that matters?"

Retrievers are biased towards Recall. Their job is to cast a net wide enough to catch the answer, but narrow enough to fit in the context window.

retriever_basic.py
from langchain_community.vectorstores import Chroma

# A VectorStore is NOT a Retriever
vectorstore = Chroma(...)

# But it can be turned into one
retriever = vectorstore.as_retriever(
  search_type="similarity",
  search_kwargs={"k": 5}
)

# Now it is a standard interface
docs = retriever.invoke("How do I reset my password?")

The Retriever is the component that selects "What the model sees." It is the most critical component in any RAG Architecture.

Key Intuition: "The model is the reasoning engine. The retriever is the memory."