Skip to content
derpx06.dev
WritingExplainersNotesAbout
works on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisationworks on my machineit's always DNSship itLGTMTODO: sleepoff by oneread the docsgit push --force-with-lease404: sleep not foundhave you tried turning it off and on againrubber duck says: explain itpremature optimisation

Learning in public.

A student's notebook on system design, distributed systems and databases. Shared as I learn.

ReadWritingExplainersNotesAbout
ElsewhereGitHubLinkedInHugging FaceLeetCode
Say hellomanaskhairnar1511@gmail.com
derpx06
NORMALmain© 2026 Derpx06Pune, Indiatop ↑
Learn/LangChain Mastery/Part 6 · 5. Retrieval & RAG Patterns
Lesson 38 of 68

The Retriever Interface

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

Derpx0610 Jan · 1 min read
LangChain Mastery
The Retriever InterfaceSimilarity vs MMRMulti-Query RetrievalRAG-FusionQuery DecompositionParent Document RetrievalContextual CompressionPost-Retrieval Re-RankingConversational RAG & History
Contents
1. Retrieval as a System2. The Abstraction3. Why Retrievers Define "Recall"4. Implementation5. Summary
0% read · 1 min leftBack to top ↑
Course outline & contents0%
LangChain Mastery
The Retriever InterfaceSimilarity vs MMRMulti-Query RetrievalRAG-FusionQuery DecompositionParent Document RetrievalContextual CompressionPost-Retrieval Re-RankingConversational RAG & History
Contents
1. Retrieval as a System2. The Abstraction3. Why Retrievers Define "Recall"4. Implementation5. Summary

1. Retrieval as a System

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.

2. The Abstraction

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)

3. Why Retrievers Define "Recall"

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.

4. Implementation

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?")

5. Summary

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."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonHybrid Search ConceptsNext lesson →Similarity vs MMR