You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/11/17 10:44:00 UTC

[GitHub] [lucene] agorlenko commented on a diff in pull request #11946: add similarity threshold for hnsw

agorlenko commented on code in PR #11946:
URL: https://github.com/apache/lucene/pull/11946#discussion_r1025027735


##########
lucene/core/src/test/org/apache/lucene/index/TestExitableDirectoryReader.java:
##########
@@ -494,13 +498,12 @@ public void testVectorValues() throws IOException {
           ExitingReaderException.class,
           () ->
               leaf.searchNearestVectors(
-                  "vector", new float[dimension], 5, leaf.getLiveDocs(), Integer.MAX_VALUE));
+                  "vector", target, 5, leaf.getLiveDocs(), Integer.MAX_VALUE));

Review Comment:
   There is a problem, because cosine similarity is not specified for zero vectors. As a result we have NaN score. I thought that it would be better not to handle that special case and get rid of docs with score equals NaN. We had the same behavior earlier, except the case with start point: https://github.com/apache/lucene/blob/a18b62ded49f1b091de7029716d6f63c06a36fc0/lucene/core/src/java/org/apache/lucene/util/hnsw/HnswGraphSearcher.java#L223-L225 We check acceptOrds.get here and raise an exception.  But actually we don't need to check acceptOrds in the case of zero vector and the cosine similarity. So I think it would be better just not to consider that case if we want to test ExitingReaderException and just define the target as a random float vector.



-- 
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-unsubscribe@lucene.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org