← AI GitHub

AI GitHub

hnswlib for an in-process nearest-neighbor index

Embed approximate nearest-neighbor search directly in an application or experiment.

Data and RetrievalPublished 2 min read

Key Takeaways

  • The library implements a navigable graph index and offers Python bindings.
  • Create the index with the expected dimension and metric.
  • Generate an exact neighbor list for a sample, then compare recall and latency across query settings.
  • The surrounding application owns metadata, persistence and concurrent update policy.

How it works

The library implements a navigable graph index and offers Python bindings. Construction settings influence memory and build time, while query settings control search effort.

What you need

Create the index with the expected dimension and metric. Preserve a mapping from internal IDs to source records outside the index so results can be interpreted after reload.

What to try first

Generate an exact neighbor list for a sample, then compare recall and latency across query settings. Save and reload the index as part of the same test.

Increase query effort across a range of values and plot recall against latency. Choose the operating point based on your own target, since no single setting is best for all data.

Where to look for failures

The surrounding application owns metadata, persistence and concurrent update policy. Pin the dimension and distance metric used for every vector.

Related Franklin pages

Decide whether search belongs in your existing database or in an index inside the process. Compare operational needs such as persistence, filtering and updates as well as nearest-neighbor speed.

For the role of the index in nearest-neighbor search, see Franklin’s glossary. Vector indexes

Project documentation

Try it for your workflow

Explore the project’s documentation for setup and usage, or save this page to a collection for later.

Read the project documentation ↗