Profile

Settings

Loading…

← Papers

Help

FAQ

Which features require signing in?

You can read the commentary, paper info, Model Structure and related papers of public papers without signing in. Sign in to manage your account or contact us about your inquiries.

Can I upload a PDF file?

Upload papers with an arXiv or DOI link; the commentary is public to everyone. Papers whose source and terms of use can't be verified, so the commentary can't be made public, can't be uploaded. Uploading PDF files and keeping papers private are for subscribers only, and a paper uploaded as a file is saved as private only. Searching for official info by title runs only when you press the button.

Are the figures and AI commentary accurate?

Figures come only from the original paper, and only those whose terms of use are verified are shown. The commentary is written by AI and may be wrong. Check important claims, numbers and figure context against the evidence in the original paper.

I want to report a copyright issue.

Terms of use and the source of the original paper are on the Paper info tab. If there's a problem, choose "Paper content, figures and copyright" under Contact us and send the paper link, the part in question, and evidence that you hold the rights. Receiving your report doesn't confirm any rights or remove anything right away. You can see the result of the review under My inquiries.

I forgot my password.

If you signed up with email, use Forgot password in the sign-in window to reset it with your verified email. If you signed up with Google, Naver or Kakao, change your password with that service.

What should I include in an inquiry?

Tell us which screen you were on and what you were doing when the problem happened, along with the paper link. Don't include personal information such as passwords, API keys, verification codes or phone numbers. Inquiries and replies are stored in Refivu and you can see them under My inquiries.

How do I delete my account?

In Settings, under My account, press Delete account. Review what will be deleted and complete identity verification to delete your account. For other requests, choose "Account" under Contact us.

Paper commentary

Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs

Hierarchical NSW graphs speed up approximate nearest neighbor search on clustered data

  • Problem Proximity graph search slows sharply on low-dimensional and clustered data. Greedy routing needs a power-law number of steps as the dataset grows.
  • Method Hierarchical NSW stacks proximity graphs over nested subsets of the data. Each element's top layer is drawn from a decaying distribution, and search starts at the top layer and moves down.
  • Results Hierarchical NSW beats NSW and other open-source vector methods on the ann-benchmarks tests. On 4-dimensional random data it needs far fewer distance computations than NSW.

Why proximity graph search breaks down

Approximate nearest neighbor search gives up a small amount of accuracy for speed, and recall measures how many of the true K nearest neighbors a search returns. Proximity graph methods work well on high-dimensional data, since a search walks through a graph of links between stored elements instead of scanning them.

A k-NN graph links each element to its closest neighbors, which only approximates the Delaunay graph, the structure that makes greedy routing reach the true nearest neighbor. Two weaknesses follow: the number of routing steps grows as a power law with dataset size, and the graph can lose global connectivity, which gives poor results on clustered data.

What NSW gains and where it stops

NSW builds its graph by inserting elements in random order and linking each new element bidirectionally to its M closest previously inserted elements, found by a greedy search from several random entry points. Links to the early elements become long-range bridges between hubs, which keeps the graph connected and gives polylogarithmic routing.

Routing has a zoom-out phase, where the node degree is still low and the search can get trapped far from the query, and a zoom-in phase; starting from a high-degree hub avoids the zoom-out phase.

Separating links into layers by length scale

Each element receives a maximum layer l, and an element belongs to every layer up to l. Within each layer, a proximity graph is built over the elements present there, so the upper layers hold longer links and the lower layers hold shorter ones. Level l is sampled as \(l = \lfloor -\ln(\mathrm{unif}(0..1)) \cdot mL \rfloor\), so the probability of a higher level decays exponentially, and the expected number of layers grows only logarithmically with the number of elements.

A query begins in the top layer, where only the longest links exist, and moves greedily until it reaches a local minimum. That local minimum becomes the entry point of the next layer down, so each layer only needs a fixed, small number of links per element, regardless of the dataset size.

If the links of all layers are merged, the structure resembles an NSW graph, with the level playing the role of the node degree. Level randomization replaces the shuffling of elements that NSW needs, so the index can grow incrementally even when the data distribution changes over time. The design is close to a one-dimensional probabilistic skip list, except that the linked lists are replaced by proximity graphs.

How insertion and query run layer by layer

Insertion first runs a greedy search with ef=1 on each layer above the new element's level, which keeps the entry point for the lower layers. On each layer from min(L, l) down to 0, the algorithm runs SEARCH-LAYER with efConstruction to collect candidates, selects neighbors, adds bidirectional links, and shrinks the neighbor list of any node that exceeds Mmax, or Mmax0 on the ground layer.

SEARCH-LAYER keeps a candidate queue and a dynamic list W of the ef nearest elements found so far, initialized with the entry points. It stops when the nearest unexpanded candidate is farther from the query than the furthest element in W, so candidates that cannot improve the list are discarded. The authors prefer this stopping rule over a fixed limit on distance computations, because it avoids keeping far candidates in the structure.

A K-NN query descends from the top layer with ef=1 greedy steps, moving to the nearest element found on each layer. On the ground layer it runs SEARCH-LAYER with the chosen ef and returns the K nearest elements found. Compared with NSW, the entry point is fixed and the search quality is set by ef instead of the number of multi-searches.

Choosing diverse neighbors

The simple rule takes the M nearest candidates, which can all sit in one cluster.

When there are enough candidates, this rule yields the relative neighborhood graph as a subgraph of the Delaunay graph, which keeps the clusters connected even when the data is highly clustered. The heuristic adds extra edges beyond that subgraph, so the number of connections per element can be controlled for search performance. For one-dimensional data the same rule gives the exact Delaunay subgraph, which coincides with the relative neighborhood graph.

Two options refine the heuristic: extendCandidates adds the neighbors of the candidates to the candidate set, which the authors describe as useful only for extremely clustered data, and keepPrunedConnections refills the list with discarded candidates up to a fixed count.

Parameter choices and their measured effects

Setting mL to zero and Mmax0 to M gives directed k-NN graphs, and setting mL to zero with Mmax0 unbounded gives NSW graphs. Lower mL reduces the overlap between layers but raises the number of hops per layer, so an optimum exists; the authors choose mL = 1/ln(M), which corresponds to a skip list parameter p = 1/M. On 10M random vectors with d=4, the authors' simulations on an Intel Core i7 5930K CPU support this choice, and on 100k random vectors with d=1024 raising mL from zero gives a measurable speedup without penalty.

Mmax0 equal to M gives a strong penalty at high recall, and the authors suggest 2 times M, since larger values degrade performance and use more memory on 5M SIFT on an Intel Core i5 2400 CPU. In every case the authors considered, the heuristic gives equal or higher search performance than the simple rule.

The authors recommend M between 5 and 48: smaller M is better at lower recall or lower dimensionality, while bigger M is better at high recall or high dimensionality. efConstruction should be large enough for the construction search to reach recall close to unity, and 0.95 is enough for most cases. With efConstruction=100 on a 4X Xeon E5-4650 v2 server, a usable index for 10M SIFT was built in about 3 minutes.

Why the cost should grow logarithmically

If the graph were an exact Delaunay graph, the search would reach the closest element on each layer in an expected number of steps bounded by a geometric sum, \(S = 1/(1-\exp(-mL))\), which does not depend on the dataset size. The bound rests on a fixed probability \(p = \exp(-mL)\) that the next node lies in the upper layer, and on the search never passing an element of a higher layer.

If the average degree of the Delaunay graph is capped by a constant C for a large dataset, the expected number of distance evaluations per layer is bounded by C times S. Since the expected maximum layer grows as O(log(N)), the overall search cost scales as O(log(N)), which the authors find consistent with simulations on low-dimensional data.

Construction time follows the same argument, so for relatively low-dimensional data it scales as O(N·log(N)).

Memory per stored element

The average connection memory per element is \((M_{max0} + mL \cdot M_{max}) \cdot \text{bytes\_per\_link}\), because the ground layer keeps Mmax0 links and every other layer keeps Mmax links. Storing connections as four-byte unsigned integers is enough for up to about four billion elements. For M values between 6 and 48, the graph needs about 60-450 bytes per object, excluding the stored data.

Vector benchmark against open-source methods

The ann-benchmarks testbed ran python bindings of each method for one thousand randomly extracted queries and reported recall against average time per search. The rivals were baseline NSW from nmslib, FLANN, Annoy, a VP-tree and FALCONN, and all tests were run single-threaded with the L2 distance, except GloVe, which used cosine similarity.

On SIFT, GloVe, DEEP and CoPhIR, Hierarchical NSW shows a large margin over the other vector methods in this benchmark. On the 30M random vectors with d=4, it is slightly faster than Annoy at high recall and clearly faster than the other methods. The authors compare against the best open-source Euclidean methods, so the result does not cover other families of methods.

Distance computations against NSW on random data

On 4-dimensional random hypercube data, measured on a Core i5 2400 CPU with 10-NN search, Hierarchical NSW needs much fewer distance computations than NSW, especially at high recall.

For 8-dimensional data at a fixed recall of 0.95 with 10-NN search, the authors report that the scaling of Hierarchical NSW is not worse than logarithmic. Hierarchical NSW also beats NSW at every tested dataset size, and the gap in absolute query time is larger because of the improved implementation.

Robustness in general spaces

The authors reran a subset of the tests from a previous comparison in general spaces, covering datasets where NSW or NNDescent had performed poorly, against VP-tree, NAPP and brute-force filtering. The datasets are Wiki-sparse, Wiki-8, Wiki-128, ImageNet and DNA, with distances such as sparse cosine, Jensen-Shannon divergence, SQFD and Levenshtein.

Hierarchical NSW improves on NSW and leads on every tested dataset. On Wiki-8, which has 8 dimensions and uses Jensen-Shannon divergence, the gain over NSW is almost three orders of magnitude, and it is measured in distance computations instead of CPU time.

Trade-off against Faiss on 200M SIFT

The baseline is Faiss, a product quantization library, run on a 200M subset of 1B SIFT on a 4X Xeon E5-4650 v2 server with 128Gb of RAM.

Table 3 lists Hierarchical NSW with M=16 and efConstruction set to 500 or 40, against two Faiss configurations, OPQ64 with IMI2x14 and PQ64, and OPQ32 with IMI2x14 and PQ32. Hierarchical NSW reached much higher accuracy and much faster search and index construction, but its peak memory was 64 Gb, against 30 Gb and 23.5 Gb for the Faiss configurations.

Peak memory was measured in separate runs after index construction, and the inset shows query time against dataset size, which the authors observe deviates from a pure logarithm, possibly because of the dimensionality.

Limitations

The complexity analysis assumes exact Delaunay graphs, while the neighbor heuristic produces an approximate graph with a fixed number of neighbors, so the analysis does not fully cover the implemented structure. The empirical support is limited to low-dimensional data, where the required ef saturates with dataset size for d=4, and the authors state that the resilience of the Delaunay approximation to higher dimensions still needs analytical evidence.

The search always starts from the top layer, so the basic NSW distribution technique cannot be used directly, and simple partitioning of the data across nodes scales poorly in throughput.

In the general-space tests, the implementation lacked the custom distance functions and special memory management used elsewhere, which led to some performance loss. The ann-benchmarks comparison ran in a single thread, and the Faiss comparison covers only the 200M SIFT subset with the stated configurations.

Paper info

Authors
Yu. A. Malkov, D. A. Yashunin
Venue
arXiv · Preprint
First published
2016-3-30
Added
2026-11-12
Updated
2018-8-14
Version
v4
arXiv
1603.09320
Category
cs.DS · cs.CV · cs.IR · cs.SI
Original paper terms
arXiv non-exclusive 1.0
What we show
Paper info and commentary

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

Quote from the paper

Yu. A. Malkov, D. A. Yashunin (2016). Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs. arXiv:1603.09320v4. https://arxiv.org/abs/1603.09320v4

BibTeX
@misc{malkov2016efficient,
  title = {{Efficient and robust approximate nearest neighbor search using Hierarchical Navigable Small World graphs}},
  author = {Yu. A. Malkov and D. A. Yashunin},
  year = {2016},
  eprint = {1603.09320},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1603.09320v4}
}

See related papersBrowse other papers

Paper preview
Account security

Connect Google account

If you connect a Google account, you can sign in with it too.

Refivu

Delete account

Refivu
Refivu

Sign up