langchain_community.utils.math.cosine_similarity¶

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

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

Parameters
  • X (Union[List[List[float]], List[ndarray], ndarray]) –

  • Y (Union[List[List[float]], List[ndarray], ndarray]) –

Return type

ndarray