{"repo":"coder/hnsw","free":true,"listed":false,"github":"https://github.com/coder/hnsw","clone":"git clone https://github.com/coder/hnsw.git","description":"In-memory vector index for Go","language":"Go","stars":233,"topics":["ai","faiss","go","golang","vector-database"],"license":"CC0-1.0","category":"databases-storage","readme_excerpt":"hnsw Package hnsw implements Hierarchical Navigable Small World graphs in Go. You can read up about how they work here. In essence, they allow for fast approximate nearest neighbor searches with high-dimensional vector data. This package can be thought of as an in-memory alternative to your favorite vector database (e.g. Pinecone, Weaviate). It implements just the essential operations: Operation Complexity Description --------- --------------------- -------------------------------------------- Insert $O(log(n))$ Insert a vector into the graph Delete $O(M^2 \\cdot log(n))$ Delete a vector from the graph Search $O(log(n))$ Search for the nearest neighbors of a vector Lookup $O(1)$ Retrieve a vector by ID [!NOTE] Complexities are approximate where $n$ is the number of vectors in the graph and $M$ is the maximum number of neighbors each node can have. This paper is a good resource for understanding the effect of the various construction parameters. Usage Persistence While all graph operations are in-memory, hnsw provides facilities for loading/saving from persistent storage. For an io.Reader / io.Writer interface, use Graph.Export and Graph.Import . If you're using a single file as the backend, hnsw provides a convenient SavedGraph type instead: See more: Export Import SavedGraph We use a fast binary encoding for the graph, so you can expect to save/load nearly at disk speed. On my M3 Macbook I get these benchmark results: when saving/loading a graph of 100 vectors with 256 dimens","default_branch":null,"files":null,"tree":[],"storefront":"/r/coder","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/coder/hnsw/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}