hnsw_build | R Documentation |
Build an hnswlib nearest neighbor index
hnsw_build(
X,
distance = "euclidean",
M = 16,
ef = 200,
verbose = FALSE,
progress = "bar",
n_threads = 0,
grain_size = 1,
byrow = TRUE
)
X |
A numeric matrix of data to search for neighbors. If |
distance |
Type of distance to calculate. One of:
|
M |
Controls the number of bi-directional links created for each element
during index construction. Higher values lead to better results at the
expense of memory consumption. Typical values are |
ef |
Size of the dynamic list used during construction. A larger value means a better quality index, but increases build time. Should be an integer value between 1 and the size of the dataset. |
verbose |
If |
progress |
defunct and has no effect. |
n_threads |
Maximum number of threads to use. The exact number is
determined by |
grain_size |
Minimum amount of work to do (rows in |
byrow |
if |
an instance of a HnswL2
, HnswCosine
or HnswIp
class.
irism <- as.matrix(iris[, -5])
ann <- hnsw_build(irism)
iris_nn <- hnsw_search(irism, ann, k = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.