Skip to content

Commit 1028572

Browse files
committed
dotSimilarity does not return negative floats
1 parent 59dff2c commit 1028572

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

elastiknn-models/src/main/java/com/klibisz/elastiknn/models/ExactModel.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ public static double cosineSimilarity(FloatVectorOps floatVectorOps, float[] v1,
4141

4242
@ForceInline
4343
public static double dotSimilarity(FloatVectorOps floatVectorOps, float[] v1, float[] v2) {
44-
return 1 + floatVectorOps.dotSimilarity(v1, v2);
44+
return Math.max(-1.0,1 + floatVectorOps.dotSimilarity(v1, v2));
4545
}
4646
}

0 commit comments

Comments
 (0)