1. Learn
  2. /
  3. Courses
  4. /
  5. Vector Databases for Embeddings with Pinecone

Connected

Exercise

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))

Instructions

100 XP
  • 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.