haive.core.engine.retriever.providers.MultiQueryRetrieverConfigΒΆ
Multi-Query Retriever implementation for the Haive framework.
This module provides a configuration class for the Multi-Query retriever, which generates multiple query variations to improve retrieval coverage and find more relevant documents for complex or ambiguous queries.
The MultiQueryRetriever works by: 1. Using an LLM to generate multiple query variations from the original query 2. Running each generated query against the base retriever 3. Collecting and deduplicating all retrieved documents 4. Returning the combined set of unique documents
This retriever is particularly useful when: - Dealing with complex or ambiguous user queries - Need to improve recall by finding documents with different phrasings - User queries might miss relevant documents due to vocabulary mismatch - Building systems that need comprehensive document coverage
The implementation integrates with LangChainβs MultiQueryRetriever while providing a consistent Haive configuration interface with LLM integration.
ClassesΒΆ
Configuration for Multi-Query retriever in the Haive framework. |
Module ContentsΒΆ
- class haive.core.engine.retriever.providers.MultiQueryRetrieverConfig.MultiQueryRetrieverConfig[source]ΒΆ
Bases:
haive.core.engine.retriever.retriever.BaseRetrieverConfig
Configuration for Multi-Query retriever in the Haive framework.
This retriever generates multiple query variations using an LLM to improve retrieval coverage and find more relevant documents for complex queries.
- retriever_typeΒΆ
The type of retriever (always MULTI_QUERY).
- Type:
- base_retrieverΒΆ
The underlying retriever to query with variations.
- Type:
- llm_configΒΆ
LLM configuration for generating query variations.
- Type:
Examples
>>> from haive.core.engine.retriever import MultiQueryRetrieverConfig >>> from haive.core.engine.retriever.providers.VectorStoreRetrieverConfig import VectorStoreRetrieverConfig >>> from haive.core.engine.aug_llm import AugLLMConfig >>> >>> # Create base retriever and LLM config >>> base_config = VectorStoreRetrieverConfig(name="base", vectorstore_config=vs_config) >>> llm_config = AugLLMConfig(model_name="gpt-3.5-turbo", provider="openai") >>> >>> # Create multi-query retriever >>> config = MultiQueryRetrieverConfig( ... name="multi_query_retriever", ... base_retriever=base_config, ... llm_config=llm_config, ... num_queries=3, ... include_original=True ... ) >>> >>> # Instantiate and use the retriever >>> retriever = config.instantiate() >>> docs = retriever.get_relevant_documents("machine learning algorithms")
- instantiate()[source]ΒΆ
Create a Multi-Query retriever from this configuration.
- Returns:
Instantiated retriever ready for multi-query retrieval.
- Return type:
MultiQueryRetriever
- Raises:
ImportError β If required packages are not available.
ValueError β If configuration is invalid.