From 0a7a20c1406427b7c1c4f094cc7c7fe9fb7d07aa Mon Sep 17 00:00:00 2001 From: Andy Martinez Date: Tue, 24 Dec 2024 12:04:47 -0500 Subject: [PATCH] Cosine similarity should be orthogonal when both vectors are zero --- common/common.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/common/common.cpp b/common/common.cpp index 20be92911..090c7c409 100644 --- a/common/common.cpp +++ b/common/common.cpp @@ -1819,11 +1819,8 @@ float common_embd_similarity_cos(const float * embd1, const float * embd2, int n sum2 += embd2[i] * embd2[i]; } - // Handle the case where one or both vectors are zero vectors + // Both vectors are required to be non-zero. if (sum1 == 0.0 || sum2 == 0.0) { - if (sum1 == 0.0 && sum2 == 0.0) { - return 1.0f; // two zero vectors are similar - } return 0.0f; }