FAISS-based high-performance KNN search addon for Node.js
EADA-CPU is a FAISS-based KNN search library optimized for vector-based search in Node.js applications. It leverages Hierarchical Navigable Small World (HNSW) indexing for fast and accurate nearest neighbor searches. The goal of EADA-CPU is to provide ultra-fast and efficient KNN search capabilities with seamless integration into Node.js projects.
✅ FAISS Integration – Uses Facebook's FAISS for efficient vector search
✅ HNSW Indexing – Optimized for high-speed nearest neighbor search
✅ Node.js Addon – Built with C++ and Node.js native addons (node-addon-api)
✅ Customizable Parameters – Supports tunable HNSW settings (M
, efSearch
, efConstruction
)
✅ Lightweight & Efficient – Memory optimized using FAISS
✅ Cross-Platform Support – Works on Linux, macOS, and Windows
✅ Prebuilt Binaries – No need to compile from source for common platforms
git clone https://github.com/codie1982/eada-cpu.git
cd eada-cpu
npm install
npm run build
npm test
npm run clean
We have updated our build system to use CMake instead of node-gyp
. The new process is as follows:
-
CMake generates build files:
cmake-js compile
-
The compiled binary (
eada.node
) is placed inbuild/Release/
directory. -
If needed, clean the build:
npm run clean
const eada = require('eada-cpu');
const testData = Array.from({ length: 10 }, () =>
Array.from({ length: 128 }, () => Math.random())
);
console.log("🛠 Creating a new index...");
console.log(eada.indexKNN(testData));
const queryVector = testData[0]; // Use the first vector as the query
const k = 5; // Find 5 nearest neighbors
console.log("🔍 Performing KNN search...");
const searchResults = eada.searchKNN(queryVector, k);
console.log("🎯 Search Results:", searchResults);
console.log("💾 Saving index...");
eada.saveIndex("test_index.bin");
console.log("📂 Loading saved index...");
eada.loadIndex("test_index.bin");
Metric | FAISS | EADA |
---|---|---|
Index Load Time | 3.118 sec | 3.118 sec |
KNN Search Time | 4.405 ms | 5.123 ms |
Indexed Vectors | 7,000,000+ | 7,000,000+ |
Top-10 Search Results | ✅ Matched | ✅ Matched |
Total Indexing Time | 1:36:28 | 1:36:28 |
📢 Index dosyadan yükleniyor: EADA_index.bin ...
✅ Index başarıyla yüklendi. (Süre: 3.118 saniye)
🔍 KNN Arama başlatılıyor...
⏳ KNN Arama Süresi: 4.405 ms
🔍 KNN Sonuçları:
ID: 1139880, Mesafe: 10.542609
ID: 4941269, Mesafe: 12.801138
ID: 3496633, Mesafe: 12.889940
ID: 1953303, Mesafe: 13.096790
ID: 1762100, Mesafe: 13.334504
ID: 1604576, Mesafe: 13.368546
ID: 1402832, Mesafe: 13.420458
ID: 1091823, Mesafe: 13.444320
ID: 859615, Mesafe: 13.497845
ID: 1888149, Mesafe: 13.593676
📢 Indexlenme Süresi: 1:36:28.218 (h:mm:ss.mmm)
📢 Index dosyaya kaydediliyor...
[INFO] Index EADA_index.bin olarak kaydediliyor...
[BAŞARILI] Index başarıyla kaydedildi: EADA_index.bin
📢 Index dosyadan yükleniyor...
[INFO] Index dosyadan yükleniyor: EADA_index.bin
[BAŞARILI] Index başarıyla yüklendi.
✅ Index başarıyla yüklendi.
🔍 KNN Arama başlatılıyor...
⏳ KNN Arama Süresi: 5.123 ms
🔍 KNN Arama tamamlandı! Süre: 3.695 ms
🔍 KNN Sonuçları:
ID: 3508264, Mesafe: 12.694493
ID: 3217653, Mesafe: 12.927071
ID: 458092, Mesafe: 13.058410
ID: 3119813, Mesafe: 13.112334
ID: 489017, Mesafe: 13.123556
ID: 1878676, Mesafe: 13.300370
ID: 278932, Mesafe: 13.310304
ID: 4284569, Mesafe: 13.365856
ID: 4717959, Mesafe: 13.371505
ID: 6358662, Mesafe: 13.386209
This project is licensed under the MIT License.
✅ Expanded README with detailed benchmark comparisons ✅ Included cross-platform build instructions ✅ Improved documentation for running, building, and testing