Skip to content

Engineer Hybrid Lexical and Vector Retrieval That Cuts Hallucinations

Go beyond naive 500-token cosine similarity chunks that miss exact SKU codes, legal article numbers, tables, and latest document versions.

The button copies the prompt and opens Michał Jaskólski’s LinkedIn profile: paste it into your message to him.

Upgrading naive vector RAG to production precision

  1. 01

    Prepend document and section breadcrumbs to every chunk

    Contextualize chunks with document title, effective date, and heading hierarchy before embedding so isolated paragraphs retain meaning.

  2. 02

    Fuse BM25 lexical search with dense vector similarity

    Combine Reciprocal Rank Fusion over exact keyword matches and semantic vectors so part numbers, acronyms, and conceptual queries all hit.

  3. 03

    Preserve Markdown tables intact with parent-child retrieval

    Never slice mid-table; index row summaries alongside intact Markdown table blocks so numerical comparisons stay structurally faithful.

  4. 04

    Rerank top-40 candidates down to crisp top-8 context

    Apply a fast cross-encoder reranker and hard relevance floor so irrelevant noise never dilutes the model's reasoning window.

How it works in practice

Naive vector-only failure

Query: 'Penalty cap under Addendum B signed 2025 for SKU-9042'. Vector search returns 5 generic 2023 master-agreement liability chunks missing SKU-9042.

Contextual hybrid RAG pipeline

Metadata filter (`status=active`) + BM25 (`SKU-9042`, `Addendum B`) + dense vectors -> Reranker selects exact 2025 Addendum table -> cites EUR 25,000 cap accurately.

Eighty percent of 'LLM hallucinations' in enterprise apps are actually retrieval failures solvable with hybrid search and table-aware chunking.

Frequently Asked Questions

Do we need a dedicated standalone vector database to run hybrid RAG well?

For corpora under tens of millions of chunks, Postgres with `pgvector` plus native full-text/BM25 keeps relational ACL filters transactional and simple.

How do you stop outdated policy versions from polluting RAG answers?

Enforce canonical document-family IDs, `effective_from`/`superseded_at` metadata filters, and incremental re-indexing webhooks on source updates.

Does long-context Gemini or Claude make RAG architecture obsolete?

Only for tiny static handbooks; stuffing 500 documents into every prompt costs 50x more and pushes latency to 20+ seconds per user question.