Re: [PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-30 Thread via GitHub
benwtrent merged PR #12727: URL: https://github.com/apache/lucene/pull/12727 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@lucene.a

Re: [PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-30 Thread via GitHub
jpountz commented on code in PR #12727: URL: https://github.com/apache/lucene/pull/12727#discussion_r1376230730 ## lucene/core/src/test/org/apache/lucene/util/TestVectorUtil.java: ## @@ -115,6 +116,21 @@ public void testNormalizeZeroThrows() { expectThrows(IllegalArgumentEx

Re: [PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-30 Thread via GitHub
jpountz commented on PR #12727: URL: https://github.com/apache/lucene/pull/12727#issuecomment-1785162374 I had a suspicion that the double promotion is not buying us anything in that case, so I ran a quick test that seems to confirm it: ```java long equals = 0; long notEquals =

Re: [PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-30 Thread via GitHub
benwtrent commented on PR #12727: URL: https://github.com/apache/lucene/pull/12727#issuecomment-1785060096 @ChrisHegarty added a test for verifying VectorSimilarityFunction returns scores `>= 0`. -- This is an automated message from the Apache Git Service. To respond to the message, pleas

Re: [PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-28 Thread via GitHub
ChrisHegarty commented on code in PR #12727: URL: https://github.com/apache/lucene/pull/12727#discussion_r1375318432 ## lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java: ## @@ -70,7 +74,11 @@ public float compare(byte[] v1, byte[] v2) { COSINE {

Re: [PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-28 Thread via GitHub
ChrisHegarty commented on code in PR #12727: URL: https://github.com/apache/lucene/pull/12727#discussion_r1375316778 ## lucene/core/src/java/org/apache/lucene/index/VectorSimilarityFunction.java: ## @@ -70,7 +74,11 @@ public float compare(byte[] v1, byte[] v2) { COSINE {

Re: [PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-28 Thread via GitHub
ChrisHegarty commented on PR #12727: URL: https://github.com/apache/lucene/pull/12727#issuecomment-1783913908 Hi @benwtrent I think that this is fine - LGTM, just dropping a few small comments / questions. I grabbed and modified your test, and was able to repo this on both my Linu

[PR] Ensure negative scores are not returned by vector similarity functions [lucene]

2023-10-27 Thread via GitHub
benwtrent opened a new pull request, #12727: URL: https://github.com/apache/lucene/pull/12727 We shouldn't ever return negative scores from vector similarity functions. Given vector panama and nearly antipodal float[] vectors, it is possible that cosine and (normalized) dot-product become s