KatInterview

Design an Enterprise Knowledge Base RAG Platform

System DesignModel answer
HardModel answerSystem Designragvector-searchsystem-design

Last updated

Architect an end-to-end Retrieval-Augmented Generation system handling millions of internal documents, low latency, real-time updates, and strict document-level security.

Enterprise Knowledge Base Retrieval-Augmented Generation (RAG) System

Design a high-throughput, enterprise-grade RAG platform that empowers employees to query a corporate knowledge repository (PDFs, Confluence pages, internal chat logs, Notion documents).

Functional Requirements

  1. Grounded Question Answering: Provide precise answers based strictly on internal company sources, complete with traceable inline citations (document title, section, link).
  2. Near-Real-Time Ingestion: Document additions, modifications, or deletions must be indexed and searchable within 5 minutes.
  3. Strict Document-Level Authorization (ACLs): Users must only retrieve information from files or messages they have explicit read permissions to access.

Non-Functional Requirements

  1. Latency Target: Time-To-First-Token (TTFT) must be strictly under 2.0 seconds at the 95th percentile ($p_{95}$).
  2. Scale: Support 10 million source documents (~100 million chunks) and handle a peak query throughput of 1,000 requests per second (RPS).
  3. Reliability & Resilience: Robust handling of corrupt file processing, third-party LLM rate limits/outages, and ingestion retries without data corruption.

Key Discussion Points

  • High-Level System Architecture: Diagram and walk through both the asynchronous document ingestion pipeline and the synchronous query/generation flow.
  • Chunking & Embedding Strategy: Detailed approach to structure-aware parsing, chunk metadata enrichment, and vector space design.
  • Hybrid Retrieval & Reranking: How to balance semantic search with exact-match keyword retrieval (BM25/sparse vectors) and cross-encoder rescoring.
  • Enforcing Authorization at Scale: Propose a deterministic, low-latency method to apply document Access Control Lists (ACLs) without breaking Approximate Nearest Neighbor (ANN) vector search.
  • Observability & Evaluation Framework: Techniques for continuous online monitoring and offline evaluation of retrieval recall and generation hallucination rates.

Hints

Hint 1

Quantify latency budgets early: Break down the 2-second TTFT target into query processing, hybrid search, reranking, and LLM prefill steps.

Hint 2

Address the ACL filtering bottleneck explicitly: Post-filtering top-K results after vector search breaks down when a user has highly restrictive permissions; pre-filtering or payload-indexed search is necessary.

Hint 3

Separate asynchronous document processing from synchronous query paths using message queues to keep ingestion spikes from impacting search latency.