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

Connected

Exercise

Defining a function for chunking

To be able to batch upserts in a reproducible way, you'll need to define a function to split your list of vectors into chunks.

The built-in itertools module has already been imported for you.

Instructions

100 XP
  • Convert the iterable input into an iterator.
  • Slice it into chunks of size batch_size using the itertools module.
  • Yield the current chunk.