Can I delete all vectors belongs to a source document using Chroma vector DB? #9495
Replies: 7 comments 7 replies
-
🤖 Hello, To delete all vectors associated with a single source document in a Chroma vector database, you can indeed use the Here's how you can do it:
Here's a sample code snippet: # Assume you have a Chroma instance `chroma_instance` and the source document `source_doc`
ids_to_delete = []
for doc in chroma_instance:
if doc.metadata.get('source') == source_doc:
ids_to_delete.append(doc.id)
chroma_instance.delete(ids=ids_to_delete) This will delete all vectors associated with the source document from the Chroma vector database. Please note that this operation could be time-consuming if you have a large number of documents in your Chroma DB, as it involves iterating over all documents. I hope this helps! Let me know if you have any other questions. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
I think following code is not right, there is no "for doc in chroma_instance", am I right?
|
Beta Was this translation helpful? Give feedback.
-
Allow to specify ID when adding to the FAISS vectorstore. How to delete or update a document within a FAISS index? Just find some related issues, maybe we need a guide how to do this kind of things, maybe a blog. |
Beta Was this translation helpful? Give feedback.
-
For your chroma DB, do the following:
|
Beta Was this translation helpful? Give feedback.
-
If you are using langchain and want to delete all vectors in collection, in my case it was easier to delete the collection: |
Beta Was this translation helpful? Give feedback.
-
Do you have any ideas how to do the same with the qdrant db, in the qdrant there is no .get() support? |
Beta Was this translation helpful? Give feedback.
-
What I did to solve the problem was:
With the async functions work too |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I want to delete all vectors belongs to a single source document in a chroma db, how can I do this?
I found following document at:
https://python.langchain.com/docs/integrations/vectorstores/chroma
It seems we can delete vector using id, but how to find these ids according source (metadata)?
The reason for this function is there are many small documents I want to put into chroma, but I found some of them are wrong docs, so I have to delete them from chroma DB. And maybe I will find other wrong documents in the future.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions