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 is TextSegment.

public class EmbeddingMatch<Embedded> extends Object
Represents a matched embedding along with its relevance score (derivative of cosine distance), ID, and original embedded content.
  • Constructor Details

    • EmbeddingMatch

      public EmbeddingMatch(Double score, String embeddingId, Embedding embedding, Embedded embedded)
      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 a TextSegment.
  • Method Details

    • score

      public Double 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

      public String 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

      public Embedding embedding()
      Returns the embedding that has been matched.
      Returns:
      The embedding that has been matched.
    • embedded

      public Embedded embedded()
      Returns the original content that was embedded.
      Returns:
      The original content that was embedded. Typically, this is a TextSegment.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object