hnsw·demo

A Hierarchical Navigable Small World index written from scratch in Rust and compiled to WebAssembly. The graph is built in this tab over 25,000 English words — no server, no API, no precomputed answers — and every query reports the hops it took to get there.

source on GitHub →

Query nearest neighbours by cosine distance

try — the last one is not a word, and still finds neighbours
64
10
12
loading…

Results

# word cosine distance
Waiting for the index to build…

What the search cost

index scanned
nodes visited
hops
recall@k
query time

Recall is measured live against an exhaustive scan of all vectors, run right after the graph search. It is the fraction of the true nearest neighbours the graph actually found.

The descent distance to the query, in visit order

Each dot is one node the search evaluated. Time runs left to right, distance runs bottom to top. The sparse upper layers cover the distance in a handful of hops; layer 0 is the dense cloud at the end where the beam refines the answer.

Graph layer populations, and how much of each was touched