Class MultiQueryExpander

java.lang.Object
org.springframework.ai.rag.preretrieval.query.expansion.MultiQueryExpander
All Implemented Interfaces:
Function<Query, List<Query>>, QueryExpander

public final class MultiQueryExpander extends Object implements 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