Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
Update HNSW Brute Force Threshold While Searching with Bitset (#829)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Weizhi Xu <weizhi.xu@zilliz.com>
  • Loading branch information
PwzXxm authored Apr 21, 2023
1 parent b2cab04 commit 5cd495a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion thirdparty/DiskANN/src/pq_flash_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ namespace diskann {
float query_norm = query_norm_opt.value();
auto ctx = this->reader->get_ctx();

if (!bitset_view.empty() && bitset_view.count() > bitset_view.size() * kDiskAnnBruteForceFilterRate) {
if (!bitset_view.empty() && bitset_view.count() >= bitset_view.size() * kDiskAnnBruteForceFilterRate) {
brute_force_beam_search(data, query_norm, k_search, indices, distances,
beam_width, ctx, stats, feder, bitset_view);
this->thread_data.push(data);
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/hnswlib/hnswlib/hnswalg.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
namespace hnswlib {
typedef unsigned int tableint;
typedef unsigned int linklistsizeint;
constexpr float kHnswBruteForceFilterRate = 0.8f;
constexpr float kHnswBruteForceFilterRate = 0.93f;

template <typename dist_t>
class HierarchicalNSW : public AlgorithmInterface<dist_t> {
Expand Down Expand Up @@ -1030,7 +1030,7 @@ class HierarchicalNSW : public AlgorithmInterface<dist_t> {
if (cur_element_count == 0)
return {};

if (!bitset.empty() && bitset.count() > (cur_element_count * kHnswBruteForceFilterRate)) {
if (!bitset.empty() && bitset.count() >= (cur_element_count * kHnswBruteForceFilterRate)) {
assert(cur_element_count == bitset.size());
knowhere::ResultMaxHeap<dist_t, labeltype> max_heap(k);
for (labeltype id = 0; id < cur_element_count; ++id) {
Expand Down

0 comments on commit 5cd495a

Please sign in to comment.