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

Post-Retrieval Re-Ranking

The Cross-Encoder. Fixing the mistakes of the vector store.

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. Bi-Encoders vs Cross-Encoders2. The Two-Stage Pipeline3. Why It Matters4. 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. Bi-Encoders vs Cross-Encoders2. The Two-Stage Pipeline3. Why It Matters4. Summary

1. Bi-Encoders vs Cross-Encoders

Standard Vector Search uses Bi-Encoders. It encodes the Query independently. It encodes the Document independently. Then it measures the angle. Pros: Fast (millions of docs). Cons: Lossy. It misses subtle interactions between query and doc.

A Cross-Encoder takes both the query and the document as a single input: Model(Query, Doc). It outputs a score (0 to 1) of "How relevant is this?" Pros: Extremely accurate. Cons: Slow. Expensive. You cannot index this ahead of time.

2. The Two-Stage Pipeline

We combine them.

  1. Stage 1 (Retrieval): Use Vector Search (Bi-Encoder) to get the top 50 candidates. (Fast, coarse).
  2. Stage 2 (Re-Ranking): Use a Cross-Encoder (like BGE-Reranker or Cohere Rerank) to score those 50.
  3. Result: Take the top 5 from the Cross-Encoder.

3. Why It Matters

"Apple" means fruit. "Apple" means company. A Vector store puts them close. A Cross-Encoder sees the full sentence "I want to buy a Granny Smith Apple" and pushes the "Company" documents to the bottom.

4. Summary

Re-ranking is the single most effective way to boost precision in a RAG pipeline. It acts as a "Quality Filter" before the expensive LLM generation step.

Key Intuition: "Index fast. Rank slow."

Track your progressSign in and your progress follows you across devices.
Sign in to track progress Next lesson
← Previous lessonContextual CompressionNext lesson →Conversational RAG & History