-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update several minor in conjugate graph #147
Conversation
768d717
to
8a50245
Compare
} | ||
|
||
// return result | ||
while (results.size() > k) { | ||
results.pop(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comparing with original search process, here only move partial pop operations from hnswalg to hnsw. So it wouldn't affect the search speed.
std::priority_queue<std::pair<float, size_t>> results; | ||
double time_cost; | ||
try { | ||
Timer t(time_cost); | ||
if (use_conjugate_graph_ and params.use_conjugate_graph_search) { | ||
k = LOOK_AT_K; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here adjust k to provide enough information for conjugate graph to enhance result
if (this->is_empty()) { | ||
return 0; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here allow use conjugate graph as default setting without influencing search process
@@ -27,6 +27,9 @@ ConjugateGraph::AddNeighbor(int64_t from_tag_id, int64_t to_tag_id) { | |||
return false; | |||
} | |||
auto& neighbor_set = conjugate_graph_[from_tag_id]; | |||
if (neighbor_set.size() >= MAXIMUM_DEGREE) { | |||
return false; | |||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here limit out degree to limit graph size and enhance latency
src/index/hnsw.cpp
Outdated
std::priority_queue<std::pair<float, size_t>> results; | ||
double time_cost; | ||
try { | ||
Timer t(time_cost); | ||
if (use_conjugate_graph_ and params.use_conjugate_graph_search) { | ||
k = LOOK_AT_K; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider the situation when k > LOOK_AT_K
src/index/hnsw.cpp
Outdated
@@ -701,10 +709,15 @@ HNSW::brute_force(const DatasetPtr& query, int64_t k) { | |||
float* dists = (float*)allocator_->Allocate(sizeof(float) * k); | |||
result->Distances(dists); | |||
|
|||
auto vector = query->GetFloat32Vectors(); | |||
const void* vector; | |||
if (type_ == DataTypes::DATA_TYPE_INT8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use get_vectors
here to replace the judgement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
auto base = Dataset::Make(); | ||
auto generated_query = Dataset::Make(); | ||
if (type_ == DataTypes::DATA_TYPE_INT8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
src/index/hnsw.cpp
Outdated
|
||
for (const int64_t& base_tag_id : base_tag_ids) { | ||
try { | ||
base->Float32Vectors(this->alg_hnsw_->getDataByLabel(base_tag_id)); | ||
if (type_ == DataTypes::DATA_TYPE_INT8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
||
for (int d = 0; d < dim_; d++) { | ||
generated_data.get()[d] = vsag::GENERATE_OMEGA * base->GetFloat32Vectors()[d] + | ||
(1 - vsag::GENERATE_OMEGA) * topk_data[d]; | ||
if (type_ == DataTypes::DATA_TYPE_INT8) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
0c3eeb7
to
1068b44
Compare
1068b44
to
2ea5ac9
Compare
->Owner(false) | ||
->NumElements(num_element); | ||
} else if (type_ == DataTypes::DATA_TYPE_INT8) { | ||
base->Int8Vectors((int8_t*)vectors_ptr)->Dim(dim_)->Owner(false)->NumElements(num_element); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indent
src/index/hnsw.cpp
Outdated
} else if (type_ == DataTypes::DATA_TYPE_INT8) { | ||
base->Int8Vectors((int8_t*)vectors_ptr)->Dim(dim_)->Owner(false)->NumElements(num_element); | ||
} else { | ||
throw std::invalid_argument(fmt::format("no support for this metric: {}", (int)type_)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no support for this data type: ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
26f2be5
to
64e3f4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
ec373ec
to
dd48c34
Compare
dd48c34
to
642866a
Compare
This PR contains several minor changes in conjugate graph: