Refine

View as Markdown

Source header: cuvs/neighbors/refine.h

Approximate Nearest Neighbors Refinement C-API

cuvsRefine

Refine nearest neighbor search.

1CUVS_EXPORT cuvsError_t cuvsRefine(cuvsResources_t res,
2DLManagedTensor* dataset,
3DLManagedTensor* queries,
4DLManagedTensor* candidates,
5cuvsDistanceType metric,
6DLManagedTensor* indices,
7DLManagedTensor* distances);

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.

Parameters

NameDirectionTypeDescription
resincuvsResources_tcuvsResources_t opaque C handle
datasetinDLManagedTensor*device matrix that stores the dataset [n_rows, dims]
queriesinDLManagedTensor*device matrix of the queries [n_queris, dims]
candidatesinDLManagedTensor*indices of candidate vectors [n_queries, n_candidates], where n_candidates >= k
metricincuvsDistanceTypedistance metric to use. Euclidean (L2) is used by default
indicesoutDLManagedTensor*device matrix that stores the refined indices [n_queries, k]
distancesoutDLManagedTensor*device matrix that stores the refined distances [n_queries, k]

Returns

CUVS_EXPORT cuvsError_t