/vibe:hybrid-search-expertfrom vibe
Guides implementation of hybrid search combining BM25 lexical retrieval with dense vector embeddings using RRF fusion, alpha tuning, and SPLADE. Useful for optimizing RAG pipelines.
Ships in vibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in hybrid retrieval: combining lexical (BM25 / sparse) and semantic (dense vector) signals into a single ranked list. Pure dense retrieval misses exact identifiers, code symbols, and rare terms. Pure BM25 misses paraphrases and synonyms. Hybrid fixes both, if you fuse the scores correctly.
Two retrievers, one ranking:
Fusion strategies (in order of robustness):
For document d appearing in result lists L1...Ln at ranks r1...rn:
RRF(d) = Σ_i weight_i / (k + r_i)
k = 60 is the common default (Cormack 2009; Microsoft Azure AI Search, OpenSearch, Elasticsearch all use 60). Higher k flattens the curve — rank-1 vs rank-10 matters less. Documents missing from a list contribute 0.
from collections import defaultdict
def rrf(rank_lists: list[list[str]], k: int = 60, weights=None) -> list[tuple[str, float]]:
weights = weights or [1.0] * len(rank_lists)
scores = defaultdict(float)
for w, ranked in zip(weights, rank_lists):
for rank, doc_id in enumerate(ranked, start=1):
scores[doc_id] += w / (k + rank)
return sorted(scores.items(), key=lambda x: -x[1])
WITH dense AS (
SELECT id, RANK() OVER (ORDER BY embedding <=> $1) AS r
FROM docs ORDER BY embedding <=> $1 LIMIT 50
),
sparse AS (
SELECT id, RANK() OVER (ORDER BY ts_rank(tsv, plainto_tsquery($2)) DESC) AS r
FROM docs WHERE tsv @@ plainto_tsquery($2) LIMIT 50
)
SELECT id, SUM(1.0 / (60 + r)) AS rrf
FROM (SELECT * FROM dense UNION ALL SELECT * FROM sparse) u
GROUP BY id ORDER BY rrf DESC LIMIT 10;
from qdrant_client import QdrantClient
from qdrant_client.models import Prefetch, FusionQuery, Fusion
client.query_points(
collection_name="docs",
prefetch=[
Prefetch(query=dense_vec, using="dense", limit=50),
Prefetch(query=sparse_vec, using="sparse", limit=50), # SPLADE/BM25
],
query=FusionQuery(fusion=Fusion.RRF),
limit=10,
)
EnsembleRetrieverfrom langchain.retrievers import EnsembleRetriever, BM25Retriever
bm25 = BM25Retriever.from_documents(docs); bm25.k = 50
dense = vector_store.as_retriever(search_kwargs={"k": 50})
hybrid = EnsembleRetriever(retrievers=[bm25, dense], weights=[0.4, 0.6])
SPLADE replaces BM25 with a learned sparse vector (BERT MLM head + sparsity reg). Pros: term expansion (handles synonyms), still inverted-index compatible. Cons: heavier indexing, model dependency.
from transformers import AutoTokenizer, AutoModelForMaskedLM
import torch
tok = AutoTokenizer.from_pretrained("naver/splade-v3")
model = AutoModelForMaskedLM.from_pretrained("naver/splade-v3")
def splade_vec(text: str) -> dict[int, float]:
with torch.no_grad():
out = model(**tok(text, return_tensors="pt")).logits
# max-pool log(1+ReLU(x)) over sequence
vec = torch.max(torch.log1p(torch.relu(out)) * tok(text, return_tensors="pt").attention_mask.unsqueeze(-1), dim=1).values[0]
nz = vec.nonzero().flatten().tolist()
return {i: vec[i].item() for i in nz}
[0.3, 0.7], [0.5, 0.5], [0.7, 0.3]. Don't trust priors — your distribution decides.k in RRF: 10, 30, 60, 100. Higher k = more democratic.ks in each retriever before fusion: if you only fetch top-5 each, fusion has nothing to work with. Fetch 50-100 each, fuse, then truncate.Use hybrid as the default for any production RAG system over heterogeneous corpora (technical docs, mixed user queries, code + prose). Skip only when you've measured that pure dense + rerank already saturates your eval.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
hybrid-search, retrieval-augmented-generation, bm25, rrf, splade, dense-retrieval
npx claudepluginhub anubhavg-icpl/vibe --plugin vibe5,304 skills in this plugin
/3d-pipelineChoose a 3D generation or reconstruction pipeline given input type, output format, and use case. Use when you need help with 3d pipeline./8-bit-orbit-video-templateHyperframes Video TemplateShip a premium template-mode Hyperframes composition with a ready default showcase and deterministic timeline behavior./a2a-agent-specProduce the Agent Card and skills schema for an agent that should be callable over A2A. Use when you need help with a2a agent spec.Other plugins' skills for the same job