We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f64aec3 commit 6d4f6f3Copy full SHA for 6d4f6f3
langchain_postgres/_utils.py
@@ -30,10 +30,8 @@ def cosine_similarity(X: Matrix, Y: Matrix) -> np.ndarray:
30
31
X = np.array(X, dtype=np.float32)
32
Y = np.array(Y, dtype=np.float32)
33
- Z = 1 - simd.cdist(X, Y, metric="cosine")
34
- if isinstance(Z, float):
35
- return np.array([Z])
36
- return np.array(Z)
+ Z = 1 - np.array(simd.cdist(X, Y, metric="cosine"))
+ return Z
37
except ImportError:
38
logger.debug(
39
"Unable to import simsimd, defaulting to NumPy implementation. If you want "
0 commit comments