시작하기무료로 시작하기

청크로 나눠서 배치 upsert 수행하기

이 연습 문제에서는 'datacamp-index' Pinecone 인덱스에 벡터를 배치 단위로 순차 적재하는 방법을 연습해요.

이전에 만든 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 애플리케이션 구축하기

강의 보기

연습 안내

  • API 키로 Pinecone 연결을 초기화하세요.
  • vectors의 벡터를 100개씩 배치로 나누어 'datacamp-index'에 upsert하세요.
  • 이 인덱스의 기술 통계(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(____)
코드 편집 및 실행