AI
Vector Database
RAG
Database
Machine Learning
Ask anything about this article
Hi! I've read this article.
What would you like to know?
@farhan
Every AI application needs a vector database. They power semantic search, RAG systems, recommendation engines, and similarity matching. Here's your complete guide.
Traditional databases search by exact match:
sqlSELECT * FROM products WHERE name = 'laptop'
-- Only finds exact match for "laptop"
Vector databases search by meaning:
pythonresults = vector_db.query(
text="portable computer for programming",
top_k=5
)
# Finds laptops, ultrabooks, MacBooks, etc.
pythonfrom sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
# Each sentence becomes a 384-dimensional vector
doc_vector = model.encode("How to build a REST API with Node.js")
query_vector = model.encode("Node.js backend tutorial")
# Cosine similarity ≈ 0.89 (very similar!)
| Feature | Pinecone | Weaviate | Chroma | Qdrant |
|---|---|---|---|---|
| Type | Managed cloud | Self-host + cloud | Self-host | Self-host + cloud |
| Max vectors | 100B+ | Unlimited | ~1M (in-memory) | Unlimited |
| Hybrid search | ✅ | ✅ | ❌ | ✅ |
| Multimodal | ❌ | ✅ | ❌ | ✅ |
| Free tier | ✅ (2GB) | ✅ (self-host) | ✅ (full) | ✅ (self-host) |
| Pricing | $$ | $ | Free | $ |
| Best for | Production at scale | Flexible enterprise | Prototyping | High performance |
pythonimport pinecone
pc = pinecone.Pinecone(api_key="YOUR_API_KEY")
index = pc.Index("my-app")
# Upsert vectors
index.upsert(vectors=[
{"id": "doc1", "values": embedding, "metadata": {"title": "...", "category": "tech"}},
])
# Query with metadata filter
results = index.query(
vector=query_embedding,
top_k=5,
filter={"category": {"$eq": "tech"}}
)
pythonimport chromadb
client = chromadb.Client()
collection = client.create_collection("my_docs")
# Add documents (auto-embeds!)
collection.add(
documents=["How to learn Python", "JavaScript fundamentals", "React tutorial"],
ids=["doc1", "doc2", "doc3"]
)
# Query
results = collection.query(
query_texts=["web development basics"],
n_results=2
)
# Returns: ["JavaScript fundamentals", "React tutorial"]
Choose Pinecone if: You need managed, production-ready, zero-ops
Choose Weaviate if: You want flexibility + multimodal + self-hosting
Choose Chroma if: You're prototyping or building locally
Choose Qdrant if: You need high performance with fine-grained control
Vector databases are the backbone of modern AI applications. Master them to build better AI products.