hybrid-search-bm25-dense
Skill8 starsChanged 7 months agoMITView on GitHub
Combine BM25 and dense retrieval signals to improve search quality across keyword and semantic queries.
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
- hyde-hypothetical-document-embeddingsSkill
- hype-hypothetical-prompt-embeddingsSkill
- multi-pass-retrieval-with-rerankingSkill
- 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 62
When exact term matching is important alongside conceptual understanding
- Distinctive: line 64
When user queries vary from natural language to specific terms
- Distinctive: line 67
When pure semantic search already provides excellent results
- Distinctive: line 69
When query latency must be minimized (hybrid adds overhead)
- Distinctive: line 70
When using a vector database that already implements hybrid search (e.g., Weaviate)
≈ “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
Hybrid search combines BM25 (keyword search) with dense vector embeddings (semantic search) to leverage both exact term matching and semantic understanding. This dual approach improves retrieval quality across diverse query types - keyword queries get exact matches, while semantic queries capture conceptual relationships.
Problem Statement
Pure semantic search or pure keyword search each have limitations:
- Dense-only search: Struggles with exact term matches, proper nouns, and domain-specific terminology
- Keyword-only search: Fails at understanding synonyms, paraphrasing, and conceptual relationships
- Different query types: Some queries are keyword-focused ("error code 404") while others are semantic ("how to fix authentication")
Key Concepts
- BM25: Okapi BM25 algorithm for keyword search with TF-IDF weighting
- Dense Search: Vector-based semantic search using embeddings
- Reciprocal Rank Fusion (RRF): Combines results from multiple ranking methods
- Score Normalization: Bringing different scoring systems to common scale
- Alpha Parameter: Controls the weighting between keyword and semantic components
Implementation Guide
Step 1: Set Up Dense Search
Implement vector-based semantic search with your chosen embedding model.
Why: Dense search captures semantic meaning but may miss exact term matches that are crucial for many queries.
Step 2: Set Up BM25 Search
Implement keyword-based search using BM25.
Why: BM25 excels at exact term matching, domain-specific terminology, and proper noun searches where semantic models might struggle.
Step 3: Implement Score Normalization
Normalize scores from different ranking methods to comparable scales.
Why: Different scoring systems (cosine similarity vs. BM25 scores) can't be directly combined - normalization creates a common scale.
Step 4: Implement Result Fusion
Combine results from multiple search methods.
Why: RRF is robust to different scoring scales and doesn't require explicit score normalization, making it ideal for fusion.
Step 5: Build the Hybrid Searcher
Combine all components into a single interface.
Why: A unified interface simplifies usage and allows easy experimentation with different fusion strategies and weights.
For implementation patterns, compare OpenSearch hybrid search docs, OpenSearch score ranker processor, the reciprocal rank fusion paper, and Sentence Transformers retrieve & re-rank.
When to Use This Skill
- Building production RAG systems where both precision and recall matter
- Handling diverse query types (keyword + semantic)
- When exact term matching is important alongside conceptual understanding
- For technical documentation with specific terminology
- When user queries vary from natural language to specific terms
When NOT to Use This Skill
- When pure semantic search already provides excellent results
- For very small datasets where complexity isn't justified
- When query latency must be minimized (hybrid adds overhead)
- When using a vector database that already implements hybrid search (e.g., Weaviate)
Related Skills
- Multi-Pass Retrieval with Reranking - Further refine results
- Semantic Chunking - Improve content quality
- Optimize Retrieval Latency - Performance tuning
Metrics & Success Criteria
- Retrieval Quality: Improved NDCG/precision/recall vs. single-method search
- Query Type Coverage: Good results for both keyword and semantic queries
- Latency: Hybrid search within 1.5x of single-method latency
- Maintainability: Clear separation of components
- Flexibility: Easy to adjust alpha and fusion method
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.

