Skip to main content
Hybrid search combines two complementary candidate lists:
  • semantic search finds related meaning through embeddings;
  • BM25 rewards exact terms, identifiers, and acronyms.
RAGLight fetches up to twice the requested result count from each strategy, deduplicates documents, and applies reciprocal rank fusion (RRF). The final list is limited to top_k by the pipeline.

Enable hybrid retrieval

Use search_type="bm25" for lexical-only search or search_type="semantic" for dense-only search. Chroma and Qdrant expose the same option.

Persistence behavior

When a store has a persist_directory, RAGLight saves the BM25 corpus as bm25_<collection_name>.json. It reloads that file on startup. For remote stores, the index is rebuilt from documents already present in the collection.
The constructor currently accepts alpha for API compatibility, but hybrid ranking uses RRF rather than an alpha-weighted score. Tune candidate count with PipelineConfig(top_k=...) and measure retrieval quality on your own evaluation set.

When to use it

Hybrid search is useful for API names, error codes, product identifiers, legal references, and technical vocabulary. Semantic search alone is often sufficient for prose where users paraphrase the source material.