Comments (3)
This error seems to occur if a variable inside the filter function was deleted. I reproduced this error with the code below:
const hnswlib = require('hnswlib-node');
const index = new hnswlib.HierarchicalNSW('l2', 3);
index.initIndex({ maxElements: 4 });
index.addPoint([1, 2, 3], 1)
index.addPoint([4, 5, 6], 2)
index.addPoint([1, 2, 3], 3)
index.addPoint([7, 8, 9], 4)
arr = [1, 2]
const filterFnc = (label) => arr.includes(label);
delete arr;
console.table(index.searchKnn([1, 2, 3], 2, filterFnc));
$ node issue_132.js
FATAL ERROR: Error::New napi_get_last_error_info
1: 0x104dd69f8 node::Abort() [/Users/foo/.anyenv/envs/nodenv/versions/20.3.1/bin/node]
2: 0x104dd6ae4 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/Users/foo/.anyenv/envs/nodenv/versions/20.3.1/bin/node]
3: 0x104da5af4 napi_open_callback_scope [/Users/foo/.anyenv/envs/nodenv/versions/20.3.1/bin/node]
4: 0x11a71dd98 Napi::Error::Error(napi_env__*, napi_value__*) [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
5: 0x11a71d5ec Napi::Error::New(napi_env__*) [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
6: 0x11a72d140 Napi::Value::ToBoolean() const [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
7: 0x11a72d0cc CustomFilterFunctor::operator()(unsigned long) [/Users/foo/test_hnswlib-node/node_modules/hnswlib-node/build/Release/addon.node]
...
It is recommended to check if any variables in the filter function have been freed.
from hnswlib-node.
Thanks for that repro!
I definitely don't delete any variables directly, I let everything get garbage collected. Furthermore, I experience the issue as soon as I restart my development server (after hours and hours of previous starts/stops). The issue persists for some time (maybe on the order of minutes?), and then resolves itself.
from hnswlib-node.
Update: I figured out the problem, and it was exactly along the lines of what you said.
I was creating a Dictionary of Sets
const availableIndices = mapValues(groupBy(array, item => item.group), item => item.index)
Then, I was iterating through some other items and trying to use this in the filter function:
for (const item of items) {
const searchResult = hsnwIndex.searchKnn(
embedding,
NUM_NEIGHBORS,
(index) => availableIndices[item.group].has(index),
);
}
But if the group hadn't been seen before, then this would throw the error because availableIndices[item.group]
is undefined.
Thanks for your help.
from hnswlib-node.
Related Issues (20)
- Can I load index from url?
- Error on AWS Lambda
- v2.0.0 Changelog HOT 1
- Returning the same points for every query? HOT 1
- Error in initIndex signature HOT 1
- I have this problem to install hnswlib-node HOT 5
- its not work on bunjs HOT 3
- Adding elements to an index without rebuilding it? HOT 2
- Missing cosine? HOT 5
- unable to install. I've got a x64 system and a node version of 18.15.0 HOT 3
- Invalid ELF Header - AWS Lambda HOT 2
- Praise: Great work! HOT 6
- node-gyp rebuild error? HOT 1
- Running into an issue when trying to install hnswlib-node with npm HOT 2
- HNSWLib-node not found when using in a AWS Lambda function HOT 3
- I am not able to install using npm HOT 7
- Code only using 4 CPU, when I have 16 CPU
- Using the library within langchain and removing / updating points / metadata HOT 1
- Error "Please install hnswlib-node as a dependency with, e.g. `npm install -S hnswlib-node`" on M2 Chip HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hnswlib-node.