检索向量

使用 Pinecone 构建 AI 应用

James Chapman

Curriculum Manager, DataCamp

回顾…

正在创建索引。

使用 Pinecone 构建 AI 应用

回顾…

多条记录被写入索引。添加后索引占用率上升。

使用 Pinecone 构建 AI 应用

访问向量

 

Fetching

  • 根据 ID 检索向量

根据 ISBN 检索图书。

 

Querying

  • 检索与输入向量相似的向量

亚马逊图书推荐。

使用 Pinecone 构建 AI 应用

获取向量

index.fetch(

ids=['0', '1']
)
{'namespace': '',
 'usage': {'read_units': 1},
 'vectors': {'0': {'id': '0',
                   'metadata': {"genre": "productivity", "year": 2020},
                   'values': [0.025525547564029694, ...]},
             '1': {'id': '1',
                   'metadata': {"genre": "action", "year": 2023},
                   'values': [-0.0131468913, ...]}}
}
1 https://docs.pinecone.io/guides/data/fetch-data
使用 Pinecone 构建 AI 应用

读取单元(Read Units)

 

  • 读取操作的资源消耗度量:
    • Fetching → 1RU / 10 条记录
    • Querying
    • Listing

 

Pinecone 入门账户定价。

1 https://www.pinecone.io/pricing/
使用 Pinecone 构建 AI 应用

从命名空间获取向量

index.fetch(
    ids=['0', '1']

namespace='namespace1'
)
{'namespace': 'namespace1',
 'usage': {'read_units': 1},
 'vectors': {'0': {'id': '0',
                   'metadata': {"genre": "productivity", "year": 2020},
                   'values': [0.025525547564029694, ...]},
             '1': {'id': '1',
                   'metadata': {"genre": "action", "year": 2023},
                   'values': [-0.0131468913, ...]}}
}
使用 Pinecone 构建 AI 应用

Passons à la pratique !

使用 Pinecone 构建 AI 应用

Preparing Video For Download...