刪除向量
刪除向量不只是為了整理資料庫,而是為了最佳化效能。當索引變大,多餘或過時的向量會佔用儲存空間並拖慢查詢效能。移除冗餘資料能簡化整體作業,帶來更快的回應與更好的資源利用率。
在這個練習中,你會從 Pinecone 的「'datacamp-index'」索引中刪除向量。你也會檢查索引的度量指標,以確認刪除已經生效。
本練習屬於課程
使用 Pinecone 構建 AI 應用
練習說明
- 使用你的 API 金鑰初始化 Pinecone 連線。
- 刪除 ID 為
"3"與"4"的向量。 - 取得
datacamp-index這個 Pinecone 索引的度量指標,確認已儲存的向量數量有下降。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Initialize the Pinecone client using your API key
pc = Pinecone(api_key="____")
index = pc.Index('datacamp-index')
# Delete vectors
____
# Retrieve metrics of the connected Pinecone index
print(____)