Package dev.langchain4j.store.embedding
Class EmbeddingMatch<Embedded>
java.lang.Object
dev.langchain4j.store.embedding.EmbeddingMatch<Embedded>
- Type Parameters:
Embedded
- The class of the object that has been embedded. Typically, it isTextSegment
.
Represents a matched embedding along with its relevance score (derivative of cosine distance), ID, and original embedded content.
-
Constructor Summary
ConstructorDescriptionEmbeddingMatch
(Double score, String embeddingId, Embedding embedding, Embedded embedded) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionembedded()
Returns the original content that was embedded.Returns the embedding that has been matched.The ID of the embedding assigned when adding this embedding to the store.boolean
int
hashCode()
score()
Returns the relevance score (derivative of cosine distance) of this embedding compared to a reference embedding during a search.toString()
-
Constructor Details
-
EmbeddingMatch
Creates a new instance.- Parameters:
score
- The relevance score (derivative of cosine distance) of this embedding compared to a reference embedding during a search.embeddingId
- The ID of the embedding assigned when adding this embedding to the store.embedding
- The embedding that has been matched.embedded
- The original content that was embedded. Typically, this is aTextSegment
.
-
-
Method Details
-
score
Returns the relevance score (derivative of cosine distance) of this embedding compared to a reference embedding during a search. The current implementation assumes that the embedding store uses cosine distance when comparing embeddings.- Returns:
- Relevance score, ranging from 0 (not relevant) to 1 (highly relevant).
-
embeddingId
The ID of the embedding assigned when adding this embedding to the store.- Returns:
- The ID of the embedding assigned when adding this embedding to the store.
-
embedding
Returns the embedding that has been matched.- Returns:
- The embedding that has been matched.
-
embedded
Returns the original content that was embedded.- Returns:
- The original content that was embedded. Typically, this is a
TextSegment
.
-
equals
-
hashCode
public int hashCode() -
toString
-