cosine_similarity#

langchain_mongodb.utils.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