hora-search / hora-wasm Goto Github PK
View Code? Open in Web Editor NEWwebassembly binding for Hora Approximate Nearest Neighbor Search Library
Home Page: https://horasearch.com
License: Apache License 2.0
webassembly binding for Hora Approximate Nearest Neighbor Search Library
Home Page: https://horasearch.com
License: Apache License 2.0
Line 15.
When I do:
npm i horajs
and then run the example:
import * as horajs from "horajs";
const demo = () => {
const dimension = 50;
var bf_idx = horajs.BruteForceIndexUsize.new(dimension);
// var hnsw_idx = horajs.HNSWIndexUsize.new(dimension, 1000000, 32, 64, 20, 500, 16, false);
for (var i = 0; i < 1000; i++) {
var feature = [];
for (var j = 0; j < dimension; j++) {
feature.push(Math.random());
}
bf_idx.add(feature, i); // add point
}
bf_idx.build("euclidean"); // build index
var feature = [];
for (var j = 0; j < dimension; j++) {
feature.push(Math.random());
}
console.log("bf result", bf_idx.search(feature, 10)); //bf result Uint32Array(10) [704, 113, 358, 835, 408, 379, 117, 414, 808, 826]
}
(async () => {
await horajs.default();
await horajs.init_env();
demo();
I get:
internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/home/halcyon/Downloads/tmp/js-bs/node_modules/horajs/' imported from /home/halcyon/Downloads/tmp/js-bs/test.mjs
at legacyMainResolve (internal/modules/esm/resolve.js:225:9)
at packageResolve (internal/modules/esm/resolve.js:648:14)
at moduleResolve (internal/modules/esm/resolve.js:696:18)
at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:810:11)
at Loader.resolve (internal/modules/esm/loader.js:86:40)
at Loader.getModuleJob (internal/modules/esm/loader.js:230:28)
at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:56:40)
at link (internal/modules/esm/module_job.js:55:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Newer versions of wasm-pack seem to need the 'target' set to 'web', or webpack fails to load the WASM module complaining about 'no loader available'.
The fix was to simply pass that option into the WasmPackPlugin in the webpack.config.js file.
plugins: [
new WasmPackPlugin({
crateDirectory: __dirname,
extraArgs: "--target web"
}),
]
Hi @salamer are there types for this library?
Could the wasm bindgen be extended so that the functions implementing serialize / dumping / loading indexes are available in the JS package?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.