Skip to content

del cleans onlly unique documents #303

@nick-konovalchuk

Description

@nick-konovalchuk

I want to delete all the embeddings, but it seems like del docs_query[...][:, 'embedding'] deletes only the embeddings of unique documents. In my case, matches of the query documents overlap, so it deletes each an embedding of a unique document only once. I'm providing an example:

from docarray import DocumentArray, Document
import numpy as np

docs_query = DocumentArray([
    Document(embedding=np.array([1, 2, 3])),
    Document(embedding=np.array([1, 2, 3])),
    # Document(embedding=np.array([1, 2, 3]))
])

docs_index = DocumentArray([
    Document(embedding=np.array([1, 2, 3])),
    Document(embedding=np.array([1, 2, 3]))
])

docs_query.match(docs_index)

del docs_query[...][:, 'embedding']
print(len(list(1 for doc in docs_query[...] if doc.embedding is not None)))

Output:

2

6 total docs - 2 unique query docs - 2 unique index docs = 2
You may uncomment the line and get 4 as an output. In that case it's gonna be
9 total docs - 3 unique query docs - 2 unique index docs = 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions