Upserts batchen in chunks
In deze oefening ga je vectors in de Pinecone-index 'datacamp-index' sequentieel, batch-voor-batch, toevoegen.
De hulpfunctie chunks() die je in de vorige oefening hebt gemaakt, is beschikbaar:
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))
Deze oefening maakt deel uit van de cursus
Vector-databases voor embeddings met Pinecone
Oefeninstructies
- Initialiseer de Pinecone-verbinding met je API-sleutel.
- Upsert de vectors in
vectorsin batches van 100 vectoren in'datacamp-index'. - Print de beschrijvende statistieken van deze index.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# 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(____)