Pinecone

Pinecone

全托管 Serverless 向量数据库,提供向量写入、元数据过滤与相似度检索。

核心功能

Pinecone 是全托管的向量数据库云服务:在控制台创建项目与索引后,通过 SDK 完成 upsert 与查询,无需自行部署运维检索节点。相比自托管的 Milvus、Qdrant,它省去容量规划与扩缩容,代价是数据托管在 Pinecone 侧,区域、配额与成本都受平台约束。

功能亮点

免运维索引

用 ServerlessSpec 指定云与区域就能建索引,不必自己规划节点规格和分片。

命名空间隔离

同一索引下按 namespace 拆分数据,Starter 计划每索引最多 100 个。

文本直接入库

用 create_index_for_model 建索引可直接写原文,向量化由平台完成。

元数据过滤

每条记录最多带 40 KB 可过滤元数据,检索时按业务字段先收窄候选集。

适用场景

• 为 RAG 应用托管文档切片向量,用 namespace 隔离不同租户的知识库
• 推荐系统里做近似最近邻召回,再用元数据过滤类目与上下架状态
• 站内语义搜索:把自然语言查询转成向量后检索最相关的内容条目

安装配置

bash
开通服务:
1) 注册并登录 Pinecone 控制台(app.pinecone.io)
2) 在项目中生成 API Key
3) 创建索引:自带向量时用 create_index 指定 dimension 与 metric(如 cosine);
   想让平台代做向量化时改用 create_index_for_model,指定嵌入模型与字段映射

安装客户端 SDK:
pip install pinecone

使用方法

python
初始化客户端并创建索引(自带向量,指定维度与距离度量):
from pinecone import Pinecone, ServerlessSpec

pc = Pinecone(api_key="YOUR_API_KEY")

index_name = "standard-dense-py"
if not pc.has_index(index_name):
    pc.create_index(
        name=index_name,
        vector_type="dense",
        dimension=1536,
        metric="cosine",
        spec=ServerlessSpec(cloud="aws", region="us-east-1")
    )

index = pc.Index(index_name)

写入向量(可带 metadata,按 namespace 分区):
index.upsert(
  vectors=[
    {"id": "A", "values": [0.1, 0.1, ...], "metadata": {"genre": "comedy", "year": 2020}},
    {"id": "B", "values": [0.2, 0.2, ...], "metadata": {"genre": "documentary", "year": 2019}}
  ],
  namespace="example-namespace"
)

用查询向量检索 Top-K:
index.query(
    namespace="example-namespace",
    vector=[0.0236663818359375, -0.032989501953125, ...],
    top_k=3,
    include_metadata=True,
    include_values=False
)

若索引是用 create_index_for_model 建的,可以直接写文本、用文本检索:
index.upsert_records(
    namespace="docs",
    records=[
        {"_id": "rec1", "content": "Refund requests must be submitted within 30 days.", "category": "policy"}
    ]
)

results = index.search(
    namespace="docs",
    query={"top_k": 5, "inputs": {"text": "what is the refund policy"}}
)

说明:官方文档的 upsert / query 示例使用 gRPC 客户端
(from pinecone.grpc import PineconeGRPC as Pinecone),方法名与上面一致。

关键指标

尚未核验对标产品,此处只列本工具自身指标,不做对比结论。

指标Pinecone
价格免费增值
开源
上手难度入门

相关工具

优点

  • Serverless 索引免运维,建索引只需指定维度、度量与区域,不用规划节点规格
  • 提供集成嵌入与 rerank 模型,文本可以直接入库并用文本检索、重排
  • 同一索引内提供 namespace 与最大 40 KB 元数据过滤,便于多租户与条件检索
  • 官方提供 Python / JavaScript / Java / Go SDK 与 REST API,文档含完整 quickstart

缺点

  • Starter 计划限制明显:每项目 5 个 serverless 索引、每组织 2 GB 存储,且索引只能建在 AWS us-east-1
  • 稠密向量维度上限 20000,单个文档上限 2 MB,可过滤元数据上限 40 KB
  • 每个命名空间的 query / upsert 均限 100 请求/秒,超限返回 429,调高需联系官方支持
  • 服务本体闭源、数据托管在 Pinecone 侧,无法自建部署,存在厂商绑定