Pinecone은 완전 관리형(SaaS) 벡터 데이터베이스다. 서버리스 아키텍처로 인프라 관리 없이 수십억 개의 벡터를 저장·검색할 수 있으며, RAG 애플리케이션과 시맨틱 검색에 널리 활용된다.
서버리스 vs Pod 기반
| 항목 | 서버리스 | Pod 기반 |
|---|
| 비용 모델 | 읽기/쓰기 단위 과금 | 항상 가동 Pod |
| 스케일링 | 자동 | 수동 설정 |
| 콜드 스타트 | 있음 | 없음 |
| 최대 규모 | 제한 없음 | Pod 크기 제한 |
기본 사용법
python
from pinecone import Pinecone, ServerlessSpec
import numpy as np
pc = Pinecone(api_key="your-api-key")
pc.create_index(
name="my-index",
dimension=1536,
metric="cosine",
spec=ServerlessSpec(cloud="aws", region="us-east-1"),
)
index = pc.Index("my-index")
vectors = [
{
"id": f"vec{i}",
"values": np.random.random(1536).tolist(),
"metadata": {"text": f"문서 {i}", "category": "tech"}
}
for i in range(100)
]
index.upsert(vectors=vectors, namespace="articles")
results = index.query(
vector=np.random.random(1536).tolist(),
top_k=5,
include_metadata=True,
namespace="articles",
filter={"category": {"$eq": "tech"}},
)
for match in results["matches"]:
print(f"ID: {match['id']}, Score: {match['score']:.3f}")
관련 문서