Chunks में upserts को batch करें
इस अभ्यास में, आप 'datacamp-index' Pinecone index में वेक्टरों को क्रमवार, बैच-दर-बैच ingest करने का अभ्यास करेंगे.
पिछले अभ्यास में बनाई गई chunks() हेल्पर फंक्शन उपलब्ध है:
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))
यह अभ्यास पाठ्यक्रम का हिस्सा है
Pinecone के साथ AI Applications बनाना
अभ्यास निर्देश
- अपनी API key के साथ Pinecone कनेक्शन initialize करें.
vectorsमें मौजूद वेक्टरों को 100-100 के batches में'datacamp-index'में upsert करें.- इस index से descriptive statistics प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# 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(____)