Skip to content

The correctness of HNSW implementation for HNSW::upper_beam != 1 #3610

@alexanderguzhva

Description

@alexanderguzhva

Summary

I wonder whether this (

int candidates_size = upper_beam;
) branch in HNSW is designed in the way as it is implemented.

Currently, it seems that HNSW may use a beam search, which is controlled by a field HNSW::upper_beam. According to the code, upper_beam serves not only as a beam search parameter, but as a replacement of ef parameter, so it is used across all HNSW levels. Logically speaking, I would expect upper_beam to control upper levels only, and leave ef for the last level. So,

MinimaxHeap candidates_upper_levels(upper_beam);
for (int level = max_level; level >= 1; level--) {
    // use `upper_beam`
}

// last level uses `ef`
MinimaxHeap candidates_last_level(ef);
candidates_last_level.copy_from(candidates_upper_levels);
...

@mdouze Could you please comment on the topic? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions