hybrid-search-implementation
wshobson/agents
Combine vector and keyword search for better retrieval in RAG and search systems.
What is hybrid-search-implementation?
Hybrid search merges semantic vector similarity with exact keyword matching to improve recall and handle domain-specific queries. Use this when building RAG systems, search engines, or when either approach alone misses relevant results.
- Fuse vector search and keyword search results using multiple strategies (RRF, linear weighting, cross-encoder reranking, cascade filtering)
- Handle queries with specific terms, names, and codes that pure vector search may miss
- Improve semantic understanding while preserving exact matching capabilities
- Rerank combined results for higher quality output
- Log and debug both vector and keyword scores for optimization
How to install hybrid-search-implementation
npx skills add https://github.com/wshobson/agents --skill hybrid-search-implementationHow to use hybrid-search-implementation
- 1.Choose a fusion method (RRF for simplicity, linear for tuning, cross-encoder for quality, cascade for efficiency)
- 2.Implement vector search and keyword search components in parallel
- 3.Apply fusion logic to combine and rank results from both approaches
- 4.Add reranking with a cross-encoder model for significant quality improvement
- 5.Test weights empirically on your data and A/B test with real users
Use cases
- Building RAG systems with improved recall for domain-specific documents
- Implementing search engines that need both semantic and exact-match capabilities
- Handling technical queries with specific codes, product names, or identifiers
- Improving search quality when pure vector embeddings miss keyword-relevant results
- Tuning search behavior for different query types in production systems
- RAG system builders
- Search engine developers
- ML engineers optimizing retrieval pipelines
- Teams handling domain-specific vocabulary and technical terminology
hybrid-search-implementation FAQ
Start with Reciprocal Rank Fusion (RRF) - it works well without tuning and doesn't require weight configuration.
Yes. Keyword search handles exact matches and domain-specific terms better, while vector search captures semantic meaning. Together they improve recall significantly.
Test empirically on your data. Use linear weighting to adjust the balance, or use RRF for a parameter-free approach. A/B test with real users to measure impact.
Yes. Adding a cross-encoder reranking step provides significant quality improvement and is a best practice for production systems.
Handle edge cases explicitly - consider fallback strategies like expanding keyword queries, lowering similarity thresholds, or returning partial results.
Full instructions (SKILL.md)
Source of truth, from wshobson/agents.
name: hybrid-search-implementation description: Combine vector and keyword search for improved retrieval. Use when implementing RAG systems, building search engines, or when neither approach alone provides sufficient recall.
Hybrid Search Implementation
Patterns for combining vector similarity and keyword-based search.
When to Use This Skill
- Building RAG systems with improved recall
- Combining semantic understanding with exact matching
- Handling queries with specific terms (names, codes)
- Improving search for domain-specific vocabulary
- When pure vector search misses keyword matches
Core Concepts
1. Hybrid Search Architecture
Query → ┬─► Vector Search ──► Candidates ─┐
│ │
└─► Keyword Search ─► Candidates ─┴─► Fusion ─► Results
2. Fusion Methods
| Method | Description | Best For |
|---|---|---|
| RRF | Reciprocal Rank Fusion | General purpose |
| Linear | Weighted sum of scores | Tunable balance |
| Cross-encoder | Rerank with neural model | Highest quality |
| Cascade | Filter then rerank | Efficiency |
Templates and detailed worked examples
Full template library and detailed worked examples live in references/details.md. Read that file when you need the concrete templates.
Best Practices
Do's
- Tune weights empirically - Test on your data
- Use RRF for simplicity - Works well without tuning
- Add reranking - Significant quality improvement
- Log both scores - Helps with debugging
- A/B test - Measure real user impact
Don'ts
- Don't assume one size fits all - Different queries need different weights
- Don't skip keyword search - Handles exact matches better
- Don't over-fetch - Balance recall vs latency
- Don't ignore edge cases - Empty results, single word queries
Related skills
More from wshobson/agents and the wider catalog.

incident-runbook-templates
Create structured incident response runbooks with detection, triage, mitigation, and escalation procedures.

interaction-design
Design microinteractions, motion, and transitions that enhance UI polish and user delight.

istio-traffic-management
Configure Istio service mesh traffic routing, load balancing, circuit breakers, and canary deployments.

javascript-testing-patterns
Implement comprehensive testing strategies with Jest, Vitest, and Testing Library for JavaScript/TypeScript.

k8s-manifest-generator
Generate production-ready Kubernetes manifests with built-in best practices and security standards.

k8s-security-policies
Implement NetworkPolicy, PodSecurityPolicy, RBAC, and Pod Security Standards for production Kubernetes security.