haive.core.engine.retriever.providers.EnsembleRetrieverConfigΒΆ
Ensemble Retriever implementation for the Haive framework.
This module provides a configuration class for the Ensemble retriever, which combines multiple retrieval strategies using weighted combination to improve overall retrieval performance and coverage.
The EnsembleRetriever works by: 1. Running multiple retrievers in parallel on the same query 2. Combining results using configurable weights for each retriever 3. Re-ranking and deduplicating the combined results 4. Returning the most relevant documents from the ensemble
This retriever is particularly useful when: - You want to combine different retrieval strategies (sparse + dense) - Need to balance precision and recall across different approaches - Building robust systems that work across diverse query types - Implementing hybrid search with customizable weights
The implementation integrates with LangChainβs EnsembleRetriever while providing a consistent Haive configuration interface.
ClassesΒΆ
Configuration for Ensemble retriever in the Haive framework. |
Module ContentsΒΆ
- class haive.core.engine.retriever.providers.EnsembleRetrieverConfig.EnsembleRetrieverConfig[source]ΒΆ
Bases:
haive.core.engine.retriever.retriever.BaseRetrieverConfig
Configuration for Ensemble retriever in the Haive framework.
This retriever combines multiple retrieval strategies using weighted combination to improve overall performance and coverage across different query types.
- retriever_typeΒΆ
The type of retriever (always ENSEMBLE).
- Type:
- retrieversΒΆ
List of retriever configurations to ensemble.
- Type:
List[BaseRetrieverConfig]
Examples
>>> from haive.core.engine.retriever import EnsembleRetrieverConfig >>> from haive.core.engine.retriever.providers.BM25RetrieverConfig import BM25RetrieverConfig >>> from haive.core.engine.retriever.providers.VectorStoreRetrieverConfig import VectorStoreRetrieverConfig >>> >>> # Create individual retrievers >>> bm25_config = BM25RetrieverConfig(name="bm25", documents=docs, k=10) >>> vector_config = VectorStoreRetrieverConfig(name="vector", vectorstore_config=vs_config, k=10) >>> >>> # Create ensemble retriever >>> config = EnsembleRetrieverConfig( ... name="hybrid_ensemble", ... retrievers=[bm25_config, vector_config], ... weights=[0.3, 0.7], # 30% BM25, 70% vector ... k=5 ... ) >>> >>> # Instantiate and use the retriever >>> retriever = config.instantiate() >>> docs = retriever.get_relevant_documents("machine learning algorithms")
- instantiate()[source]ΒΆ
Create an Ensemble retriever from this configuration.
- Returns:
Instantiated retriever ready for ensemble retrieval.
- Return type:
EnsembleRetriever
- Raises:
ImportError β If required packages are not available.
ValueError β If configuration is invalid.