Pinecone (managed)
import os
from pinecone import Pinecone, ServerlessSpec
pc = Pinecone(api_key=os.environ["PINECONE_API_KEY"])
pc.create_index(
name="docs",
dimension=1536,
metric="cosine",
spec=ServerlessSpec(cloud="aws", region="us-east-1"),
)
index = pc.Index("docs")
index.upsert(vectors=[{"id": "d1", "values": vec, "metadata": {"src": "faq"}}])
Pros: zero infrastructure, auto-scale. Cons: cost, data at the vendor, vendor lock-in.
Qdrant (self-hosted in Docker)
docker run -p 6333:6333 qdrant/qdrant
from qdrant_client import QdrantClient
from qdrant_client.models import Distance, VectorParams
q = QdrantClient(url="http://localhost:6333")
q.recreate_collection(
collection_name="docs",
vectors_config=VectorParams(size=1536, distance=Distance.COSINE),
)
Open source, powerful payload filtering, hybrid mode. Great when data can't leave your perimeter.
pgvector (Postgres extension)
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE chunks (id bigserial PRIMARY KEY, body text, embedding vector(1536));
CREATE INDEX ON chunks USING hnsw (embedding vector_cosine_ops);
SELECT body FROM chunks ORDER BY embedding <=> '[...]'::vector LIMIT 5;
Ideal when you already run Postgres: transactions, JOINs with business data, a single backup. <=> is cosine distance, <-> is L2, <#> is negative inner product.
ChromaDB and FAISS
- ChromaDB — a lightweight local DB for prototypes and notebooks, embedded mode without a server.
- FAISS — Facebook's library, not a database: only an in-memory/on-disk index, no metadata, filters, or networking. Maximum speed for offline tasks and benchmarks.
Index types
- HNSW (nearest-neighbor graph) — high recall, fast search, expensive memory and build. The default almost everywhere. Params:
m (connectivity), ef_construction, ef_search (recall vs query speed).
- IVF (inverted lists + clusters) — more compact, searches only the closest
nprobe clusters; slightly lower recall, better for very large datasets with memory limits.
How to choose
| Scenario | Pick |
|---|---|
| Don't want infrastructure | Pinecone |
| Already have Postgres, up to ~1–5M vectors | pgvector |
| Self-host, privacy, powerful filters | Qdrant |
| Notebook / prototype | ChromaDB |
| Offline benchmark, maximum speed | FAISS |