1. Learn
  2. /
  3. Courses
  4. /
  5. 使用 Pinecone 的向量数据库与 Embeddings

Connected

Exercise

定义用于分块的函数

为便于可复现地批量执行 upsert,您需要定义一个函数,将向量列表拆分为多个小块。

内置模块 itertools 已为您导入。

Instructions

100 XP
  • 将输入 iterable 转换为迭代器。
  • 使用 itertools 模块按 batch_size 大小切片 it。
  • 产出当前这一块。