elips/docs
Chapter XII · algorithms

IndexHNSW — HNSW in ELIPS

ANN is mostly graph traversal in disguise. HNSW makes the disguise efficient.

layer 2 · sparse hubsahlayer 1 · regionalacehlayer 0 · full populationdescend until ef_search convergesgreedy search → climb down → refine
Top layer: long-range hubs. Bottom layer: every point. Search descends one layer at a time.

Parameters that matter (docs/cpp/api-reference/config.md)

  • max_connections (M) — outgoing edges per node per layer; default 16
  • ef_construction — candidate-list size when inserting; default 200
  • ef_search — candidate-list size at query time; default 50

Increase ef_search to trade latency for recall at query time without rebuilding. Increase ef_construction or max_connections only at build time — and only if your recall plateau is below target.

The FAISS-style native index API

Below the collection layer, ELIPS exposes a FAISS-shaped index family: IndexFlat, IndexIVFFlat, IndexIVFPQ, IndexIVFScalarQuantizer, IndexHNSW, plus index_factory. Metric strings are FAISS-style ('l2' for euclidean).

python
import numpy as np, elips
xb = np.random.rand(100000, 128).astype("float32")
xq = np.random.rand(1000, 128).astype("float32")

index = elips.IndexHNSW(128, 32, "l2")   # d, M, metric
index.add(xb)
D, I = index.search(xq, 10)
print(index.ntotal, index.d, index.is_trained)

# or an IVF index via the factory, with a probe sweep:
ivf = elips.index_factory(128, "IVF316,Flat", "l2")
ivf.train(xb); ivf.add(xb); ivf.nprobe = 128
D, I = ivf.search(xq, 10)