Nearest Neighbor Search with Neighborhood Graph and Tree for High-dimensional Data
C++
1,374
264 commits
updated Oct 8, 2026
Neighborhood Graph and Tree for Indexing High-dimensional Data
Home / Installation / Command / License / Publications / 日本語
NGT provides commands and a library for performing high-speed approximate nearest neighbor searches against a large volume of data in high-dimensional vector spaces (several tens to several thousand dimensions).
This repository provides the following methods.
Note: Since QG and QBG require BLAS and LAPACK libraries, if you use only NGT (Graph and tree-based method) without the additional libraries like V1, you can disable QG and QBG with this option.
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ cmake -DNGT_QBG_DISABLED=ON ..
$ make
$ make install
$ ldconfig /usr/local/lib
$ yum install blas-devel lapack-devel
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install
$ ldconfig /usr/local/lib
$ apt install libblas-dev liblapack-dev
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install
$ ldconfig /usr/local/lib
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install cmake
$ brew install libomp
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ export OpenMP_ROOT=$(brew --prefix)/opt/libomp
$ cmake ..
$ make
$ make install
Windows support currently targets MinGW-w64 GCC (via MSYS2 / UCRT64). Native Microsoft Visual C++ (MSVC) is not currently supported and is planned as a future enhancement. -DNGT_QBG_DISABLED=ON is required. The standard in-memory index creation and search workflows are supported. Windows builds currently use static linking for the CLI; DLL export annotations and shared memory (memory-mapped file) allocators are not included yet.
To set up the build environment and build using MSYS2 (UCRT64 environment):
$ pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-libgomp mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja
$ cd NGT
$ mkdir build
$ cd build
$ cmake -DNGT_QBG_DISABLED=ON -G Ninja ..
$ ninja -j 2
[!NOTE] Compiling with Link-Time Optimization (LTO) and template instantiations is memory-intensive. Using
ninja -j 2(or limiting parallel jobs) avoids compiler out-of-memory errors on machines with less than 16 GB of RAM.
$ brew install ngt
The following build parameters are available
The index can be placed in shared memory with memory mapped files. Using shared memory can reduce the amount of memory needed when multiple processes are using the same index. In addition, it can not only handle an index with a large number of objects that cannot be loaded into memory, but also reduce time to open it. Since changes become necessary at build time, please add the following parameter when executing "cmake" in order to use shared memory.
$ cmake -DNGT_SHARED_MEMORY_ALLOCATOR=ON ..
Note: Since there is no lock function, the index should be used only for reference when multiple processes are using the same index.
When you insert more than about 5 million objects for the graph-based method, please add the following parameter to improve the search time.
$ cmake -DNGT_LARGE_DATASET=ON ..
QG and QBG require BLAS and LAPACK libraries. If you would not like to install these libraries and do not use QG and QBG, you can disable QG and QBG.
$ cmake -DNGT_QBG_DISABLED=ON ..
For QG, it is recommended to disable rotation of the vector space and residual vectors to improve performance as follows.
$ cmake -DNGTQG_NO_ROTATION=ON -DNGTQG_ZERO_GLOBAL=ON ..
The following results are for NGT v2.8.0 and were measured on Sakura Cloud, provided by SAKURA internet Inc., using an Intel(R) Xeon(R) Gold 6230R.
Copyright (C) 2015 Yahoo Japan Corporation
Copyright (C) 2026 SAKURA internet Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
The holders of patents covering technologies used in this software will not assert those patent rights against users of this software, provided that the software is used in compliance with the Apache License, Version 2.0.
Please refer to CONTRIBUTING.md before submitting a pull request.
6,595 followers · starred May 2026
148 followers · starred May 2021
114 followers · starred Nov 2021
28 followers · starred Mar 2023
Nearest Neighbor Search with Neighborhood Graph and Tree for High-dimensional Data
C++
1,374
264 commits
updated Oct 8, 2026
Neighborhood Graph and Tree for Indexing High-dimensional Data
Home / Installation / Command / License / Publications / 日本語
NGT provides commands and a library for performing high-speed approximate nearest neighbor searches against a large volume of data in high-dimensional vector spaces (several tens to several thousand dimensions).
This repository provides the following methods.
Note: Since QG and QBG require BLAS and LAPACK libraries, if you use only NGT (Graph and tree-based method) without the additional libraries like V1, you can disable QG and QBG with this option.
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ cmake -DNGT_QBG_DISABLED=ON ..
$ make
$ make install
$ ldconfig /usr/local/lib
$ yum install blas-devel lapack-devel
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install
$ ldconfig /usr/local/lib
$ apt install libblas-dev liblapack-dev
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ cmake ..
$ make
$ make install
$ ldconfig /usr/local/lib
$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew install cmake
$ brew install libomp
$ unzip NGT-x.x.x.zip
$ cd NGT-x.x.x
$ mkdir build
$ cd build
$ export OpenMP_ROOT=$(brew --prefix)/opt/libomp
$ cmake ..
$ make
$ make install
Windows support currently targets MinGW-w64 GCC (via MSYS2 / UCRT64). Native Microsoft Visual C++ (MSVC) is not currently supported and is planned as a future enhancement. -DNGT_QBG_DISABLED=ON is required. The standard in-memory index creation and search workflows are supported. Windows builds currently use static linking for the CLI; DLL export annotations and shared memory (memory-mapped file) allocators are not included yet.
To set up the build environment and build using MSYS2 (UCRT64 environment):
$ pacman -S mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-libgomp mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-ninja
$ cd NGT
$ mkdir build
$ cd build
$ cmake -DNGT_QBG_DISABLED=ON -G Ninja ..
$ ninja -j 2
[!NOTE] Compiling with Link-Time Optimization (LTO) and template instantiations is memory-intensive. Using
ninja -j 2(or limiting parallel jobs) avoids compiler out-of-memory errors on machines with less than 16 GB of RAM.
$ brew install ngt
The following build parameters are available
The index can be placed in shared memory with memory mapped files. Using shared memory can reduce the amount of memory needed when multiple processes are using the same index. In addition, it can not only handle an index with a large number of objects that cannot be loaded into memory, but also reduce time to open it. Since changes become necessary at build time, please add the following parameter when executing "cmake" in order to use shared memory.
$ cmake -DNGT_SHARED_MEMORY_ALLOCATOR=ON ..
Note: Since there is no lock function, the index should be used only for reference when multiple processes are using the same index.
When you insert more than about 5 million objects for the graph-based method, please add the following parameter to improve the search time.
$ cmake -DNGT_LARGE_DATASET=ON ..
QG and QBG require BLAS and LAPACK libraries. If you would not like to install these libraries and do not use QG and QBG, you can disable QG and QBG.
$ cmake -DNGT_QBG_DISABLED=ON ..
For QG, it is recommended to disable rotation of the vector space and residual vectors to improve performance as follows.
$ cmake -DNGTQG_NO_ROTATION=ON -DNGTQG_ZERO_GLOBAL=ON ..
The following results are for NGT v2.8.0 and were measured on Sakura Cloud, provided by SAKURA internet Inc., using an Intel(R) Xeon(R) Gold 6230R.
Copyright (C) 2015 Yahoo Japan Corporation
Copyright (C) 2026 SAKURA internet Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this software except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
The holders of patents covering technologies used in this software will not assert those patent rights against users of this software, provided that the software is used in compliance with the Apache License, Version 2.0.
Please refer to CONTRIBUTING.md before submitting a pull request.
6,595 followers · starred May 2026
148 followers · starred May 2021
114 followers · starred Nov 2021
28 followers · starred Mar 2023