開始使用免費開始

匯入含中繼資料的向量

開始匯入吧!你將匯入 vectors,它是一個字典清單,包含向量數值、ID,以及相關的中繼資料。它們已經整理成可以直接插入索引的格式,無需再額外處理。

以下再次提醒 vectors 的結構。

vectors = [
    {
        "id": "0",
        "values": [0.025525547564029694, ..., 0.0188823901116848]
        "metadata": {"genre": "action", "year": 2024}
    },
        ...,
]

本練習屬於課程

使用 Pinecone 構建 AI 應用

檢視課程

練習說明

  • 使用你的 API 金鑰初始化 Pinecone 連線。
  • 連線到名為 "datacamp-index" 的索引。
  • vectors upsert 到該索引。
  • 列印該索引的描述性統計。

動手互動練習

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

# Initialize the Pinecone client with your API key
pc = Pinecone(api_key="____")

# Connect to your index
index = pc.____("datacamp-index")

# Ingest the vectors and metadata
____

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