Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Get labels and vectors from index #93

Closed
2 of 3 tasks
leoplusx opened this issue Jun 6, 2023 · 5 comments
Closed
2 of 3 tasks

Feature: Get labels and vectors from index #93

leoplusx opened this issue Jun 6, 2023 · 5 comments
Assignees
Labels
enhancement New feature or request released

Comments

@leoplusx
Copy link

leoplusx commented Jun 6, 2023

Describe what you are looking for

I'd like to be able to access all labels stored inside an index. I'd also like to be able to access vectors from the index by id.

hnswlib has these methods:

  • index.get_items(ids)
  • get_ids_list()

I find them useful, and am missing them in usearch.

Can you contribute to the implementation?

  • I can contribute

Is your feature request specific to a certain interface?

Python bindings

Contact Details

No response

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct
@leoplusx leoplusx added the enhancement New feature or request label Jun 6, 2023
@ashvardanian
Copy link
Contributor

Consider done. I will add it in the next couple of days ;)

@ashvardanian ashvardanian self-assigned this Jun 6, 2023
ashvardanian pushed a commit that referenced this issue Jun 6, 2023
# [0.14.0](v0.13.0...v0.14.0) (2023-06-06)

### Add

* Labels exports and synthetic benchmarks ([9cee295](9cee295)), closes [#93](#93)

### Fix

* Push to protected branch ([defd73c](defd73c))
* Push to protected branch ([c8b643c](c8b643c))
* Python `property` setter ([9e099aa](9e099aa))
* Test label exports order on Windows ([268b834](268b834))
@ashvardanian
Copy link
Contributor

🎉 This issue has been resolved in version 0.14.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@ashvardanian
Copy link
Contributor

@leoplusx I managed to implement those today and they are already available in the latest release. You can use index.labels property to get all labels, use index[x] to get one vector under the x label, and check if it's present with the simple in operator. More enhancements coming soon!

ishkhan42 pushed a commit that referenced this issue Jun 7, 2023
ishkhan42 pushed a commit that referenced this issue Jun 7, 2023
@leoplusx
Copy link
Author

leoplusx commented Jun 9, 2023

Actually, it doesn't seem to work. At least in Python:

Label values all seem to be 0.

Even though, when I run a search, it's clear that there actually are non-zero labels in the index.

Code example:


matches, distances, count  = iu.search(emb_np, k=10)
matches
> array([36517119, 38332614, 38332473, 38332625, 35783650, 38332484,
       36786081, 36927136, 38642553, 37563334])

iu[36517119]
> IndexError: Couldn't find key.

len(iu.labels)
> 3361000

len(set(iu.labels))
> 1

iu.labels[:10]
> array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])

@ashvardanian
Copy link
Contributor

Oh, wow. The new tests cover it, so it must have been solved, but not yet released. Will push the new release sooner.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

No branches or pull requests

2 participants