HybridRetriever<T>

Models & Types · AiDotNet.RetrievalAugmentedGeneration.Retrievers

Hybrid retriever combining dense and sparse retrieval via Reciprocal Rank Fusion (RRF).

Inheritance: RetrieverBase<T> → HybridRetriever<T>

How It Works

Dense (cosine, ~0..1) and sparse (BM25, unbounded) scores live on incompatible scales, so a raw weighted sum is dominated by whichever list has larger-magnitude scores. RRF instead fuses by RANK — each list contributes weight / (k + rank) — which is scale-free and is the default hybrid fusion in Elasticsearch/Weaviate/Qdrant and the LangChain/LlamaIndex ensemble retrievers (Cormack et al., 2009). The weights still let callers favor one retriever; k (default 60) damps the influence of low ranks.

Constructors

Constructor Summary
HybridRetriever(IRetriever<T> denseRetriever, IRetriever<T> sparseRetriever, double denseWeight, double sparseWeight, int defaultTopK, int rrfK)