การอัปเดตและลบเวกเตอร์

การสร้างแอปพลิเคชัน AI ด้วย Pinecone

James Chapman

Curriculum Manager, DataCamp

ทำให้ข้อมูลทันสมัยอยู่เสมอ...

  • รักษาข้อมูลให้ ทันสมัย
  • เพิ่มประสิทธิภาพการคิวรี
  • รักษา ความสมบูรณ์ของข้อมูล

วงจรชีวิตของข้อมูลตั้งแต่การเก็บรวบรวม การใช้งาน การตรวจสอบ และการอัปเดตหรือลบออก

การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การอัปเดตค่าเวกเตอร์

index.fetch(ids=['1'])
{'namespace': '',
 'usage': {'read_units': 1},
 'vectors': {'1': {'id': '1',
                   'metadata': {"genre": "action", "year": 2023},
                   'values': [-0.0131468913, ...]}
            }
}
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การอัปเดตค่าเวกเตอร์

index.update(

id="1",
values=[0.370695321, ...]
)
  • ข้อควรตรวจสอบ: ความยาวของ list = มิติของ index
1 https://docs.pinecone.io/docs/update-data
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การอัปเดตค่าเวกเตอร์

index.fetch(ids=['1'])
{'namespace': '',
 'usage': {'read_units': 1},
 'vectors': {'1': {'id': '1',
                   'metadata': {"genre": "action", "year": 2023},
                   'values': [0.370695321, ...]}
            }
}
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การอัปเดต metadata ของเวกเตอร์

index.update(
    id="1",
    set_metadata={"genre": "comedy", "rating": 5}
)
1 https://docs.pinecone.io/docs/update-data
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การอัปเดต metadata ของเวกเตอร์

index.fetch(ids=['1'])
{'namespace': '',
 'usage': {'read_units': 1},
 'vectors': {'1': {'id': '1',
                   'metadata': {"genre": "comedy", "year": 2023, "rating": 5},
                   'values': [0.370695321, ...]}
            }
}
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การอัปเดตค่าและ metadata พร้อมกัน

index.update(
    id="1",
    values=[-0.31956, ...],
    set_metadata={"genre": "thriller", "ratings": 4}
)
1 https://docs.pinecone.io/docs/update-data
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การลบเวกเตอร์

index.delete(
    ids=["1", "2"]
)
1 https://docs.pinecone.io/docs/delete-data
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การลบเวกเตอร์ตาม metadata

index.delete(
    filter={
        "genre": {"$eq": "action"},
    }
)
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

การลบเวกเตอร์ใน namespace

index.delete(delete_all=True, namespace='namespace1')
  • หมายเหตุ: จะลบ namespace ออกด้วย!
1 https://docs.pinecone.io/docs/delete-data
การสร้างแอปพลิเคชัน AI ด้วย Pinecone

มาฝึกกันเถอะ!

การสร้างแอปพลิเคชัน AI ด้วย Pinecone

Preparing Video For Download...