Class MultiQueryExpander
java.lang.Object
org.springframework.ai.rag.preretrieval.query.expansion.MultiQueryExpander
- All Implemented Interfaces:
Function<Query,
,List<Query>> QueryExpander
Uses a large language model to expand a query into multiple semantically diverse
variations to capture different perspectives, useful for retrieving additional
contextual information and increasing the chances of finding relevant results.
Example usage:
MultiQueryExpander expander = MultiQueryExpander.builder()
.chatClientBuilder(chatClientBuilder)
.numberOfQueries(3)
.build();
List<Query> queries = expander.expand(new Query("How to run a Spring Boot app?"));
- Since:
- 1.0.0
- Author:
- Thomas Vitale
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionMultiQueryExpander
(ChatClient.Builder chatClientBuilder, PromptTemplate promptTemplate, Boolean includeOriginal, Integer numberOfQueries) -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.rag.preretrieval.query.expansion.QueryExpander
apply
-
Constructor Details
-
MultiQueryExpander
public MultiQueryExpander(ChatClient.Builder chatClientBuilder, @Nullable PromptTemplate promptTemplate, @Nullable Boolean includeOriginal, @Nullable Integer numberOfQueries)
-
-
Method Details
-
expand
Description copied from interface:QueryExpander
Expands the given query into a list of queries.- Specified by:
expand
in interfaceQueryExpander
- Parameters:
query
- The original query to be expanded- Returns:
- A list of expanded queries
-
builder
-