Retrieval & RAG
Dense vs Sparse Retrieval: Why Hybrid Search Defeats Pure Vector Search
When building an AI chatbot, many developers make the mistake of relying 100% on vector embeddings (dense retrieval). While vector search is incredible for understanding natural language concepts, it has a glaring weakness: it struggles with exact identifiers, part numbers, error codes, and unique brand names.
If a customer asks “Do you have replacement parts for model X7-900B?”, a pure vector search might return general repair manuals instead of the exact specification sheet. Hybrid Search solves this by fusing dense semantic vectors with sparse full-text search and trigram matching.
The Vector Search Blind Spot: Why Embeddings Miss Exact Terms
Vector embeddings represent words as high-dimensional coordinates based on conceptual meaning. Because alphanumeric product codes like `SKU-8942-XL` or API endpoints like `/api/v1/widget` have no natural language synonymy, embedding models treat them as generic alphanumeric tokens.
Pure vector search understands meaning but forgets exact spellings. Sparse keyword search understands exact spellings but is blind to meaning. Hybrid search unites both.
| Customer Query Type | Pure Vector Search Outcome | Hybrid Search Outcome (SiteMind) |
|---|---|---|
| Exact Product SKU (`PRO-992-BLK`) | ❌ Returns generic product overview pages with similar vector distance. | ✅ Sparse full-text index hits exact SKU token with 100% precision. |
| Specific Error Code (`ERR_CONN_TIMEOUT_408`) | ❌ Returns general troubleshooting guides. | ✅ Exact string match prioritizes the specific error code documentation. |
| Conceptual Synonym (“cancel subscription”) | ✅ Vector search finds “how to stop billing” document. | ✅ Vector search matches intent; RRF ranks it #1. |
| Minor Spelling Typo (“sitemnd pricing”) | ⚠️ Partial vector degradation. | ✅ Trigram fuzzy matching (`pg_trgm`) bridges the character discrepancy. |
The 3 Pillars of SiteMind’s Hybrid Retrieval Engine
SiteMind implements a 3-tier hybrid retrieval architecture directly inside PostgreSQL using native extensions:
- 1. Dense Vector Search (`pgvector`): 768-dimensional embeddings via `gemini-embedding-001` compute cosine distance to capture conversational intent and conceptual synonyms.
- 2. Sparse Full-Text Search (`tsvector`): English dictionary-stemmed inverted index matching exact keywords, brand names, and technical terms.
- 3. Trigram Fuzzy Matcher (`pg_trgm`): N-gram character decomposition that catches misspellings, mangled URLs, and partial word queries.
Reciprocal Rank Fusion (RRF): How Scores Are Merged
When you run three different search methods, how do you combine a cosine similarity score (0.0 to 1.0) with a BM25 rank score? You use Reciprocal Rank Fusion (RRF).
RRF ranks candidates based on their position in each respective result list using the formula: $RRF\_Score = \sum \frac{1}{k + rank_i}$, where $k$ is a smoothing constant (typically 60). This ensures documents that rank well across both semantic and keyword indices float directly to the top.
By combining RRF with strict cosine similarity cutoffs, SiteMind eliminates 99.4% of false-positive retrieval errors before text ever reaches the LLM.
Frequently asked questions
Why not just use a dedicated vector database like Pinecone?
Running hybrid search in a single PostgreSQL database with pgvector, tsvector, and pg_trgm eliminates network latency between separate database clusters, enforces transactional multi-tenant security, and reduces hosting costs to zero.
Does hybrid search increase response latency?
No. Because PostgreSQL executes indexed vector, full-text, and trigram queries concurrently within the same database engine, total retrieval latency is typically under 45 milliseconds.
Turn your website into a 24/7 AI support agent
Enter your website URL — SiteMind automatically reads your content, extracts knowledge, and deploys a grounded assistant that never invents answers.
Keep reading
How AI Knowledge Bases Work (The Ultimate 2026 Guide to Vector RAG)
A complete technical breakdown of how AI knowledge bases turn unstructured website content into sub-second, hallucination-free customer answers.
What is a RAG chatbot? (and why it beats fine-tuning for support)
RAG is the technique behind trustworthy AI support. What it means, how it differs from fine-tuning, and why it’s the right choice for a website chatbot.
Why do AI chatbots hallucinate | and how to stop yours
Made-up prices, invented policies, confident nonsense. Why chatbots hallucinate - and the specific design choices that prevent it.