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 27962ce commit 44b7889Copy full SHA for 44b7889
libs/community/langchain_community/utils/math.py
@@ -64,7 +64,7 @@ def cosine_similarity_top_k(
64
if len(X) == 0 or len(Y) == 0:
65
return [], []
66
score_array = cosine_similarity(X, Y)
67
- score_threshold = score_threshold or -1.0
+ score_threshold = -1.0 if score_threshold is None else score_threshold
68
score_array[score_array < score_threshold] = 0
69
top_k = int(min(top_k or len(score_array), int(np.count_nonzero(score_array))))
70
top_k_idxs = np.argpartition(score_array, -top_k, axis=None)[-top_k:]
0 commit comments