Neighbors | NVIDIA cuVS

Neighbors

View as Markdown

Python module: cuvs.neighbors

refine

@auto_sync_resources @auto_convert_output

Refine nearest neighbor search.

Refinement is an operation that follows an approximate NN search. The approximate search has already selected n_candidates neighbor candidates for each query. We narrow it down to k neighbors. For each query, we calculate the exact distance between the query and its n_candidates neighbor candidate, and select the k nearest ones.

Input arrays can be either CUDA array interface compliant matrices or array interface compliant matrices in host memory. All array must be in the same memory space.

Parameters

NameTypeDescription
datasetarray interface compliant matrix, shape (n_samples, dim)Supported dtype [float32, int8, uint8, float16]
queriesarray interface compliant matrix, shape (n_queries, dim)Supported dtype [float32, int8, uint8, float16]
candidatesarray interface compliant matrix, shape (n_queries, k0)Supported dtype int64
kintNumber of neighbors to search (k <= k0). Optional if indices or distances arrays are given (in which case their second dimension is k).
metricstrName of distance metric to use, default =“sqeuclidean”
indicesOptional array interface compliant matrix shape (n_queries, k).If supplied, neighbor indices will be written here in-place. (default None). Supported dtype int64.
distancesOptional array interface compliant matrix shape (n_queries, k).If supplied, neighbor indices will be written here in-place. (default None) Supported dtype float.
resourcescuvs.common.Resources, optional

Examples