HNSW
Source header: cuvs/neighbors/hnsw.hpp
hnswlib index wrapper params
neighbors::hnsw::HnswHierarchy
Hierarchy for HNSW index when converting from CAGRA index
NOTE: When the value is NONE, the HNSW index is built as a base-layer-only index.
Values
neighbors::hnsw::[[deprecated
Create a CAGRA index parameters compatible with HNSW index
- IMPORTANT NOTE *
The reference HNSW index and the corresponding from-CAGRA generated HNSW index will NOT produce the same recalls and QPS for the same parameter ef. The graphs are different internally. For the same ef, the from-CAGRA index likely has a slightly higher recall and slightly lower QPS. However, the Recall-QPS curves should be similar (i.e. the points are just shifted along the curve).
Usage example:
Parameters
Returns
void
hnswlib index wrapper
neighbors::hnsw::index
hnswlib index wrapper
neighbors::hnsw::index::index
load a base-layer-only hnswlib index originally saved from a built CAGRA index.
This is a virtual class and it cannot be used directly. To create an index, use the factory function cuvs::neighbors::hnsw::from_cagra from the header cuvs/neighbors/hnsw.hpp
Parameters
Returns
void
neighbors::hnsw::index::get_index
Get underlying index
Returns
virtual void const*
neighbors::hnsw::index::set_ef
Set ef for search
Parameters
Returns
virtual void
neighbors::hnsw::index::file_path
Get file path for disk-backed index
Returns
virtual std::string
HNSW index extend parameters
neighbors::hnsw::extend_params
HNSW index extend parameters
Fields
Build HNSW index on the GPU
neighbors::hnsw::build
Build an HNSW index on the GPU
The resulting graph is compatible for HNSW search, but is not an exact equivalent of the graph built by the HNSW.
The HNSW index construction parameters M and ef_construction are the main parameters to control the graph degree and graph quality. We have additional options that can be used to fine tune graph building on the GPU (see cuvs::neighbors::cagra::index_params). In case the index does not fit the host or GPU memory, we would use disk as temporary storage. In such cases it is important to set ace_params.build_dir to a fast disk with sufficient storage size.
NOTE: This function requires CUDA headers to be available at compile time.
Usage example:
Parameters
Returns
Additional overload: neighbors::hnsw::build
Build an HNSW index on the GPU
The resulting graph is compatible for HNSW search, but is not an exact equivalent of the graph built by the HNSW.
The HNSW index construction parameters M and ef_construction are the main parameters to control the graph degree and graph quality. We have additional options that can be used to fine tune graph building on the GPU (see cuvs::neighbors::cagra::index_params). In case the index does not fit the host or GPU memory, we would use disk as temporary storage. In such cases it is important to set ace_params.build_dir to a fast disk with sufficient storage size.
NOTE: This function requires CUDA headers to be available at compile time.
Usage example:
Parameters
Returns
Additional overload: neighbors::hnsw::build
Build an HNSW index on the GPU
The resulting graph is compatible for HNSW search, but is not an exact equivalent of the graph built by the HNSW.
The HNSW index construction parameters M and ef_construction are the main parameters to control the graph degree and graph quality. We have additional options that can be used to fine tune graph building on the GPU (see cuvs::neighbors::cagra::index_params). In case the index does not fit the host or GPU memory, we would use disk as temporary storage. In such cases it is important to set ace_params.build_dir to a fast disk with sufficient storage size.
NOTE: This function requires CUDA headers to be available at compile time.
Usage example:
Parameters
Returns
std::unique_ptr<index<uint8_t>>
Additional overload: neighbors::hnsw::build
Build an HNSW index on the GPU
The resulting graph is compatible for HNSW search, but is not an exact equivalent of the graph built by the HNSW.
The HNSW index construction parameters M and ef_construction are the main parameters to control the graph degree and graph quality. We have additional options that can be used to fine tune graph building on the GPU (see cuvs::neighbors::cagra::index_params). In case the index does not fit the host or GPU memory, we would use disk as temporary storage. In such cases it is important to set ace_params.build_dir to a fast disk with sufficient storage size.
NOTE: This function requires CUDA headers to be available at compile time.
Usage example:
Parameters
Returns
std::unique_ptr<index<int8_t>>
Load CAGRA index as hnswlib index
neighbors::hnsw::from_cagra
Construct an hnswlib index from a CAGRA index
NOTE: When hnsw::index_params.hierarchy is:
NONE: This method uses the filesystem to write the CAGRA index in/tmp/<random_number>.binbefore reading it as an hnswlib index, then deleting the temporary file. The returned index is immutable and can only be searched by the hnswlib wrapper in cuVS, as the format is not compatible with the original hnswlib.CPU: The returned index is mutable and can be extended with additional vectors. The serialized index is also compatible with the original hnswlib library.
Usage example:
Parameters
Returns
Additional overload: neighbors::hnsw::from_cagra
Construct an hnswlib index from a CAGRA index
NOTE: When hnsw::index_params.hierarchy is:
NONE: This method uses the filesystem to write the CAGRA index in/tmp/<random_number>.binbefore reading it as an hnswlib index, then deleting the temporary file. The returned index is immutable and can only be searched by the hnswlib wrapper in cuVS, as the format is not compatible with the original hnswlib.CPU: The returned index is mutable and can be extended with additional vectors. The serialized index is also compatible with the original hnswlib library.
Usage example:
Parameters
Returns
Additional overload: neighbors::hnsw::from_cagra
Construct an hnswlib index from a CAGRA index
NOTE: When hnsw::index_params.hierarchy is:
NONE: This method uses the filesystem to write the CAGRA index in/tmp/<random_number>.binbefore reading it as an hnswlib index, then deleting the temporary file. The returned index is immutable and can only be searched by the hnswlib wrapper in cuVS, as the format is not compatible with the original hnswlib.CPU: The returned index is mutable and can be extended with additional vectors. The serialized index is also compatible with the original hnswlib library.
Usage example:
Parameters
Returns
std::unique_ptr<index<uint8_t>>
Additional overload: neighbors::hnsw::from_cagra
Construct an hnswlib index from a CAGRA index
NOTE: When hnsw::index_params.hierarchy is:
NONE: This method uses the filesystem to write the CAGRA index in/tmp/<random_number>.binbefore reading it as an hnswlib index, then deleting the temporary file. The returned index is immutable and can only be searched by the hnswlib wrapper in cuVS, as the format is not compatible with the original hnswlib.CPU: The returned index is mutable and can be extended with additional vectors. The serialized index is also compatible with the original hnswlib library.
Usage example:
Parameters
Returns
std::unique_ptr<index<int8_t>>
Extend HNSW index with additional vectors
neighbors::hnsw::extend
Add new vectors to an HNSW index
NOTE: The HNSW index can only be extended when the hnsw::index_params.hierarchy is CPU when converting from a CAGRA index.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::extend
Add new vectors to an HNSW index
NOTE: The HNSW index can only be extended when the hnsw::index_params.hierarchy is CPU when converting from a CAGRA index.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::extend
Add new vectors to an HNSW index
NOTE: The HNSW index can only be extended when the hnsw::index_params.hierarchy is CPU when converting from a CAGRA index.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::extend
Add new vectors to an HNSW index
NOTE: The HNSW index can only be extended when the hnsw::index_params.hierarchy is CPU when converting from a CAGRA index.
Usage example:
Parameters
Returns
void
Build CAGRA index and search with hnswlib
neighbors::hnsw::search_params
Build CAGRA index and search with hnswlib
Fields
Search hnswlib index
neighbors::hnsw::search
Search HNSW index constructed from a CAGRA index
NOTE: The HNSW index can only be searched by the hnswlib wrapper in cuVS when the hierarchy is NONE, as the format is not compatible with the original hnswlib.
[n_queries, k] k]
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::search
Search HNSW index constructed from a CAGRA index
NOTE: The HNSW index can only be searched by the hnswlib wrapper in cuVS when the hierarchy is NONE, as the format is not compatible with the original hnswlib.
[n_queries, k] k]
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::search
Search HNSWindex constructed from a CAGRA index
NOTE: The HNSW index can only be searched by the hnswlib wrapper in cuVS when the hierarchy is NONE, as the format is not compatible with the original hnswlib.
[n_queries, k] k]
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::search
Search HNSW index constructed from a CAGRA index
NOTE: The HNSW index can only be searched by the hnswlib wrapper in cuVS when the hierarchy is NONE, as the format is not compatible with the original hnswlib.
[n_queries, k] k]
Usage example:
Parameters
Returns
void
Deserialize CAGRA index as hnswlib index
neighbors::hnsw::serialize
Serialize the HNSW index to file
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::serialize
Serialize the HNSW index to file
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::serialize
Serialize the HNSW index to file
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::serialize
Serialize the HNSW index to file
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void
neighbors::hnsw::deserialize
De-serialize a CAGRA index saved to a file as an hnswlib index
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::deserialize
De-serialize a CAGRA index saved to a file as an hnswlib index
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::deserialize
De-serialize a CAGRA index saved to a file as an hnswlib index
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void
Additional overload: neighbors::hnsw::deserialize
De-serialize a CAGRA index saved to a file as an hnswlib index
NOTE: When hierarchy is NONE, the saved hnswlib index is immutable and can only be read by the hnswlib wrapper in cuVS, as the serialization format is not compatible with the original hnswlib. However, when hierarchy is CPU, the saved hnswlib index is compatible with the original hnswlib library.
Usage example:
Parameters
Returns
void