Aan de slagGa gratis aan de slag

Deleting vectors

Deleting vectors isn't just about tidying up our databases; it's about optimizing performance. As your indexes grow, unnecessary or outdated vectors can clutter your storage and slow down query performance. By removing redundant data, you streamline your operations, leading to faster responses and better resource utilization.

In this exercise, you'll practice deleting vectors from the 'datacamp-index' Pinecone index. You'll check the index metrics to verify the deletion took place.

If you accidentally delete the vectors but don't pass the exercise for a different reason, add the following code before your .delete() code to re-upsert the vectors for deletion:

index.upsert(vectors=vectors)

Deze oefening maakt deel uit van de cursus

Vector Databases for Embeddings with Pinecone

Cursus bekijken

Oefeninstructies

  • Initialize the Pinecone connection using your API key.
  • Delete the vectors with IDs "3" and "4".
  • Retrieve the metrics of the datacamp-index Pinecone index to check that the number of stored vectors has decreased.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Initialize the Pinecone client using your API key
pc = Pinecone(api_key="____")

index = pc.Index('datacamp-index')

# Delete vectors
____

# Retrieve metrics of the connected Pinecone index
print(____)
Code bewerken en uitvoeren