Class RelevanceScore

java.lang.Object
dev.langchain4j.store.embedding.RelevanceScore

public class RelevanceScore extends Object
Utility class for converting between cosine similarity and relevance score.
  • Method Details

    • fromCosineSimilarity

      public static double fromCosineSimilarity(double cosineSimilarity)
      Converts cosine similarity into relevance score.
      Parameters:
      cosineSimilarity - Cosine similarity in the range [-1..1] where -1 is not relevant and 1 is relevant.
      Returns:
      Relevance score in the range [0..1] where 0 is not relevant and 1 is relevant.