Open wskish opened 1 year ago
Hi @wskish, I guess it is possible to change the behavior, but it should be clearly defined what to do in what situation and how to alert the user that something is wrong (usually that is a sign of bad hyperparameters, like ef or M or a broken index).
In the case I am seeing the ef/M/index are fine it is just that there are actually fewer than K items in the index that meet the filter criteria. So the base assumption that K nearest neighbors actually exist (after filtering) is the issue.
Oh. Got it. Yeah, that needs to be fixed.
One issue is that the batch search returns a numpy matrix. In case there are routinely not enough candidates, the matrix would not be filled. Maybe can add something like -1
to indicate the lack of result to keep the api intact. Will think about that.
@yurymalkov +1! eg https://github.com/chroma-core/chroma/issues/225
Yeah, we are gonna work on it.
Circling back to see if we indeed fixed this issue?
When using filters and requesting a K larger than the number of filtered items in the index, hnswlib will raise the following exception: "RuntimeError: Cannot return the results in a contigious 2D array. Probably ef or M is too small"
Would it be possible to just return however many items are available in this case instead of raising the exception.