Vchord Suite
Retrieval-Augmented Generation (RAG) is revolutionizing our interaction with vast datasets and language models. RAG systems offer more precise, contextually aware, and current answers by retrieving pertinent information before generating responses. Nonetheless, constructing robust, scalable, and efficient RAG pipelines poses considerable challenges, particularly for production use.
Many solutions feature complex architectures, using distinct databases for vector search, keyword search, and primary data storage. This commonly results in data synchronization challenges, greater infrastructure complexity, and higher operational costs.
What if you could build a powerful, production-ready RAG system directly within your trusted PostgreSQL database?
Enter the Vchord Suite, a collection of PostgreSQL extensions designed to bring high-performance vector search, native BM25 ranking, and flexible tokenization capabilities right into Postgres. Let’s explore the components and how they enable next-generation RAG solutions.
What is the Vchord Suite?
The suite comprises three key PostgreSQL extensions working in concert:
-
vchord(pgsty/vchord): The core vector search engine. It’s specifically designed for scalable, high-performance, and disk-efficient vector similarity search within PostgreSQL. -
vchord_bm25(pgsty/vchord_bm25): This extension implements the sophisticated BM25 ranking algorithm directly inside PostgreSQL, leveraging efficient Block-WeakAnd algorithms. BM25 is a standard for relevance ranking based on keyword frequency and document characteristics. -
pg_tokenizer(pgsty/pg_tokenizer): Provides essential text tokenization capabilities needed for effective full-text search, enabling fine-grained control over how text is processed for full-text search.
By combining these extensions, you unlock powerful capabilities for building advanced RAG systems entirely within PostgreSQL.
How to Use the Vchord Suite
You can use the tensorchord/vchord-suite Docker image to run multiple extensions which are provided by TensorChord. The image is based on the Docker official PostgreSQL image and includes the following extensions:
vchordpg_tokenizervchord_bm25vector
Use Cases for the Vchord Suite
Use Case 1: Powerful Hybrid Search with Native BM25 and vchord
In the RAG era, effective retrieval is paramount. Neither keyword search nor vector search alone is perfect:
-
Keyword Search (like BM25): Excels at precision, finding documents with exact keyword matches. It’s great for structured queries and term-specific searches. However, it struggles with synonyms, paraphrasing, and understanding the underlying meaning or semantic intent. (Leverages
vchord_bm25andpg_tokenizer). -
Vector Search: Captures deep semantic meaning and relationships between concepts, allowing it to find relevant information even if the exact keywords aren’t present. However, it can sometimes lack precision for queries demanding specific term matches. (Leverages
vchord).
The Solution: Hybrid Search. By combining the strengths of both approaches within PostgreSQL, the Vchord Suite bridges this gap. You can run a query that leverages:
-
vchord_bm25(powered bypg_tokenizer) for keyword precision. -
vchordfor semantic understanding.
The results from both can be intelligently combined (e.g., using reciprocal rank fusion - RRF or Model-based rerank) to produce a final ranking that is more accurate, contextually relevant, and semantically aware than either method could achieve alone. This delivers significantly better retrieval performance for your RAG applications.
Use Case 2: Beyond Text - OCR-Free RAG with ColQwen2 & vchord
Building RAG systems for documents like PDFs or scanned images often involves cumbersome pre-processing pipelines. Traditional methods rely heavily on Optical Character Recognition (OCR) and layout analysis to extract text. This process can be:
-
Slow: OCR can be computationally expensive.
-
Error-Prone: OCR accuracy varies significantly depending on document quality.
-
Lossy: Crucial visual contexts like tables, figures, formatting, and relative positioning is often lost during text extraction.
The Solution: OCR-Free, Visually-Aware RAG. What if you could query documents based on how they look and their content, without explicit OCR?
This is now achievable by combining:
-
Multi-Modal Vision Language Models (VLMs): Models like ColQwen2 can process images (document pages) and generate embeddings that capture both textual content and visual layout information.
-
vchord’s Multi-Vector Capabilities:vchordcan efficiently store and search multiple vectors per document within PostgreSQL – allowing you to store embeddings representing different aspects (e.g., text content, visual layout).
With this setup, you can query your document database using prompts that reference visual elements (“Find documents with a bar chart comparing sales figures”) or combined textual and visual cues, directly within PostgreSQL. This simplifies your RAG stack, potentially boosts retrieval accuracy by preserving visual context, and eliminates the bottlenecks associated with traditional OCR pipelines.
Why Build RAG in PostgreSQL?
Leveraging the Vchord Suite within PostgreSQL offers significant advantages:
-
Unified Data: Keep your source data, text, metadata, and vector embeddings all in one place.
-
Reduced Complexity: Eliminate the need for separate vector databases and synchronization pipelines.
-
Leverage Existing Infrastructure: Utilize your existing PostgreSQL expertise, tooling, and operational practices.
-
Transactional Integrity: Benefit from PostgreSQL’s robust ACID compliance.
-
Rich Ecosystem: Access the wide array of tools and features available within the PostgreSQL ecosystem.
Conclusion
The Vchord Suite transforms PostgreSQL into a powerful, production-ready platform for building advanced RAG solutions. By integrating high-performance vector search (vchord), sophisticated keyword ranking (vchord_bm25), and flexible text processing (pg_tokenizer), you can implement cutting-edge techniques like hybrid search and OCR-free multi-modal retrieval directly within your database. Simplify your architecture, enhance retrieval accuracy, and unlock the full potential of RAG with Vchord in PostgreSQL.
Blog Posts
In our recent blog posts, we shared some user cases where all Docker images can be replaced with VectorChord Suite image.