pgvector क्या है?
pgvector Postgres के लिए ओपन सोर्स वेक्टर similarity search. यह Retrieval & Knowledge (RAG) टूल्स की Vector Databases श्रेणी में आता है; ओपन सोर्स है और C में लिखा गया है। शुरू करने के लिए: compile और install करें (Linux/Mac).
सारांश
pgvector एक ओपन सोर्स एक्सटेंशन है जो PostgreSQL में vector डेटा टाइप और similarity search जोड़ता है। इससे आप embeddings को अपने एप्लिकेशन के बाकी डेटा वाले उसी डेटाबेस में स्टोर कर सकते हैं और उन्हें सामान्य SQL से क्वेरी कर सकते हैं, इसलिए Postgres के साथ अलग से कोई vector store चलाने की ज़रूरत नहीं पड़ती।
यह उन developers के लिए बना है जो पहले से Postgres इस्तेमाल करते हैं और AI एप्लिकेशन के लिए semantic search, recommendations या retrieval जोड़ना चाहते हैं। चूंकि vectors सामान्य tables में रहते हैं, आपको अपने similarity search के ऊपर JOINs, transactions, ACID guarantees, point-in-time recovery और Postgres की बाकी सुविधाएं भी मिलती रहती हैं।
एक vector database विकल्प के रूप में, pgvector exact और approximate nearest neighbor search, single-precision, half-precision, binary और sparse vectors, और कई distance functions सपोर्ट करता है, जिनमें L2, inner product, cosine, L1, Hamming और Jaccard शामिल हैं। यह किसी भी ऐसी भाषा से काम करता है जिसका Postgres client मौजूद है।
यह क्या करता है
- Postgres tables में native vector column टाइप जोड़ता है, साथ में halfvec, bit (binary) और sparsevec टाइप भी
- Perfect recall के लिए exact nearest neighbor search, और HNSW व IVFFlat indexes के ज़रिए approximate search
- L2 (<->), inner product (<#>), cosine (<=>), L1 (<+>), Hamming (<~>) और Jaccard (<%>) के लिए distance operators
- Postgres की पूरी feature set: ACID compliance, JOINs, point-in-time recovery और standard SQL queries
- किसी भी ऐसी भाषा के साथ काम करता है जिसका Postgres client हो; Postgres 13 और उसके बाद के वर्ज़न सपोर्ट करता है
- Docker, Homebrew, APT, Yum, conda-forge और कई hosted Postgres providers के ज़रिए उपलब्ध
शुरू करें
Postgres 13+ इंस्टेंस में एक्सटेंशन इंस्टॉल करें, इसे हर डेटाबेस में एक बार enable करें, फिर एक vector column बनाएं और nearest-neighbor query चलाएं।
Compile और install करें (Linux/Mac)
एक्सटेंशन को clone करें और make से build करें। Install स्टेप के लिए आपको sudo की ज़रूरत पड़ सकती है। Docker, Homebrew, APT, Yum और conda-forge पैकेज भी उपलब्ध हैं।
cd /tmp
git clone --branch v0.8.2 https://github.com/pgvector/pgvector.git
cd pgvector
make
make install # may need sudoएक्सटेंशन enable करें
हर उस डेटाबेस में इसे एक बार चलाएं जहां आप vectors इस्तेमाल करना चाहते हैं।
CREATE EXTENSION vector;टेबल बनाएं और vectors insert करें
एक निश्चित संख्या में dimensions वाला vector column जोड़ें, फिर अपने embeddings insert करें।
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3));
INSERT INTO items (embedding) VALUES ('[1,2,3]'), ('[4,5,6]');Nearest neighbors क्वेरी करें
एक distance operator से order करें और results को limit करें। इस उदाहरण में L2 distance इस्तेमाल हुआ है; <#> (inner product), <=> (cosine) और <+> (L1) भी सपोर्टेड हैं।
SELECT * FROM items ORDER BY embedding <-> '[3,1,2]' LIMIT 5;कमांड और कोड प्रोजेक्ट के अपने दस्तावेज़ों से लिए गए हैं — हमेशा जांचें आधिकारिक repo ताज़ा जानकारी के लिए।
कब इस्तेमाल करें
- उस एप्लिकेशन में semantic search या retrieval (RAG) जोड़ें जो पहले से Postgres पर चलता है, बिना अलग vector database खड़ा किए
- Text या image embeddings को उनकी source rows के साथ स्टोर करें, ताकि एक ही SQL query में filter, JOIN और rank कर सकें
- किसी दी गई row के सबसे नज़दीकी vectors खोजकर recommendation या similar-item फीचर बनाएं
- तेज़ approximate nearest neighbor search के लिए HNSW या IVFFlat indexes का इस्तेमाल करके बड़े vector sets तक स्केल करें
How pgvector compares
pgvector alongside other open-source vector databases tools AI/TLDR tracks, ranked by GitHub stars.
| टूल | स्टार | यह क्या करता है |
|---|---|---|
| Supabase | ★ 116k | Managed Postgres backend whose Vector toolkit (pgvector) stores, indexes, and queries embeddings next to transactional data. |
| Redis Cloud | ★ 77.9k | Fully-managed Redis with built-in vector search, offering low-latency similarity and hybrid queries over any embeddings. |
| Milvus | ★ 46.8k | अरबों embeddings में बड़े पैमाने पर खोज के लिए एक ओपन सोर्स वेक्टर डेटाबेस |
| FAISS | ★ 42k | dense vectors पर कुशल similarity search और clustering के लिए लाइब्रेरी |
| Qdrant | ★ 35.9k | Rust में लिखा, समृद्ध payload फ़िल्टरिंग वाला सिमेंटिक सर्च के लिए वेक्टर सर्च इंजन |
| Chroma | ★ 29.8k | ओपन सोर्स एम्बेडिंग डेटाबेस, जो रिट्रीवल और RAG फ़ीचर बनाने में मदद करता है |
| pgvector | ★ 23.9k | Postgres के लिए ओपन सोर्स वेक्टर similarity search |
| turbovec | ★ 17.5k | TurboQuant पर आधारित Rust vector index, जिसमें Python bindings हैं और कोई training step नहीं है |

