Package com.tnsai.intelligence.rag
Class MultiQueryRAGStrategy
java.lang.Object
com.tnsai.intelligence.rag.MultiQueryRAGStrategy
- All Implemented Interfaces:
RAGStrategy
Expands one query, retrieves every unique variation through the same
source-scoped base strategy, and fuses the results deterministically.
Reciprocal-rank fusion controls ordering only. The returned document keeps the strongest original strategy score so semantic, keyword, and hybrid score contracts are not replaced by an unrelated fusion scale. Fusion score and query provenance are attached as metadata.
- Since:
- 0.13.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMultiQueryRAGStrategy(RAGStrategy baseStrategy, QueryExpander expander, com.tnsai.annotations.Search.QueryExpansion mode, String model, int maxExpansions) Creates a strategy with no external cancellation signal.MultiQueryRAGStrategy(RAGStrategy baseStrategy, QueryExpander expander, com.tnsai.annotations.Search.QueryExpansion mode, String model, int maxExpansions, com.tnsai.cancellation.CancellationToken cancellationToken) Creates a strategy with an explicit cooperative cancellation signal. -
Method Summary
Modifier and TypeMethodDescriptionname()Returns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").retrieve(String query, RAGContext context) Retrieves documents relevant to the given query.
-
Field Details
-
QUERY_PROVENANCE_METADATA
Metadata containing comma-delimited zero-based query indexes that returned a document. Index0is always the original query.- See Also:
-
FUSION_SCORE_METADATA
Metadata containing the deterministic reciprocal-rank fusion score.- See Also:
-
-
Constructor Details
-
MultiQueryRAGStrategy
public MultiQueryRAGStrategy(RAGStrategy baseStrategy, QueryExpander expander, com.tnsai.annotations.Search.QueryExpansion mode, String model, int maxExpansions) Creates a strategy with no external cancellation signal. -
MultiQueryRAGStrategy
public MultiQueryRAGStrategy(RAGStrategy baseStrategy, QueryExpander expander, com.tnsai.annotations.Search.QueryExpansion mode, String model, int maxExpansions, com.tnsai.cancellation.CancellationToken cancellationToken) Creates a strategy with an explicit cooperative cancellation signal.
-
-
Method Details
-
name
Description copied from interface:RAGStrategyReturns the unique name of this strategy (e.g., "vector", "keyword", "hybrid").Names are compared case-insensitively using
Locale.ROOT.- Specified by:
namein interfaceRAGStrategy- Returns:
- the strategy name, never null
-
retrieve
Description copied from interface:RAGStrategyRetrieves documents relevant to the given query.Every returned document must exactly match all metadata filters in the context. Implementations apply that constraint before limiting the result to
RAGContext.maxResults().- Specified by:
retrievein interfaceRAGStrategy- Parameters:
query- the search query (never null)context- retrieval parameters (max results, min score, exact metadata filters)- Returns:
- an unmodifiable list of retrieved documents, sorted by descending relevance
-