Build a fresh in-memory HNSW from labeled vectors.
vectors must be L2-normalized — the cosine distance space treats
inputs as already-unit-length, so unnormalized inputs produce wrong
distances. The EmbedDb already L2-normalizes at insert time, so the
usual call path (loadAllVectors → buildHnsw) is safe by construction.
Throws if dim doesn't match any vector's length, if maxElements
is less than the input count, or if hnswlib-node failed to load.
Build a fresh in-memory HNSW from labeled vectors.
vectorsmust be L2-normalized — the cosine distance space treats inputs as already-unit-length, so unnormalized inputs produce wrong distances. TheEmbedDbalready L2-normalizes at insert time, so the usual call path (loadAllVectors → buildHnsw) is safe by construction.Throws if
dimdoesn't match any vector's length, ifmaxElementsis less than the input count, or ifhnswlib-nodefailed to load.