Batching upserts in chunks
In this exercise, you'll practice ingesting vectors into the 'datacamp-index'
Pinecone index in series, batch-by-batch.
The chunks()
helper function you created in the previous exercise is available to use:
def chunks(iterable, batch_size=100):
"""A helper function to break an iterable into chunks of size batch_size."""
it = iter(iterable)
chunk = tuple(itertools.islice(it, batch_size))
while chunk:
yield chunk
chunk = tuple(itertools.islice(it, batch_size))
Cet exercice fait partie du cours
Vector Databases for Embeddings with Pinecone
Instructions
- Initialize the Pinecone connection with your API key.
- Upsert the vectors in
vectors
in batches of 100 vectors into'datacamp-index'
. - Print the descriptive statistics from this index.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")
index = pc.Index('datacamp-index')
# Upsert vectors in batches of 100
for chunk in ____:
____
# Retrieve statistics of the connected Pinecone index
print(____)