multi-pass-retrieval-with-reranking
Skill8 starsChanged 7 months agoMITView on GitHub
Use a two-stage retrieval pipeline with reranking to balance recall, precision, and latency.
In this repository39 other files it gives its agents.
- AGENTS.mdAGENTS.md
- rag-skillsSkill
- choosing-a-chunking-frameworkSkill
- contextual-chunk-headersSkill
- hierarchical-chunkingSkill
- semantic-chunkingSkill
- chunkingSkill
- sliding-window-chunkingSkill
- rag-for-code-documentationSkill
- rag-for-multimodal-contentSkill
- data-type-handlingSkill
- index-versioning-and-reindexingSkill
- production-rag-deploymentSkill
- deploymentSkill
- generation-evaluation-metricsSkill
- rag-evaluation-frameworksSkill
- retrieval-evaluation-metricsSkill
- evaluation-metricsSkill
- optimize-retrieval-latencySkill
- performance-optimizationSkill
- agentic-rag-routingSkill
- multi-agent-rag-orchestrationSkill
- rag-agentsSkill
- adaptive-retrievalSkill
- context-enrichment-windowSkill
- crag-corrective-ragSkill
- explainable-retrievalSkill
- graph-ragSkill
- hybrid-search-bm25-denseSkill
- hyde-hypothetical-document-embeddingsSkill
- hype-hypothetical-prompt-embeddingsSkill
- query-transformation-strategiesSkill
- raptor-hierarchical-retrievalSkill
- self-ragSkill
- retrieval-strategiesSkill
- choosing-vector-db-by-datatypeSkill
- qdrant-for-production-ragSkill
- qdrant-setup-ragSkill
- vector-databasesSkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 54
Add caching and optimizations for production use.
- Distinctive: line 62
When document collections are too large for full cross-encoder search
- Distinctive: line 64
When you can tolerate slightly higher latency for better results
- Distinctive: line 68
When latency must be minimized (single bi-encoder is faster)
- Distinctive: line 70
When bi-encoder already provides excellent relevance
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Overview
Multi-pass retrieval with reranking is a two-stage approach that first retrieves a broad set of candidates using fast bi-encoder search, then refines them using a more accurate but slower cross-encoder reranker. This balances recall and relevance while maintaining acceptable latency.
Problem Statement
Single-stage retrieval has inherent trade-offs:
- Bi-encoder only: Fast but limited relevance - struggles with complex query-document relationships
- Cross-encoder only: Accurate but too slow for large document collections
- Fixed top-k: Can't adapt to query difficulty - some queries need more/ fewer candidates
- Static retrieval: Can't incorporate user feedback or context during retrieval
Key Concepts
- Bi-Encoder: Fast encoding model that produces fixed vectors for documents and queries
- Cross-Encoder: Joint query-document encoder for accurate scoring (but slower)
- Two-Stage Retrieval: Broad retrieval followed by refinement
- Adaptive Top-K: Dynamically adjust retrieval depth based on query characteristics
- Reranking Pipeline: Post-retrieval scoring and reordering of candidates
Implementation Guide
Step 1: Set Up Bi-Encoder Retrieval
Implement the first-stage retrieval using your vector database.
Why: Bi-encoder retrieval is fast and scalable but produces approximate scores - suitable for the first pass to narrow candidates.
Step 2: Set Up Cross-Encoder Reranking
Implement the second-stage reranking for accurate scoring.
Why: Cross-encoders produce more accurate relevance scores by jointly encoding query-document pairs, but are too slow for full-scale retrieval.
Step 3: Implement Adaptive Retrieval
Dynamically adjust retrieval parameters based on query characteristics.
Why: Adaptive retrieval ensures complex queries get more candidates for reranking while simple queries remain fast.
Step 4: Build the Multi-Pass Pipeline
Combine all components into a complete retrieval pipeline.
Why: A unified pipeline with timing and explanation makes it easy to optimize and debug the retrieval system.
Step 5: Implement Cache and Optimization
Add caching and optimizations for production use.
Why: Caching reduces computation for repeated queries, which is common in production systems.
For working examples, see Sentence Transformers CrossEncoder docs, Sentence Transformers rerankers, Sentence Transformers retrieve & re-rank, and the MonoT5 paper.
When to Use This Skill
- Production RAG systems where relevance is critical
- When document collections are too large for full cross-encoder search
- For complex queries where bi-encoder precision is insufficient
- When you can tolerate slightly higher latency for better results
- For applications with clear performance metrics (NDCG, precision@k)
When NOT to Use This Skill
- When latency must be minimized (single bi-encoder is faster)
- For very small collections where full cross-encoder is feasible
- When bi-encoder already provides excellent relevance
- For simple keyword searches (BM25 may suffice)
Related Skills
- Hybrid Search BM25 Dense - First-stage enhancement
- Semantic Chunking - Better input for retrieval
- Optimize Retrieval Latency - Performance tuning
Metrics & Success Criteria
- Relevance: NDCG@10 improvement > 10% over bi-encoder alone
- Latency: Total retrieval < 500ms for typical queries
- Recall: Maintain > 95% recall of first stage
- Reranking Quality: Reranked top-10 should significantly outscore stage-1 top-10
- Cost Efficiency: Acceptable computational overhead vs. relevance gain
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

