hybrid-search-rag

Implement hybrid search combining BM25, vector embeddings, and RRF fusion for RAG retrieval.

Updated May 11, 2026
One-click install
npx skills add https://github.com/thachrocky12345/local-agent-train-workstation --skill hybrid-search-rag-thachrocky12345
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hybrid-search-rag
Source: https://github.com/thachrocky12345/local-agent-train-workstation/tree/main/.claude/skills/hybrid-search-rag
Command: npx skills add https://github.com/thachrocky12345/local-agent-train-workstation --skill hybrid-search-rag-thachrocky12345

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Keyword-only search misses conceptual matches while vector-only search misses exact technical terms, causing poor retrieval accuracy for structured content like skills, MCP servers, and tools. ## Core Features & Use Cases - Hybrid Retrieval Pipeline: Combines PostgreSQL tsvector BM25 search with pgvector cosine similarity, merged via Reciprocal Rank Fusion (RRF). - Query Expansion Taxonomy: Maps synonyms and technical abbreviations (e.g., "CI/CD" → "deployment") to improve recall across skills, MCP servers, agents, and workflows. - 7-Signal Confidence Scoring: Computes intent clarity, filter completeness, overlap, margin, and coverage to decide whether to return results or ask clarifying questions. - Use Case: A user searches "git commit workflow" across a tenant's skills and MCP servers; the system runs BM25 and vector search in parallel, fuses results with RRF, and returns ranked matches with a confidence score driving the UX. ## Quick Start Ask the AI to implement hybrid search with BM25, vector embeddings, and RRF fusion for your PostgreSQL-backed skill and MCP server catalog.

Frequently Asked Questions about hybrid-search-rag

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

FAQPage Schema
How do I implement hybrid search with BM25 and vector embeddings?

Run PostgreSQL full-text search (ts_rank_cd with tsvector) and pgvector cosine similarity in parallel, then merge the ranked lists using Reciprocal Rank Fusion with k=60. RRF combines ranks without needing score calibration between the two retrievers.

What is Reciprocal Rank Fusion and why use it for RAG?

Reciprocal Rank Fusion merges ranked lists by summing 1/(k + rank) for each document across lists. It works for RAG because BM25 scores and cosine similarities are not comparable, but ranks are, so documents appearing in both lists rank higher without score normalization.

Does PostgreSQL support BM25 full-text search natively?

Yes, PostgreSQL provides tsvector and tsquery with ts_rank_cd ranking, which implements BM25-style probabilistic ranking. Add a tsvector column with a GIN index and an update trigger to keep search vectors synchronized with content changes.

How do I improve search recall for technical terms and abbreviations?

Use query expansion with a synonym taxonomy that maps terms like "CI/CD" to "deployment" and "e2e" to "testing". Expand query tokens before BM25 search so conceptual and abbreviated queries match canonical content.

When should search results trigger a clarifying question instead?

Use a confidence score combining signals like BM25/vector overlap, top result quality, and margin between results. Return results directly above 0.80, return with refinement suggestions between 0.55-0.79, and ask a clarifying question below 0.55.

What are the limitations of Reciprocal Rank Fusion?

RRF ignores score magnitude, treating a BM25 score of 10.0 the same as 0.1 if ranks are equal. It is also sensitive to candidate list length, so fetching more results from one retriever biases the fusion toward it.