開始使用免費開始

命名空間

命名空間可用來在單一索引中區隔向量,讓查詢更有目標性,並減少被掃描的記錄數量。

在這個練習中,你會在 Pinecone 的 「'datacamp-index'」 索引中,練習將向量寫入不同的命名空間。你需要連線到索引、把向量 upsert 到不同的命名空間,並檢查索引更新後的量測指標。

本練習屬於課程

使用 Pinecone 構建 AI 應用

檢視課程

練習說明

  • 使用你的 API 金鑰初始化 Pinecone 連線。
  • vector_set1 的向量 upsert 到命名空間 namespace1
  • vector_set2 的向量 upsert 到命名空間 namespace2
  • 列印索引的描述性統計。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")
index = pc.Index('datacamp-index')

# Upsert vector_set1 to namespace1
____(
  vectors=vector_set1,
  ____
)

# Upsert vector_set2 to namespace2
____(
  vectors=vector_set2,
  ____
)

# Print the index statistics
____
編輯並執行程式碼