cosine_similarity#

langchain_community.utils.math.cosine_similarity(X: List[List[float]] | List[ndarray] | ndarray, Y: List[List[float]] | List[ndarray] | ndarray) ndarray[source]#

Row-wise cosine similarity between two equal-width matrices.

Parameters:
  • X (List[List[float]] | List[ndarray] | ndarray)

  • Y (List[List[float]] | List[ndarray] | ndarray)

Return type:

ndarray

Examples using cosine_similarity