ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing
ApX logoApX logo
ModelsCalculatorHardwareCoursesPricing

All Courses

Advanced Vector Search for LLM Applications
Chapter 1: Approximate Nearest Neighbor Algorithms
Revisiting Vector Embeddings and Search Fundamentals
Hierarchical Navigable Small Worlds (HNSW) Internals
Inverted File Index (IVF) Variations
Product Quantization (PQ) Mechanics
Other Graph-Based ANN Methods (e.g., NSG, Vamana)
Selecting the Right ANN Algorithm: Trade-offs
Hands-on Practical: Implementing and Tuning HNSW
Chapter 2: Optimizing Vector Search Performance and Efficiency
Quantization Techniques: Scalar vs. Product
Implementing Optimized Product Quantization (OPQ)
Binary Hashing and Locality Sensitive Hashing (LSH) Refresher
Advanced Filtering Strategies: Pre vs. Post Filtering
Indexing Metadata Efficiently alongside Vectors
Hardware Acceleration Considerations (CPU SIMD, GPU)
Memory Management and Caching Strategies
Practice: Applying Quantization and Filtering
Chapter 3: Hybrid Search Approaches
Limitations of Pure Vector Search
Integrating Keyword Search (BM25, TF-IDF)
Result Fusion and Ranking Strategies
Reciprocal Rank Fusion (RRF) and Other Fusion Algorithms
Graph-Based Augmentation for Vector Search
Multi-Modal Search Considerations
Hands-on Practical: Building a Hybrid Search Pipeline
Chapter 4: Scaling Vector Search for Production Systems
Distributed Vector Database Architectures
Sharding Strategies for Vector Indexes
Replication and High Availability
Load Balancing Search Queries
Monitoring Vector Search Performance Metrics
Index Updates and Maintenance in Production
Cost Optimization for Large-Scale Deployments
Practice: Configuring a Distributed Setup
Chapter 5: Advanced Tuning and Evaluation
Evaluation Metrics Revisited: Recall, Precision, Latency
Building Ground Truth Datasets for Evaluation
Parameter Sensitivity Analysis (HNSW, IVF)
A/B Testing Frameworks for Search Algorithms
Debugging Search Relevance Issues
Online vs. Offline Evaluation Techniques
Tuning for Specific Application Needs (RAG vs. Semantic Search)
Hands-on Practical: Comprehensive Performance Evaluation

Other Graph-Based ANN Methods (e.g., NSG, Vamana)

Hierarchical Navigable Small Worlds (HNSW) is a popular and effective graph-based Approximate Nearest Neighbor (ANN) algorithm, but it is not the only approach leveraging graph structures for efficient vector search. Examining alternative methods like Navigating Spreading-Out Graphs (NSG) and Vamana offers a comprehensive understanding of the design choices and trade-offs inherent in proximity graph construction and search. These methods share the fundamental idea of building a graph where nodes represent data points (vectors) and edges connect points that are close in the embedding space, enabling fast traversal towards the query's nearest neighbors.

Navigating Spreading-Out Graphs (NSG)

NSG focuses on constructing a graph with good "spreading" properties. The core motivation is to ensure that the neighbors of any given node are diverse enough to guide the search effectively across different regions of the data distribution, reducing the chance of getting trapped in local optima during the search process.

Graph Construction: The NSG construction process typically involves these steps:

  1. Initialization: Start with an initial graph, often built using simpler methods like kkk-NN graphs or random connections.
  2. Navigation Node: Select a designated entry point or "navigation node" (pnavp_{nav}pnav​) which serves as the starting point for all searches.
  3. Edge Selection: For each node ppp in the dataset, find its approximate nearest neighbors. Instead of just connecting ppp to its absolute closest neighbors, NSG applies a selection strategy. It iteratively builds the neighborhood set for ppp by adding candidate neighbors pcp_cpc​ only if the path from the navigation node pnavp_{nav}pnav​ through pcp_cpc​ to ppp is potentially shorter or offers a better angle than paths through existing neighbors. This encourages connections that facilitate efficient navigation from the entry point. The goal is to connect each node to a set of neighbors that are not only close but also cover different directions in the embedding space relative to the node.
  4. Refinement: The graph might undergo refinement steps to ensure connectivity and potentially prune redundant edges.

Search Process: Searching in NSG typically follows a greedy search strategy, similar in principle to HNSW's layer 0 search:

  1. Start at the predefined navigation node pnavp_{nav}pnav​.
  2. Maintain a candidate list (e.g., a priority queue) initialized with the navigation node, ordered by distance to the query vector qqq.
  3. Iteratively explore the neighbors of the closest unvisited candidate node pcurrentp_{current}pcurrent​ in the list.
  4. For each neighbor pneighborp_{neighbor}pneighbor​, calculate its distance d(q,pneighbor)d(q, p_{neighbor})d(q,pneighbor​). If pneighborp_{neighbor}pneighbor​ has not been visited, add it to the candidate list.
  5. Continue until a stopping criterion is met (e.g., no closer candidates found, budget exhausted).

A simplified representation of the desired "spreading" property compared to a basic k-NN graph:

A basic k-NN graph might connect a point P primarily to its nearest, potentially clustered neighbors (N1, N2, N3). NSG aims to select neighbors (like N1, N2, N3) that provide better directional coverage, facilitating more efficient long-range navigation within the graph.

Trade-offs: NSG can sometimes achieve high recall with relatively compact graphs compared to HNSW, potentially leading to lower memory usage. However, the construction process, especially the edge selection heuristic, requires careful tuning. The reliance on a single or few navigation nodes can sometimes create bottlenecks, although variations exist.

Vamana Algorithm

Vamana is another influential graph-based ANN algorithm, notably used as the core indexing technique in the DiskANN system, which is optimized for handling massive datasets that may not fit entirely in RAM. Vamana focuses explicitly on building a graph that is provably efficient for greedy search routing.

Graph Construction: Vamana graph construction is an iterative optimization process:

  1. Initialization: Start with a random graph where each node has a fixed out-degree (number of outgoing edges).
  2. Iterative Optimization: The core of Vamana involves multiple iterations where the graph is refined. In each iteration:
    • Greedy Search Simulation: For each node ppp, perform a greedy search starting from a random node (or set of nodes) to find the approximate nearest neighbors of ppp using the current graph structure.
    • Neighbor Pruning/Addition: Update the neighborhood N(p)N(p)N(p) of node ppp. The goal is to keep neighbors that are helpful for routing searches towards ppp and potentially add new neighbors discovered during the simulated searches that improve routing efficiency or recall. A typical objective is to maximize recall while adhering to a maximum out-degree constraint for each node. This often involves a heuristic (like the RobustPrune method in DiskANN) that evaluates both the distance of a neighbor and its angular diversity relative to other neighbors.
  3. Termination: Repeat the optimization iterations until the graph structure stabilizes or a maximum number of iterations is reached.

The main idea is that the graph construction actively optimizes the graph's structure for the greedy search algorithm that will be used at query time.

Search Process: The search process in Vamana is typically a standard greedy search, potentially enhanced with techniques like beam search:

  1. Start at one or more designated entry points (often randomly selected or strategically chosen).
  2. Maintain a candidate list (priority queue) ordered by distance to the query qqq.
  3. Iteratively explore the neighbors of the best candidates, adding unvisited neighbors to the queue.
  4. Continue until a stopping condition is met.

Because Vamana (especially in DiskANN) is often used with disk-based storage, the search implementation might include optimizations to minimize disk I/O, such as reading larger chunks of neighbor lists from disk.

Trade-offs: Vamana aims for high recall and efficient greedy search performance, often achieving state-of-the-art results, particularly on very large datasets. Its construction process directly optimizes for the search algorithm. However, the iterative construction can be computationally expensive compared to single-pass methods like basic HNSW construction. Its design principles are particularly well-suited for scenarios involving disk storage, where minimizing random access is important.

Choosing Between Graph Methods

While HNSW, NSG, and Vamana all rely on proximity graphs, their construction heuristics differ:

  • HNSW: Uses a multi-layer hierarchy to separate long-range and short-range links, enabling efficient zoom-in during search. Construction involves heuristic neighbor selection at each layer.
  • NSG: Focuses on selecting diverse "spreading" neighbors around a central navigation point to guide greedy search effectively.
  • Vamana: Iteratively optimizes the graph structure explicitly to improve the performance of the greedy search algorithm itself, often targeting high recall under degree constraints.

The choice among them depends on the specific application constraints:

  • Build Time: HNSW construction can be faster than Vamana's iterative optimization, while NSG's build time depends heavily on the specific heuristics used.
  • Memory Usage: Graph density (average degree) significantly impacts memory. NSG and Vamana might offer competitive memory footprints for high recall compared to HNSW, but this varies greatly with tuning.
  • Search Speed vs. Recall: All methods offer tunable trade-offs. Vamana's optimization often targets very high recall. HNSW's layers provide tunable accuracy/speed. NSG performance depends on the quality of the "spreading" achieved.
  • Dataset Size/Hardware: Vamana/DiskANN principles are strong contenders for massive, disk-resident datasets. HNSW and NSG are widely used for in-memory scenarios.

Understanding these alternative graph-based approaches highlights the rich design space for ANN algorithms. While HNSW is a frequent default choice, evaluating methods like NSG or examining the optimization principles of Vamana can lead to better performance or efficiency depending on your specific vector search requirements. Research continues to produce new graph construction techniques and hybrid methods, making familiarity with these foundational alternatives valuable.

  • DiskANN: Fast Accurate Billion-point Nearest Neighbor Search on a Single Node, Suhas Jayaram, Ravishankar Krishnaswamy, Vasileios Kandylas, Harsha Vardhan Simhadri, Rohan Karunakaran, Sudipta Sengupta and Vivek Narasayya, 2019 Advances in Neural Information Processing Systems 32 (NeurIPS 2019), Vol. 32 (NeurIPS) - Presents DiskANN, which uses Vamana as its core indexing mechanism, for fast and accurate billion-point nearest neighbor search optimized for large datasets.
  • Vamana: An Efficient Graph Based Nearest Neighbor Algorithm, Jie Sun, Xiang Li, 2019 Proceedings of the 2019 IEEE International Conference on Data Mining (ICDM) (IEEE) DOI: 10.1109/ICDM.2019.00122 - Describes the Vamana algorithm, an efficient graph-based approach for nearest neighbor search, outlining its construction and search principles.

© 2026 ApX Machine Learning