|
|
Getting Started with Pinecone in Python
Author: Venkata Sudhakar
Pinecone is a fully managed vector database that makes it easy to store, index, and query high-dimensional embeddings at scale. Unlike self-hosted solutions like ChromaDB or FAISS, Pinecone requires no infrastructure management - you create an index, upsert vectors, and query them through a simple API. It supports billions of vectors with millisecond query latency, making it suitable for production RAG systems at ShopMax India scale. Pinecone organises vectors into indexes. Each index has a fixed dimension (matching your embedding model) and a distance metric (cosine for semantic search, euclidean for geometric similarity). Namespaces allow you to partition an index into logical groups - for example, separating product embeddings from policy document embeddings within the same index. The below example creates a Pinecone index, upserts ShopMax India product embeddings, and performs semantic similarity search using the Pinecone Python client.
It gives the following output,
Upserted 4 products
Top results for: affordable phone under Rs 70000
[0.891] OnePlus 12 5G smartphone 256GB Rs 64999 Delhi
[0.847] Samsung Galaxy S24 256GB smartphone Rs 74999 Mumbai
Pinecone correctly ranked the OnePlus 12 highest as it is both a phone and under Rs 70000. The Samsung Galaxy S24 scored second despite being slightly above budget because it is semantically similar. In production, add metadata filters to enforce hard constraints like price range: index.query(vector=query_emb, filter={"price": {"lte": 70000}}). Use Pinecone for ShopMax product search when your catalogue grows beyond what ChromaDB can handle efficiently in memory.
|
|