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
Content
s to the provided Query
,
without any Filter
ing.
Configurable parameters (optional):
-
displayName
: Display name for logging purposes, e.g. when multiple instances are used.
-
maxResults
: The maximum number of Content
s 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 Content
s.
Content
s 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
Modifier and TypeClassDescriptionstatic class
-
Field Summary
-
Constructor Summary
ConstructorDescriptionEmbeddingStoreContentRetriever
(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 anEmbeddingStoreContentRetriever
from the specifiedEmbeddingStore
andEmbeddingModel
found 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 anEmbeddingStoreContentRetriever
from the specifiedEmbeddingStore
andEmbeddingModel
found through SPI (seeEmbeddingModelFactory
). -
retrieve
Description copied from interface:ContentRetriever
Retrieves relevantContent
s using a givenQuery
. TheContent
s are sorted by relevance, with the most relevantContent
s appearing at the beginning of the returnedList<Content>
.- Specified by:
retrieve
in interfaceContentRetriever
- Parameters:
query
- TheQuery
to use for retrieval.- Returns:
- A list of retrieved
Content
s.
-
toString
-