For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
GitHubCUDA-X
    • Home
    • Installation
  • Getting Started
    • Introduction
    • Integrations
    • Use-cases
  • User Guide
    • API Guide
    • Benchmarking Guide
    • Field Guide
    • References
  • Developer Guide
    • Coding Guidelines
    • Contributing
  • API Reference
    • C API Documentation
      • Cluster Kmeans
      • Core C API
      • Distance Distance
      • Distance Pairwise Distance
      • Neighbors Multi GPU Cagra
      • Neighbors Multi GPU Common
      • Neighbors Multi GPU IVF Flat
      • Neighbors Multi GPU IVF PQ
      • Neighbors All Neighbors
      • Neighbors Brute Force
      • Neighbors Cagra
      • Neighbors Common
      • Neighbors HNSW
      • Neighbors IVF Flat
      • Neighbors IVF PQ
      • Neighbors IVF SQ
      • Neighbors NN Descent
      • Neighbors Refine
      • Neighbors Tiered Index
      • Neighbors Vamana
      • Preprocessing Quantize Binary
      • Preprocessing PCA
      • Preprocessing Quantize PQ
      • Preprocessing Quantize Scalar
    • Cpp API Documentation
    • Python API Documentation
    • Java API Documentation
    • Rust API Documentation
    • Go API Documentation
NVIDIANVIDIA
Developer-friendly docs for your API
Privacy Policy | Your Privacy Choices | Terms of Service | Accessibility | Corporate Policies | Product Security | Contact

Copyright © 2026, NVIDIA Corporation.

LogoLogocuVS
GitHubCUDA-X
On this page
  • Approximate Nearest Neighbors Refinement C-API
  • cuvsRefine
API ReferenceC API Documentation

Refine

||View as Markdown|
Previous

Neighbors NN Descent

Next

Neighbors Tiered Index

Source header: cuvs/neighbors/refine.h

Approximate Nearest Neighbors Refinement C-API

cuvsRefine

Refine nearest neighbor search.

1cuvsError_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

cuvsError_t