Class EmbeddingStoreContentRetriever
java.lang.Object
dev.langchain4j.rag.content.retriever.EmbeddingStoreContentRetriever
- All Implemented Interfaces:
ContentRetriever
A
By default, it retrieves the 3 most similar
Configurable parameters (optional):
-
-
-
-
-
-
-
ContentRetriever that retrieves from an EmbeddingStore.
By default, it retrieves the 3 most similar
Contents to the provided Query,
without any Filtering.
Configurable parameters (optional):
-
displayName: Display name for logging purposes, e.g. when multiple instances are used.
-
maxResults: The maximum number of Contents to retrieve.
-
dynamicMaxResults: It is a Function that accepts a Query and returns a maxResults value.
It can be used to dynamically define maxResults value, depending on factors such as the query,
the user (using Metadata#chatMemoryId()} from Query.metadata()), etc.
-
minScore: The minimum relevance score for the returned Contents.
Contents scoring below #minScore are excluded from the results.
-
dynamicMinScore: It is a Function that accepts a Query and returns a minScore value.
It can be used to dynamically define minScore value, depending on factors such as the query,
the user (using Metadata#chatMemoryId()} from Query.metadata()), etc.
-
filter: The Filter that will be applied to a Metadata in the
Content.textSegment().
-
dynamicFilter: It is a Function that accepts a Query and returns a filter value.
It can be used to dynamically define filter value, depending on factors such as the query,
the user (using Metadata#chatMemoryId()} from Query.metadata()), etc.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionEmbeddingStoreContentRetriever(EmbeddingStore<TextSegment> embeddingStore, EmbeddingModel embeddingModel) EmbeddingStoreContentRetriever(EmbeddingStore<TextSegment> embeddingStore, EmbeddingModel embeddingModel, int maxResults) EmbeddingStoreContentRetriever(EmbeddingStore<TextSegment> embeddingStore, EmbeddingModel embeddingModel, Integer maxResults, Double minScore) -
Method Summary
Modifier and TypeMethodDescriptionbuilder()from(EmbeddingStore<TextSegment> embeddingStore) Creates an instance of anEmbeddingStoreContentRetrieverfrom the specifiedEmbeddingStoreandEmbeddingModelfound through SPI (seeEmbeddingModelFactory).toString()
-
Field Details
-
DEFAULT_MAX_RESULTS
-
DEFAULT_MIN_SCORE
-
DEFAULT_FILTER
-
DEFAULT_DISPLAY_NAME
- See Also:
-
-
Constructor Details
-
EmbeddingStoreContentRetriever
public EmbeddingStoreContentRetriever(EmbeddingStore<TextSegment> embeddingStore, EmbeddingModel embeddingModel) -
EmbeddingStoreContentRetriever
public EmbeddingStoreContentRetriever(EmbeddingStore<TextSegment> embeddingStore, EmbeddingModel embeddingModel, int maxResults) -
EmbeddingStoreContentRetriever
public EmbeddingStoreContentRetriever(EmbeddingStore<TextSegment> embeddingStore, EmbeddingModel embeddingModel, Integer maxResults, Double minScore)
-
-
Method Details
-
builder
-
from
Creates an instance of anEmbeddingStoreContentRetrieverfrom the specifiedEmbeddingStoreandEmbeddingModelfound through SPI (seeEmbeddingModelFactory). -
retrieve
Description copied from interface:ContentRetrieverRetrieves relevantContents using a givenQuery. TheContents are sorted by relevance, with the most relevantContents appearing at the beginning of the returnedList<Content>.- Specified by:
retrievein interfaceContentRetriever- Parameters:
query- TheQueryto use for retrieval.- Returns:
- A list of retrieved
Contents.
-
toString
-