Agrupar actualizaciones en bloques
En este ejercicio, practicarás la ingesta de vectores en el índice Pinecone 'datacamp-index' en serie, por lotes.
La función auxiliar chunks() que creaste en el ejercicio anterior está disponible para su uso:
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
Bases de datos vectoriales para incrustaciones con Pinecone
Instrucciones del ejercicio
- Inicializa la conexión de Pinecone con tu clave API.
- Inserta los vectores de
vectorsen lotes de 100 vectores en'datacamp-index'. - Imprime las estadísticas descriptivas de este índice.
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(____)