Enterprise RAG Governance

Architecting reliable and safe GenAI for financial services.

The Problem

A financial services client needed a RAG-powered AI system to answer questions about internal documents — contracts, compliance manuals, financial reports. The stakes were high: a single hallucinated claim in a regulatory context could trigger compliance violations.

The core challenge wasn’t retrieval — it was governance. Financial institutions require:

  • Zero data leakage between client tenants (multi-tenant isolation)
  • Full traceability — every claim must be grounded in a specific source document
  • Measurable factuality — not “it looks right” but quantified faithfulness scores

Off-the-shelf RAG systems failed on all three. They hallucinate confidently, mix context across users, and provide no audit trail.

Architecture

┌─────────────────────────────────────────────────────────────┐
│                    QUERY LAYER                               │
│  User Query ──▶ Auth + Tenant Resolution ──▶ Rate Limiting  │
└──────────────────────────┬──────────────────────────────────┘
                           │
┌──────────────────────────▼──────────────────────────────────┐
│                 RETRIEVAL LAYER                              │
│                                                              │
│  ┌─────────────────┐    ┌──────────────────┐                │
│  │  Dense Retrieval │    │  Sparse Retrieval │               │
│  │  (Embeddings +   │    │  (BM25 for exact  │               │
│  │   Vector DB)     │    │   term matching)  │               │
│  └────────┬─────────┘    └────────┬─────────┘               │
│           └──────────┬───────────┘                           │
│                      ▼                                       │
│            ┌──────────────────┐                              │
│            │  Hybrid Reranker │                              │
│            │  (Cross-encoder) │                              │
│            └────────┬─────────┘                              │
└─────────────────────┼────────────────────────────────────────┘
                      │
┌─────────────────────▼────────────────────────────────────────┐
│                   GENERATION LAYER                            │
│  Top-K Chunks + Query ──▶ LLM ──▶ Draft Response             │
└─────────────────────┬────────────────────────────────────────┘
                      │
┌─────────────────────▼────────────────────────────────────────┐
│                  VALIDATION LAYER                             │
│                                                              │
│  ┌─────────────────────────────────────────────┐            │
│  │  Grounding Checker                           │            │
│  │  - Every claim matched to source chunk       │            │
│  │  - Unsupported claims flagged / removed      │            │
│  │  - Faithfulness score computed               │            │
│  └─────────────────────────────────────────────┘            │
│                                                              │
│  ┌─────────────────────────────────────────────┐            │
│  │  Safety Filter                               │            │
│  │  - PII detection in output                   │            │
│  │  - Tenant boundary enforcement               │            │
│  │  - Compliance keyword scanning               │            │
│  └─────────────────────────────────────────────┘            │
└─────────────────────┬────────────────────────────────────────┘
                      │
                      ▼
              Final Response + Citations

Key Decisions & Tradeoffs

1. Multi-Tenant Isolation at the Vector DB Layer

Decision: Each tenant gets a separate namespace in the vector database with access controls enforced at the database layer, not the application layer.

Tradeoff: This adds latency (~15ms per query for namespace routing) and increases infrastructure cost (separate indices). But application-level isolation is fragile — a single bug could leak data across financial entities. The database-level guarantee is worth the cost.

What I learned: Security boundaries should be enforced as close to the data as possible. Application-layer checks are necessary but not sufficient.

2. Hybrid Retrieval (Dense + Sparse)

Decision: Combined semantic search (embeddings) with keyword search (BM25) and reranked results using a cross-encoder.

Tradeoff: Three-stage retrieval is slower than single-stage. But financial documents contain exact terms (account numbers, regulation references, clause numbers) that pure semantic search misses. The hybrid approach caught 23% more relevant chunks in evaluation.

What I learned: For domain-specific retrieval, pure embedding search is a starting point, not a solution. The domain’s vocabulary matters.

3. Grounding Validation as a Separate Layer

Decision: After the LLM generates a response, a separate validation step checks every factual claim against the retrieved chunks. Unsupported claims are either removed or flagged with uncertainty.

Tradeoff: Adds ~200ms latency per response and requires a second model call (cross-encoder). But it reduced the unsupported claim rate from ~33% to under 4%.

What I learned: LLMs are confident liars. You cannot trust self-reported certainty. External validation is non-negotiable for high-stakes domains.

4. Faithfulness as a First-Class Metric

Decision: Implemented automated faithfulness scoring (response claims vs. source chunks) as a core CI metric, not just a one-time evaluation.

Tradeoff: Requires maintaining evaluation datasets and running scoring on every model/prompt change. But it catches regressions before they reach production.

Results

Metric Before After Change
Faithfulness Score 0.67 0.91 +36%
Unsupported Claim Rate ~33% <4% -88%
Tenant Isolation App-level DB-level Hardened
P95 Latency 1.2s 1.8s +50% (acceptable)
Retrieval Recall@10 0.71 0.89 +25%

What Made This Hard

The hallucination problem: The first version had no grounding checker. The LLM would synthesize plausible-sounding answers that combined information from multiple documents in ways that were technically “supported” by individual chunks but semantically wrong in combination. Fixing this required the separate validation layer.

The multi-tenant trap: Initial design used application-level tenant filtering. During load testing, we discovered race conditions where rapid concurrent queries could briefly share context. Moving isolation to the database layer eliminated this entirely.

The latency vs. accuracy tension: Every validation layer adds latency. The business wanted sub-second responses. We negotiated a tiered approach: fast path for low-stakes queries (single retrieval + generation), full validation for high-stakes (hybrid retrieval + grounding + safety).


[Built at KPMG Global Services. Source code is proprietary. Architecture and metrics shared with permission.]