pinecone
zechenzhangAGI/AI-research-SKILLs
本番環境向けのAIアプリケーション向けマネージドベクトルデータベース。フルマネージドで自動スケーリングに対応し、ハイブリッド検索(高密度+疎)、メタデータフィルタリング、ネームスペース機能を備えています。低レイテンシ(p95値で100ms未満)。本番環境でのRAG、レコメンデーションシステム、または大規模なセマンティック検索にご利用いただけます。 サーバーレス環境やマネージドインフラストラクチャに最適です。
...すべて拡張しますpineconeについて
Pinecone は、本番環境向けのAIアプリケーション向けに設計された、フルマネージドのサーバーレスベクトルデータベースです。インフラ管理の複雑さを処理しつつ、ベクトルデータベースのスケーリングに関する課題を解決します。Pineconeは、プロビジョニング、スケーリング、メンテナンスといった基盤となるデータベースアーキテクチャを気にすることなく、開発者がAIアプリケーションの構築に集中できるプラットフォームを提供します。 その低遅延(p95値で100ms未満)という特性により、レコメンデーションシステム、セマンティック検索、検索強化生成(RAG)アプリケーションなどの分野における本番環境での利用に最適です。
Pineconeの主な機能には、高密度ベクトルと疎ベクトルを組み合わせたハイブリッド検索、メタデータフィルタリング、およびネームスペースのサポートが含まれます。このプラットフォームは高可用性と信頼性を重視して構築されており、99.9%の稼働率を保証するSLAを提供しています。Pineconeは、パフォーマンスの低下を招くことなく数十億のベクトルまで自動的にスケーリングできるため、大規模な本番システムに適しています。 AWS、GCP、Azureなどのクラウドプロバイダーとの統合により、導入の柔軟性が確保されており、パフォーマンス要件に合わせて、サーバーレス環境やポッドベースの環境でもシームレスに動作します。
Pinecone 本サービスは、効率的でスケーラブルなベクトル検索を必要とするAI駆動型アプリケーションに取り組む組織や開発者を対象としています。 理想的なユースケースとしては、RAGシステム、レコメンデーションエンジン、大規模なセマンティック検索などが挙げられ、特にレイテンシやインフラ管理が重要な場面で威力を発揮します。統合の容易さとマネージドサービスモデルを備えたPineconeは、AIワークロード向けに信頼性が高く、メンテナンスの手間が少ないベクトルデータベースソリューションを必要とする開発者にとって、優れた選択肢となります。
よくある質問
Pinecone を始めるにはどうすればよいですか?
Pineconeの利用を開始するには、`pip install pinecone -client` を実行して `pinecone -client` Python パッケージをインストールします。その後、Pineconeクライアントを初期化し、インデックスを作成し、ベクトルをアップサートし、クエリを実行します。ドキュメントには、これらの各手順に関するサンプルコードが掲載されています。
Pineconeのレイテンシはどのくらいですか?
Pinecone 低レイテンシを実現しており、p95レイテンシは100ms未満であるため、高速な応答時間が重要な本番環境のアプリケーションに適しています。
Pineconeはハイブリッド検索をサポートしていますか?
はい、Pineconeはハイブリッド検索をサポートしており、クエリで高密度ベクトルと疎ベクトルの両方を活用できるため、より柔軟で効率的な検索機能を実現します。
メタデータに基づいて結果をフィルタリングすることはできますか?
はい、Pineconeはメタデータによるフィルタリング機能を提供しており、完全一致、比較、論理演算子、またはリスト用の「in」演算子など、さまざまな基準に基づいてクエリ結果をフィルタリングできます。
Pineconeはサーバーレスですか?
はい、Pineconeはデフォルトでサーバーレスですが、特定の環境でより一貫したパフォーマンスを必要とするユーザー向けに、Podベースのデプロイもサポートしています。
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
- Use serverless - Auto-scaling, cost-effective
- Batch upserts - More efficient (100-200 per batch)
- Add metadata - Enable filtering
- Use namespaces - Isolate data by user/tenant
- Monitor usage - Check Pinecone dashboard
- Optimize filters - Index frequently filtered fields
- Test with free tier - 1 index, 100K vectors free
- Use hybrid search - Better quality
- Set appropriate dimensions - Match embedding model
- Regular backups - Export important data
Performance
| Operation | Latency | Notes |
|---|---|---|
| Upsert | ~50-100ms | Per batch |
| Query (p50) | ~50ms | Depends on index size |
| Query (p95) | ~100ms | SLA target |
| Metadata filter | ~+10-20ms | Additional 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
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
コピー





家
