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 40 of 68

Multi-Query Retrieval

Asking 5 questions is better than asking 1. Expanding the search net.

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. The Single Query Failure2. Query Expansion (Paraphrasing)3. Benefits4. 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. The Single Query Failure2. Query Expansion (Paraphrasing)3. Benefits4. Summary

1. The Single Query Failure

User Query: "Why is my screen dark?" Document: "Display brightness settings can be adjusted in the Control Panel."

Semantic Distance: Far. The user used "dark," the doc uses "brightness." The user used "screen," the doc uses "Display."

If you rely on a single query, you rely on a perfect semantic match.

2. Query Expansion (Paraphrasing)

We ask an LLM to generate 3 variations of the user's question.

  • Variation 1: "How do I increase display brightness?"
  • Variation 2: "Monitor is not lighting up fix."
  • Variation 3: "Troubleshoot backlight issues."

We then run ALL 3 queries against the vector store. If any of them hits the document, we retrieve it.

multi_query.py
from langchain.retrievers.multi_query import MultiQueryRetriever

retriever = MultiQueryRetriever.from_llm(
  retriever=vectorstore.as_retriever(),
  llm=chat_model
)

# It generates queries, searches all, and creates a unique union of docs.

3. Benefits

It solves the "Vocabulary Mismatch" problem. It covers different "Embeddings Neighborhoods" (synonyms often live in different clusters).

4. Summary

Users are bad at prompting. Don't let their poor wording break your retrieval. Expand their intent.

Key Intuition: "Cast a wider net by saying the same thing in different ways."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonSimilarity vs MMRNext lesson →RAG-Fusion