stephantul / reach

Load embeddings and featurize your sentences.
MIT License
24 stars 6 forks source link

How could I delete embeds that exist in Reach? #70

Closed Jester6136 closed 1 week ago

Jester6136 commented 1 week ago

How could I delete embeds that exist in reach? I couldn't find function in source code.

stephantul commented 1 week ago

Hey @Jester6136 ,

That functionality doesn't exist yet, but if you like I can add it. For now here's a work-around:

# Assuming you have some reach you want to delete items from, name it `r`.
# Get some items you want to delete, turn it into a set
items_to_delete = ["dog", "cat"]
# Get all items from a reach instance. 
items_to_keep = set(r.items) - set(items_to_delete)
new_r = r.intersect(items_to_keep)

print(len(r))
print(len(new_r))

BTW: are you on github main or using the latest pip version?

Jester6136 commented 1 week ago

Yep @stephantul,

Thank you so much for the workaround! That definitely helps for now. I really appreciate the offer to add the delete functionality too. For reference, I'm currently on the latest pip version.

stephantul commented 1 week ago

Hey @Jester6136 ,

I'm adding the function right now, I'm releasing a new version later today. It has some changes, mainly the save format will change. So it is a breaking change. Please let me know if you run into issues after upgrading. Thanks for using Reach!

I'll ping you in this thread when it's on main.

stephantul commented 1 week ago

It's on main now as Reach.delete(list_of_tokens). The work-around still works of course. I'll release later today.

Jester6136 commented 1 week ago

Thank @stephantul, I'll test it out.