เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

การสร้างและกำหนดค่า Pinecone index

เพื่อเริ่มต้นสร้างแอปพลิเคชันค้นหาเชิงความหมาย ให้สร้างและกำหนดค่า Pinecone index ใหม่ชื่อ 'pinecone-datacamp' โดย index นี้จะใช้ในแบบฝึกหัดถัดไปเพื่อจัดเก็บบทความ Wikipedia จากชุดข้อมูล SQuAD

หากสร้าง index ที่ไม่ตรงตามข้อกำหนดในคำแนะนำโดยไม่ตั้งใจ ให้เพิ่มโค้ดต่อไปนี้ก่อนโค้ด .create_index():

pc.delete_index('pinecone-datacamp')

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Vector Databases สำหรับ Embeddings ด้วย Pinecone

ดูคอร์ส

คำแนะนำการฝึกหัด

  • กำหนดค่า Pinecone client ด้วย API key ของคุณ
  • สร้าง Pinecone index ชื่อ 'pinecone-datacamp' โดยกำหนดจำนวนมิติเป็น 1536
  • เชื่อมต่อกับ index ที่สร้างขึ้น แล้วดูสถิติของ index

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

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

# Create Pinecone index
pc.create_index(
    name='____', 
    dimension=____,
    spec=ServerlessSpec(cloud='aws', region='us-east-1')
)

# Connect to index and print the index statistics
index = ____
print(____)
แก้ไขและรันโค้ด