Interface QueryTransformer
- All Known Implementing Classes:
CompressingQueryTransformer, DefaultQueryTransformer, ExpandingQueryTransformer
public interface QueryTransformer
Transforms the given
The goal is to enhance retrieval quality by modifying or expanding the original
Some known approaches to improve retrieval include:
Query into one or multiple Querys.
The goal is to enhance retrieval quality by modifying or expanding the original
Query.
Some known approaches to improve retrieval include:
- Query compression (seeAdditional details can be found here.CompressingQueryTransformer) - Query expansion (seeExpandingQueryTransformer) - Query re-writing - Step-back prompting - Hypothetical document embeddings (HyDE)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault CompletableFuture<Collection<Query>> transformAsync(Query query) Non-blocking counterpart oftransform(Query), invoked by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service modes when RAG is configured.
-
Method Details
-
transform
-
transformAsync
Non-blocking counterpart oftransform(Query), invoked by the asynchronous (CompletableFuture/CompletionStage) and reactive (Flow.Publisher) AI Service modes when RAG is configured.The default implementation returns a failed future carrying
AsyncNotSupportedException: a transformer backed by a blocking LLM call (e.g. query compression/expansion) must opt in by overriding this method to stay off the calling thread. A transformer that cannot be made non-blocking is still usable from these modes viaDefaultRetrievalAugmentor, which offloads the blockingtransform(Query)to its executor.- Parameters:
query- TheQueryto be transformed.- Returns:
- A
CompletableFutureof one or moreQuerys derived from the originalQuery. - Since:
- 1.20.0
-