



A Go implementation of the HNSW approximate nearest neighbor search algorithm, enabling developers to embed efficient vector similarity search directly into Go services and custom vector database solutions.
Category: SDKs & Libraries
Technology: Go, Approximate Nearest Neighbor (ANN), Vector Search
Source: https://github.com/coder/hnsw
HNSW (Go) is a Go implementation of Hierarchical Navigable Small World (HNSW) graphs for fast approximate nearest neighbor (ANN) search over high-dimensional vectors. It can serve as an in-memory alternative to a vector database, suitable for embedding vector similarity search directly into Go applications and custom vector databases.
Graph.Ml) to trade off speed, recall, and memory usage, following the original HNSW paper.go get github.com/coder/hnsw@main
hnsw.NewGraph[IDType](), where the ID is generic (e.g., int).hnsw.MakeNode(id, []float32{...}).Graph.Add(...).Graph.Search(queryVector, k).Graph.Export(io.Writer) — write graph to an io.Writer.Graph.Import(io.Reader) — load graph from an io.Reader.Loading more......
LoadSavedGraph[T](path) to load or initialize a graph backed by a single file.SavedGraph.Save() to persist the current graph state to disk.M (maximum neighbors per node) for better search behavior at the cost of memory.Graph.M (M — maximum neighbors per node).Graph.Ml (mL — level generation parameter).Not applicable. HNSW (Go) is an open-source Go library; no pricing information is provided in the source content.