Dual-Branch HNSW++ for Efficient ANN Search
- The paper introduces Dual-Branch HNSW++ that enhances traditional HNSW through a dual-branch graph, LID-driven node insertion, and skip-bridge techniques to reduce local optima.
- It demonstrates significant performance gains with up to +30% recall improvement and 18-20% build time reduction, while maintaining comparable query speed across varied datasets.
- The methodology leverages parallel branch searches and effective merging strategies, ensuring robust connectivity and efficient handling of high-dimensional data.
The Dual-Branch HNSW++ algorithm is an enhanced approach for Approximate Nearest Neighbor (ANN) search that addresses key limitations of the original Hierarchical Navigable Small World (HNSW) method. By integrating a dual-branch architecture, Local Intrinsic Dimensionality (LID)–driven node insertion, and a skip-bridge mechanism, Dual-Branch HNSW++ improves accuracy, connectivity, and construction efficiency without compromising query speed. Extensive benchmarking demonstrates consistent gains in recall, construction time, and high-dimensional robustness across both computer vision and natural language processing datasets (Nguyen et al., 23 Jan 2025).
1. Limitations of Traditional HNSW and Rationale for HNSW++
The canonical HNSW algorithm constructs multi-layer small-world graphs by greedily linking each new data point to the closest neighbors found at each layer, descending from sparser higher layers to a dense base layer. This local search is prone to suboptimal neighbor selection, leading to:
- Local Optima: Search trajectories may become trapped in clusters (basins of attraction) disconnected from true nearest neighbors, reducing recall.
- Logarithmic Complexity Degradation: In high-dimensional settings, theoretical scaling is undermined by exhaustive, layer-by-layer traversals, yielding a large constant factor in computational cost.
Dual-Branch HNSW++ introduces key modifications to reduce local-optimum risk, improve outlier and inter-cluster connectivity, and reduce per-query and per-insertion search space (Nguyen et al., 23 Jan 2025).
2. Dual-Branch Graph Structure
Dual-Branch HNSW++ partitions the dataset (size ) into two interleaved branches, denoted branch 0 and branch 1. This assignment is alternated during the layer-assignment process. Each branch forms an independent multi-layer HNSW graph, with node layers indexed .
During querying, greedy search is conducted independently in both branches. Each query is initialized at the top layer entry point in both branch 0 and branch 1. The two searches proceed in parallel, descending layers until reaching the base (layer 0), or skipping directly to layer 0 if a suitable skip-bridge is traversed (see Section 4). At layer 0, the neighbor sets and from both branches are merged (excluding duplicates) to yield the final top- result.
Dual-Branch Search (Abridged Pseudocode):
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function DUAL_BRANCH_SEARCH(hnsw, q, k):
ep0 ← highest‐level entry in branch_0
ep1 ← highest‐level entry in branch_1
W0, W1 ← {ep0}, {ep1}
L0, L1 ← top_layer(branch_0), top_layer(branch_1)
while L0 ≥ 0 or L1 ≥ 0:
if L0 ≥ 0:
(W0, skip0) ← SEARCH_LAYER(q, W0, L0, lid_threshold)
L0 ← 0 if skip0 else (L0 − 1)
if L1 ≥ 0:
(W1, skip1) ← SEARCH_LAYER(q, W1, L1, lid_threshold)
L1 ← 0 if skip1 else (L1 − 1)
return MERGE(W0, W1, k) |
3. LID-Driven Layer Assignment and Insertion
Local Intrinsic Dimensionality (LID) quantifies the local space’s effective dimensionality around each data point. For point , LID is estimated as
where is the th-nearest neighbor of .
The algorithm proceeds as follows:
- Compute LID for all nodes via -NN.
- Normalize LID to :
- Sort nodes in descending normalized LID order. Assignment alternates between the two branches.
- Layer assignment samples levels with probability favoring higher layers for higher LID points:
High-LID points are thus inserted as long-range connectors (“hubs”), promoting connectivity and mitigating cluster disconnections.
4. Skip Bridges: Bridge-Building for Efficient Layer Traversal
The skip-bridge or bridge-building technique enables the search process to bypass intermediate layers when certain geometric and structural conditions are met. Specifically, at layer , the search descends directly to layer $0$ (the base) if
where is a hyperparameter LID threshold and is a distance threshold. If both are satisfied for the current entry point ep and query , the search jumps immediately to the base layer. This reduces unnecessary traversals through sparse or redundant layers, shaving overhead introduced by dual-branching and accelerating queries in practice.
5. Computational Complexity
The dual-branch design influences all dimensions of complexity:
- Search Complexity: Each branch contains nodes. Standard HNSW query cost is . Skip bridges reduce the expected number of layer traversals to , with the probability of skip conditions being met. Merging two small sets at layer 0 is . Overall, query complexity remains but with a reduced constant.
- Construction Complexity: LID computation for all nodes is due to -NN. Each insertion is per branch, yielding total build time . The per-insertion search space is halved.
- Space Complexity: The two-branch architecture retains total memory complexity (with each node having up to links per layer), identical to original HNSW.
6. Empirical Evaluation and Component Analysis
Experiments covered six datasets: three from computer vision (SIFT $128$-d, GIST $960$-d, DEEP $96$-d), one from NLP (GloVe $100$-d), and two synthetic. Each dataset included $10,000$ points for index construction and $1,000$ queries, measured by recall@10, build time, and query latency using -distance.
Key results demonstrate that Dual-Branch HNSW++ provides:
| Dataset | Recall@10 Improvement | Build Time Reduction |
|---|---|---|
| SIFT (CV) | +28% | –18% |
| GIST (CV) | +30% | –20% |
| DEEP (CV) | +25% | –17% |
| GLOVE (NLP) | +18% | –12% |
- Query latency is unchanged () or slightly reduced.
- No empirical trade-off observed between recall and speed.
Ablation studies indicate:
- LID-based insertion yields the largest single-factor gain in recall (+12–14 percentage points).
- Dual-branching adds a further gain of +8–10 points.
- Skip bridges reduce query time by ~10–15% without recall degradation.
7. Comparative Performance with State-of-the-Art ANN Methods
In benchmarking (for example, on GIST 960-dimensional), Dual-Branch HNSW++ shows the following results:
| Method | Recall@10 | Query QPS | Build Time (s) |
|---|---|---|---|
| FAISS IVFPQ | 0.65 | 5k | 18 |
| Annoy | 0.58 | 7k | 22 |
| NMSLIB (HNSW) | 0.78 | 12k | 15 |
| HNSW++ | 0.92 | 12.4k | 12 |
Dual-Branch HNSW++ thus outperforms both graph-based (NMSLIB) and tree/quantization-based (FAISS, Annoy) methods in recall, accelerates build time, and maintains or exceeds query throughput. Observed gains are attributed to improved graph connectivity, rapid outlier capture, and efficient traversal enabled by LID-driven hubs and bridges. There are no observed trade-offs; recall increases as build time decreases, with query speed unaltered (Nguyen et al., 23 Jan 2025).