Repolode
NGT-labs

NGT-labs/NGT

A C++ library and command-line tool for fast approximate nearest neighbor search over high-dimensional vectors, using graph and tree indexes.

Stars
1,376
Forks
134
Open issues
29
Last commit
23 hours ago

What is it?

NGT provides commands and a library for approximate nearest neighbor search over large collections of high-dimensional vectors, typically from tens to thousands of dimensions. It builds neighborhood graph and tree indexes so that similar objects can be found without comparing a query against every stored item.

The project offers several methods: a graph and tree-based index (NGT), a quantized graph method (QG), and a quantized blob graph method (QBG) intended for very large datasets. Supported distance functions include L1, L2, cosine, angular, Hamming, Jaccard, inner product, and hyperbolic (Poincare and Lorentz) distances. Vectors can be stored as 4-byte or 2-byte floats or as 1-byte unsigned integers, and indexes can be placed in memory-mapped shared memory.

NGT includes a CLI, a C++ API, and bindings for Python, Rust, Go, Ruby, PHP, and JavaScript. Objects can be added and removed after an index is built. Builds are supported on Linux, macOS, and Windows through MinGW-w64/MSYS2, with QG and QBG requiring BLAS and LAPACK.

Key features

  • 01Approximate nearest neighbor search using graph and tree indexes
  • 02Supports L1, L2, cosine, angular, Hamming, Jaccard, inner product and hyperbolic distances
  • 03Adding and removing objects after the index is built
  • 04Float32, float16 and uint8 data types, plus product and scalar quantization for graph indices
  • 05Shared memory (memory-mapped file) index option for large datasets
  • 06Bindings for Python, Rust, Go, Ruby, PHP and JavaScript

Use cases

  • Finding similar images, documents or embeddings by vector similarity in a custom search service
  • Serving nearest neighbor queries from multiple processes that share one index in memory
  • Running similarity search over billions of vectors with the QBG method
  • Prototyping vector search from the command line or Python before choosing a larger system

Quick start

  1. 1

    Install on macOS with Homebrew

    brew install ngt
  2. 2

    Download the source archive from the Releases page

  3. 3

    Configure the build on Linux without QG and QBG

    cmake -DNGT_QBG_DISABLED=ON ..

Things to know

  • Native Microsoft Visual C++ (MSVC) builds are not supported; Windows currently requires MinGW-w64 and disabling QBG.
  • QG and QBG require BLAS and LAPACK libraries and run only on Linux and macOS.

In collections

Topics

#approximate-nearest-neighbor-search#vector-search#knn#high-dimensional-data#c-plus-plus#indexing#k-nearest-neighbors#knn-search#nearest-neighbor-search#nearest-neighbors

FAQ

What is NGT?
A C++ library and command-line tool for fast approximate nearest neighbor search over high-dimensional vectors, using graph and tree indexes. NGT provides commands and a library for approximate nearest neighbor search over large collections of high-dimensional vectors, typically from tens to thousands of dimensions. It builds neighborhood graph and tree indexes so that similar objects can be found without comparing a query against every stored item.
Is NGT free to use? What license does it have?
NGT is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is NGT still maintained?
Actively maintained. The last commit to NGT was on Nov 6, 2026.
What can I use NGT for?
Finding similar images, documents or embeddings by vector similarity in a custom search service Serving nearest neighbor queries from multiple processes that share one index in memory Running similarity search over billions of vectors with the QBG method Prototyping vector search from the command line or Python before choosing a larger system
How do I install NGT?
Install on macOS with Homebrew: brew install ngt Download the source archive from the Releases page Configure the build on Linux without QG and QBG: cmake -DNGT_QBG_DISABLED=ON ..
Where can I get NGT?
The source code and installation instructions are on GitHub: https://github.com/NGT-labs/NGT

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects