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))
Este ejercicio forma parte del curso
Vector Databases for Embeddings with Pinecone
Instrucciones del ejercicio
- Initialize the Pinecone connection with your API key.
- Upsert the vectors in
vectorsin batches of 100 vectors into'datacamp-index'. - Print the descriptive statistics from this index.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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(____)