hnswlib icon indicating copy to clipboard operation
hnswlib copied to clipboard

Support "skipping" nodes during traversal?

Open sourcesync opened this issue 3 years ago • 3 comments

Is it possible to tell the HNSW algorithm to skip a given set of nodes during search/traversal?

Note that I do not want "delete" nodes.

I just want the traversal to skip a set of pre-determined nodes when it's deciding to add any of those "skip nodes" to the list of nearest neighbors, as its traversing the graph.

I think this means that for a "Top-K" list of nearest neighbors - the kind of search I describe may have to perform a few more traversals to get to K items ( since it may have "skipped" a few nodes along the way. )

I don't want "delete" because the "skip node list" may be different between searches on the same graph.

sourcesync avatar Mar 12 '21 23:03 sourcesync

Hu @gosha1128, That sure if possible, but requires alteration of the C++ code (can point out to the place in the code).

yurymalkov avatar Mar 15 '21 01:03 yurymalkov

Yes that would be great- thanks.

sourcesync avatar Mar 15 '21 02:03 sourcesync

In the main search cycle https://github.com/nmslib/hnswlib/blob/master/hnswlib/hnswalg.h#L249 you can replace all isMarkedDeleted(some_internal_id) to a check that some_internal_id does not belong to this node set.

yurymalkov avatar Mar 15 '21 03:03 yurymalkov