Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
hnswlib-wasm
Advanced tools
This is a wasm version of hnswlib. Created by @ShravanSunder
Created with the help of library hnswlib-node. See his wonderful docs here, Thanks @yoshoku!
Note: This is still a beta!
hnswlib-wasm
provides Node.js bindings for Hnswlib
that implements approximate nearest-neghbor search based on
hierarchical navigable small world graphs. It will work in node.js and browser and is compiled with emscripten.
$ yarn add hnswlib-wasm
indexedDB
(in browser) and fs
(in node) and uses FS from emscripten to save and laod the index via the virtual file system.hnswlib-node
for more details by @yoshoku changelogGenerating search index:
import { HierarchicalNSW } from 'hnswlib-node';
const numDimensions = 8; // the length of data point vector that will be indexed.
const maxElements = 10; // the maximum number of data points.
// declaring and intializing index.
const index = new HierarchicalNSW('l2', numDimensions);
index.initIndex(maxElements);
// inserting data points to index.
for (let i = 0; i < maxElements; i++) {
const point = new Array(numDimensions);
for (let j = 0; j < numDimensions; j++) point[j] = Math.random();
index.addPoint(point, i);
}
// saving index.
index.writeIndexSync('foo.dat');
Searching nearest neighbors:
import { HierarchicalNSW } from 'hnswlib-node';
// loading index.
const index = new HierarchicalNSW('l2', 3);
index.readIndexSync('foo.dat');
// preparing query data points.
const numDimensions = 8;
const query = new Array(numDimensions);
for (let j = 0; j < numDimensions; j++) query[j] = Math.random();
// searching k-nearest neighbor data points.
const numNeighbors = 3;
const result = index.searchKnn(query, numNeighbors);
console.table(result);
hnswlib-wasm is available as open source under the terms of the Apache-2.0 License.
To build
yarn install
make rebuild
yarn build
To test
yarn test
Contact @ShravanSunder first!
FAQs
typescript and wasm bindings for Hnswlib
We found that hnswlib-wasm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.