hybrid-search-implementation

Implement hybrid search combining vector similarity and keyword retrieval with fusion methods.

38.6k|4.1k|Updated Jul 24, 2025
One-click install
npx skills add https://github.com/wshobson/agents --skill hybrid-search-implementation-wshobson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hybrid-search-implementation
Source: https://github.com/wshobson/agents/tree/main/plugins/llm-application-dev/skills/hybrid-search-implementation
Command: npx skills add https://github.com/wshobson/agents --skill hybrid-search-implementation-wshobson

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires asyncpg, numpy, sentence-transformers, elasticsearch, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill addresses the limitations of relying on a single search method by combining the strengths of vector similarity search and traditional keyword search for more comprehensive and accurate retrieval.

Core Features & Use Cases

  • Hybrid Search Architectures: Implement strategies that fuse results from multiple search modalities.
  • Fusion Methods: Utilize techniques like Reciprocal Rank Fusion (RRF), linear combination, or cross-encoder reranking.
  • Database Integration: Provides templates for PostgreSQL with pgvector and Elasticsearch.
  • Use Case: Enhance a RAG system by ensuring that queries seeking specific product codes (best handled by keyword search) are not missed, while still benefiting from the semantic understanding of vector search.

Quick Start

Use the hybrid-search-implementation skill to combine vector and keyword search results using Reciprocal Rank Fusion.

Frequently Asked Questions about hybrid-search-implementation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I combine vector search and keyword search for RAG applications?

Hybrid search combines vector similarity and keyword-based retrieval to enhance information retrieval. By fusing results from both modalities, you ensure that exact term matching for specific identifiers and semantic understanding are preserved for more comprehensive RAG systems.

What is Reciprocal Rank Fusion and how does it work for hybrid search?

Reciprocal Rank Fusion (RRF) is a fusion method that combines rankings from multiple search modalities. It assigns scores based on the reciprocal of each document's rank in individual result lists, allowing you to merge vector similarity and keyword search outputs without needing raw score calibration.

Can I implement hybrid search with PostgreSQL and Elasticsearch?

Yes, you can implement hybrid search using templates for PostgreSQL with pgvector and Elasticsearch. The integration supports both vector similarity and traditional keyword retrieval within these databases to build advanced search engines and information retrieval systems.

When should I use cross-encoder reranking instead of linear combination for search results?

Use cross-encoder reranking when you need higher precision through joint encoding of query and document pairs, and use linear combination when you need a faster fusion of independently scored vector and keyword results. Both methods address different scale and accuracy requirements.

Why does my vector search miss exact product code matches in queries?

Vector search alone often misses exact product codes because it prioritizes semantic similarity over exact term matching. Implementing hybrid search ensures that keyword retrieval handles specific identifiers while vector search captures broader semantic context.

Do I need sentence-transformers and asyncpg to build a hybrid search system?

Yes, sentence-transformers generate the vector embeddings, asyncpg interfaces with PostgreSQL, numpy handles numerical operations for fusion methods, and elasticsearch manages keyword indexing. These dependencies collectively support the hybrid search architecture.