选项

面向生产级 AI 应用的托管向量数据库。完全托管、自动扩展,支持混合搜索(密集 + 稀疏)、元数据过滤和命名空间。低延迟(p95 值<100 毫秒)。适用于生产级 RAG、推荐系统或大规模语义搜索。 最适合无服务器、托管式基础设施。

...展开全部
53
更新时间 2026-06-29

关于pinecone

Pinecone 是一款专为生产环境中的AI应用设计的全托管、无服务器向量数据库。它既解决了向量数据库的扩展问题,又处理了基础设施管理的复杂性。Pinecone提供了一个平台,让开发者能够专注于构建AI应用,而无需担心底层数据库架构(如资源配置、扩展或维护)的问题。 其低延迟(p95<100ms)特性使其非常适合在推荐系统、语义搜索以及检索增强生成(RAG)应用等领域的生产环境中使用。

Pinecone 的关键特性包括结合稠密向量和稀疏向量的混合搜索、元数据过滤以及对命名空间的支持。该平台专为高可用性和可靠性而设计,提供 99.9% 的正常运行时间 SLA。Pinecone 可在不影响性能的情况下自动扩展至数十亿个向量,因此非常适合大规模生产系统。 它与 AWS、GCP 和 Azure 等云服务提供商的集成提供了灵活的部署方式,并可在无服务器或基于 Pod 的环境中无缝运行,以满足不同的性能需求。

Pinecone 该平台面向开发基于 AI 的应用程序且需要高效、可扩展向量搜索的企业和开发者。 典型的应用场景包括 RAG 系统、推荐引擎以及大规模语义搜索,特别是在延迟和基础设施管理至关重要的情况下。凭借其易于集成的特性及托管服务模式,Pinecone 对于需要可靠且低维护的向量数据库解决方案来处理 AI 工作负载的开发者而言,是一个绝佳的选择。

常见问题

如何开始使用 Pinecone?

要开始使用 Pinecone,您可以通过 `pip install pinecone -client` 安装 `pinecone -client` Python 包。然后,初始化 Pinecone 客户端,创建索引,插入或更新向量,并执行查询。文档中提供了每个步骤的示例代码。

Pinecone 的延迟是多少?

Pinecone 具有低延迟特性,其 p95 延迟小于 100 毫秒,因此非常适合对响应速度要求极高的生产环境应用。

Pinecone 是否支持混合搜索?

是的,Pinecone 支持混合搜索,允许在查询中同时使用稠密向量和稀疏向量,从而提供更灵活、更高效的搜索能力。

我可以根据元数据过滤结果吗?

是的,Pinecone 提供元数据过滤功能,允许您根据精确匹配、比较、逻辑运算符或列表的“in”运算符等多种条件过滤查询结果。

Pinecone 是无服务器架构吗?

是的,Pinecone 默认采用无服务器架构,但同时也支持基于 Pod 的部署,以满足在特定环境中需要更稳定性能的用户需求。

在 GitHub 上查看

Pinecone - Managed Vector Database

The vector database for production AI applications.

When to use Pinecone

Use when:

  • Need managed, serverless vector database
  • Production RAG applications
  • Auto-scaling required
  • Low latency critical (<100ms)
  • Don't want to manage infrastructure
  • Need hybrid search (dense + sparse vectors)

Metrics:

  • Fully managed SaaS
  • Auto-scales to billions of vectors
  • p95 latency <100ms
  • 99.9% uptime SLA

Use alternatives instead:

  • Chroma: Self-hosted, open-source
  • FAISS: Offline, pure similarity search
  • Weaviate: Self-hosted with more features

Quick start

Installation

pip install pinecone-client

Basic usage

from pinecone import Pinecone, ServerlessSpec# Initializepc = Pinecone(api_key="your-api-key")# Create indexpc.create_index(    name="my-index",    dimension=1536,  # Must match embedding dimension    metric="cosine",  # or "euclidean", "dotproduct"    spec=ServerlessSpec(cloud="aws", region="us-east-1"))# Connect to indexindex = pc.Index("my-index")# Upsert vectorsindex.upsert(vectors=[    {"id": "vec1", "values": [0.1, 0.2, ...], "metadata": {"category": "A"}},    {"id": "vec2", "values": [0.3, 0.4, ...], "metadata": {"category": "B"}}])# Queryresults = index.query(    vector=[0.1, 0.2, ...],    top_k=5,    include_metadata=True)print(results["matches"])

Core operations

Create index

# Serverless (recommended)pc.create_index(    name="my-index",    dimension=1536,    metric="cosine",    spec=ServerlessSpec(        cloud="aws",         # or "gcp", "azure"        region="us-east-1"    ))# Pod-based (for consistent performance)from pinecone import PodSpecpc.create_index(    name="my-index",    dimension=1536,    metric="cosine",    spec=PodSpec(        environment="us-east1-gcp",        pod_type="p1.x1"    ))

Upsert vectors

# Single upsertindex.upsert(vectors=[    {        "id": "doc1",        "values": [0.1, 0.2, ...],  # 1536 dimensions        "metadata": {            "text": "Document content",            "category": "tutorial",            "timestamp": "2025-01-01"        }    }])# Batch upsert (recommended)vectors = [    {"id": f"vec{i}", "values": embedding, "metadata": metadata}    for i, (embedding, metadata) in enumerate(zip(embeddings, metadatas))]index.upsert(vectors=vectors, batch_size=100)

Query vectors

# Basic queryresults = index.query(    vector=[0.1, 0.2, ...],    top_k=10,    include_metadata=True,    include_values=False)# With metadata filteringresults = index.query(    vector=[0.1, 0.2, ...],    top_k=5,    filter={"category": {"$eq": "tutorial"}})# Namespace queryresults = index.query(    vector=[0.1, 0.2, ...],    top_k=5,    namespace="production")# Access resultsfor match in results["matches"]:    print(f"ID: {match['id']}")    print(f"Score: {match['score']}")    print(f"Metadata: {match['metadata']}")

Metadata filtering

# Exact matchfilter = {"category": "tutorial"}# Comparisonfilter = {"price": {"$gte": 100}}  # $gt, $gte, $lt, $lte, $ne# Logical operatorsfilter = {    "$and": [        {"category": "tutorial"},        {"difficulty": {"$lte": 3}}    ]}  # Also: $or# In operatorfilter = {"tags": {"$in": ["python", "ml"]}}

Namespaces

# Partition data by namespaceindex.upsert(    vectors=[{"id": "vec1", "values": [...]}],    namespace="user-123")# Query specific namespaceresults = index.query(    vector=[...],    namespace="user-123",    top_k=5)# List namespacesstats = index.describe_index_stats()print(stats['namespaces'])

Hybrid search (dense + sparse)

# Upsert with sparse vectorsindex.upsert(vectors=[    {        "id": "doc1",        "values": [0.1, 0.2, ...],  # Dense vector        "sparse_values": {            "indices": [10, 45, 123],  # Token IDs            "values": [0.5, 0.3, 0.8]   # TF-IDF scores        },        "metadata": {"text": "..."}    }])# Hybrid queryresults = index.query(    vector=[0.1, 0.2, ...],    sparse_vector={        "indices": [10, 45],        "values": [0.5, 0.3]    },    top_k=5,    alpha=0.5  # 0=sparse, 1=dense, 0.5=hybrid)

LangChain integration

from langchain_pinecone import PineconeVectorStorefrom langchain_openai import OpenAIEmbeddings# Create vector storevectorstore = PineconeVectorStore.from_documents(    documents=docs,    embedding=OpenAIEmbeddings(),    index_name="my-index")# Queryresults = vectorstore.similarity_search("query", k=5)# With metadata filterresults = vectorstore.similarity_search(    "query",    k=5,    filter={"category": "tutorial"})# As retrieverretriever = vectorstore.as_retriever(search_kwargs={"k": 10})

LlamaIndex integration

from llama_index.vector_stores.pinecone import PineconeVectorStore# Connect to Pineconepc = Pinecone(api_key="your-key")pinecone_index = pc.Index("my-index")# Create vector storevector_store = PineconeVectorStore(pinecone_index=pinecone_index)# Use in LlamaIndexfrom llama_index.core import StorageContext, VectorStoreIndexstorage_context = StorageContext.from_defaults(vector_store=vector_store)index = VectorStoreIndex.from_documents(documents, storage_context=storage_context)

Index management

# List indicesindexes = pc.list_indexes()# Describe indexindex_info = pc.describe_index("my-index")print(index_info)# Get index statsstats = index.describe_index_stats()print(f"Total vectors: {stats['total_vector_count']}")print(f"Namespaces: {stats['namespaces']}")# Delete indexpc.delete_index("my-index")

Delete vectors

# Delete by IDindex.delete(ids=["vec1", "vec2"])# Delete by filterindex.delete(filter={"category": "old"})# Delete all in namespaceindex.delete(delete_all=True, namespace="test")# Delete entire indexindex.delete(delete_all=True)

Best practices

  1. Use serverless - Auto-scaling, cost-effective
  2. Batch upserts - More efficient (100-200 per batch)
  3. Add metadata - Enable filtering
  4. Use namespaces - Isolate data by user/tenant
  5. Monitor usage - Check Pinecone dashboard
  6. Optimize filters - Index frequently filtered fields
  7. Test with free tier - 1 index, 100K vectors free
  8. Use hybrid search - Better quality
  9. Set appropriate dimensions - Match embedding model
  10. Regular backups - Export important data

Performance

OperationLatencyNotes
Upsert~50-100msPer batch
Query (p50)~50msDepends on index size
Query (p95)~100msSLA target
Metadata filter~+10-20msAdditional overhead

Pricing (as of 2025)

Serverless:

  • $0.096 per million read units
  • $0.06 per million write units
  • $0.06 per GB storage/month

Free tier:

  • 1 serverless index
  • 100K vectors (1536 dimensions)
  • Great for prototyping

Resources

  • Website: https://www.pinecone.io
  • Docs: https://docs.pinecone.io
  • Console: https://app.pinecone.io
  • Pricing: https://www.pinecone.io/pricing

所有文件

1 个文件

安装 pinecone

下载技能文件并将其解压到 .claude/skills/ 目录中。

下载ZIP

克隆仓库并复制技能文件到您的项目中。

git clone https://github.com/Orchestra-Research/AI-Research-SKILLs/blob/main/15-rag/pinecone/SKILL.md # Copy SKILL.md to your .claude/skills/ directory

复制 复制
快速设置: 将技能文件夹复制到 .claude/skills/ 目录下,Claude 会自动检测并使用该技能

相关技能

Cloudflare Manager
更新时间 2026-06-29
sentry-architecture-variants
更新时间 2026-06-29
azure-setup-guide
更新时间 2026-06-29
cloud
更新时间 2026-06-29
OR