Enterprise RAG

Enterprise Hybrid RAG Architecture

A battle-tested production blueprint for enterprise search and knowledge retrieval combining dense semantic embeddings, sparse BM25 indexing, and cross-encoder reranking.

By Bhavin Mistry, Senior Engineering Manager at Commonwealth Bank Published: 2026-08-01 Last updated: 2026-09-15 12 min read
Table of Contents (9 sections)
SYSTEM TOPOLOGY & DATA FLOW ENTERPRISE SPECIFICATION
Client Application RBAC Context Security & Gateway PII Sanitization Semantic Cache Check Rate & Token Budget Inference & Rerank BM25 + Vector Fusion Cross-Encoder Top-5 Grounded Synthesis Telemetry OpenTelemetry

The Core Problem Solved

Pure vector search frequently misses exact keyword IDs, acronyms, and product codes, while suffering from vector drift and permission blindness across corporate data silos.

When To Deploy This Architecture

Internal search across complex technical documentation, policy repositories, customer support wikis, and regulatory knowledge bases where retrieval precision is non-negotiable.

Architectural Components

  • Ingestion Pipeline (Document parsing, chunking, metadata extraction)
  • Dual Index (Sparse BM25 Inverted Index + Dense HNSW Vector Store)
  • Hybrid Fusion Layer (Reciprocal Rank Fusion - RRF)
  • Cross-Encoder Reranker (e.g. BGE-Reranker-Large)
  • Security Trimming Filter (Active Directory / RBAC permission alignment)
  • Context Window Synthesizer (Citation & provenance tracking)

Data Flow Narrative

User query -> Ingestion sanitizer -> Parallel BM25 + Dense vector search -> RRF fusion score calculation -> RBAC permission verification -> Cross-encoder top-5 rerank -> LLM grounded synthesis with inline citations.

Security & Perimeter Control

Enforce document-level ACLs at query time before LLM context synthesis; zero vector search across records the user is unauthorized to read.

Governance & Telemetry

Maintain strict audit logging of queries, retrieved chunk hashes, and synthesized outputs for compliance reviews.

Identified Failure Modes & Mitigations

Chunk truncation splitting critical clauses; stale vector indices following source edits; rate-limiting on reranker inference endpoints.

Production Code Implementation

Copy-paste ready implementation snippet demonstrating the core architectural boundary logic:

hybrid_rag_pipeline.py
# Enterprise Hybrid Retrieval with Reciprocal Rank Fusion (RRF) & Reranking
from rank_bm25 import BM25Okapi
from sentence_transformers import CrossEncoder

def rrf(dense_ranks: dict[str, int], bm25_ranks: dict[str, int], k: int = 60) -> list[tuple[str, float]]:
    scores = {}
    all_docs = set(dense_ranks.keys()) | set(bm25_ranks.keys())
    for doc_id in all_docs:
        score = 0.0
        if doc_id in dense_ranks:
            score += 1.0 / (k + dense_ranks[doc_id])
        if doc_id in bm25_ranks:
            score += 1.0 / (k + bm25_ranks[doc_id])
        scores[doc_id] = score
    return sorted(scores.items(), key=lambda x: x[1], reverse=True)

# Step 2: Cross-encoder reranking on candidate pool
reranker = CrossEncoder("BAAI/bge-reranker-large")
def rerank_top_k(query: str, candidates: list[dict], top_n: int = 5) -> list[dict]:
    pairs = [[query, c["text"]] for c in candidates]
    scores = reranker.predict(pairs)
    ranked = sorted(zip(candidates, scores), key=lambda x: x[1], reverse=True)
    return [doc for doc, _ in ranked[:top_n]]
Architectural Q&A

Frequently Asked Questions

Why does pure vector search fail in enterprise document retrieval?
Pure vector search relies on semantic embeddings that frequently miss exact part numbers, product SKUs, financial tickers, and regulatory acronyms. It also ignores document-level Access Control Lists (RBAC) and suffers from vector drift across large repositories.
How does Reciprocal Rank Fusion (RRF) combine sparse BM25 and dense vector search?
RRF calculates rank scores: score(d) = sum(1 / (k + rank_i(d))) across both sparse BM25 and dense vector rank lists (typically with k=60), balancing exact keyword matching with semantic concept search without requiring score normalization.
What is the role of a cross-encoder reranker in production RAG?
A cross-encoder evaluates the query and retrieved passage jointly with full cross-attention, computing true contextual relevance. Placing it after fast candidate retrieval dramatically boosts precision@5 before context is passed to the LLM.
Engineering Resource

The Enterprise AI Production Checklist

A rigorous 50-point engineering, security, and FinOps verification gate before promoting Generative AI and Agentic systems to live enterprise traffic.

Zero spam. Fortnightly dispatches. Unsubscribe anytime.
Author & Engineering Leader

Bhavin Mistry

Senior Engineering Manager at Commonwealth Bank based in Melbourne, Australia. Focusing on enterprise AI architecture, hybrid RAG, agentic reliability, and technology economics.

Connected Tools & Frameworks

Cross-Referenced Production Resources

Methodology

5-Stage Maturity Framework

Stage gates from exploration to hardened multi-region deployment.

Assessment

AI Readiness Diagnostic

Benchmark organizational readiness across 12 operational dimensions.

FinOps

RAG Cost Calculator

Model vector storage, query volume, and caching ROI accurately.