haive.core.engine.retriever.providers.RePhraseQueryRetrieverConfig¶
Rephrase Query Retriever implementation for the Haive framework.
from typing import Any This module provides a configuration class for the Rephrase Query retriever, which reformulates user queries using an LLM to improve retrieval performance by creating more effective search queries.
The RePhraseQueryRetriever works by: 1. Taking the user’s original query as input 2. Using an LLM to rephrase the query for better search effectiveness 3. Running the rephrased query against the base retriever 4. Returning documents found using the improved query
This retriever is particularly useful when: - User queries are poorly formulated or ambiguous - Need to improve search effectiveness through query optimization - Building systems that need to handle natural language queries better - Want to bridge the gap between user intent and retrieval effectiveness
The implementation integrates with LangChain’s RePhraseQueryRetriever while providing a consistent Haive configuration interface with LLM integration.
Classes¶
Configuration for Rephrase Query retriever in the Haive framework. |
Module Contents¶
- class haive.core.engine.retriever.providers.RePhraseQueryRetrieverConfig.RePhraseQueryRetrieverConfig[source]¶
Bases:
haive.core.engine.retriever.retriever.BaseRetrieverConfig
Configuration for Rephrase Query retriever in the Haive framework.
This retriever reformulates user queries using an LLM to improve retrieval performance by creating more effective search queries.
- retriever_type¶
The type of retriever (always REPHRASE_QUERY).
- Type:
- base_retriever¶
The underlying retriever to query with rephrased query.
- Type:
- llm_config¶
LLM configuration for query rephrasing.
- Type:
Examples
>>> from haive.core.engine.retriever import RePhraseQueryRetrieverConfig >>> 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 rephrase query retriever >>> config = RePhraseQueryRetrieverConfig( ... name="rephrase_retriever", ... base_retriever=base_config, ... llm_config=llm_config ... ) >>> >>> # Instantiate and use the retriever >>> retriever = config.instantiate() >>> docs = retriever.get_relevant_documents("machine learning stuff")
- instantiate()[source]¶
Create a Rephrase Query retriever from this configuration.
- Returns:
Instantiated retriever ready for query rephrasing retrieval.
- Return type:
RePhraseQueryRetriever
- Raises:
ImportError – If required packages are not available.
ValueError – If configuration is invalid.