KatInterview

Design a RAG-Powered Knowledge Assistant with Access Control

Machine LearningModel answer
HardModel answerMachine LearningRAGLLMsystem-design

Last updated

Architect a retrieval-augmented generation system that answers natural language queries over heterogeneous internal documents with strict permissions, low latency, and near-real-time freshness.

Scenario

Your company runs an internal knowledge platform used by hundreds of engineers every day. The corpus spans product wikis, project-management tickets, and team chat archives — thousands of documents in total, updated continuously throughout the day.

You have been asked to design an intelligent assistant that lets engineers ask plain-language questions and receive synthesized answers, with citations. Some documents are sensitive and visible only to specific teams or channels, so the system must enforce those restrictions without exception.

Requirements

Functional

  • Accept natural-language questions from authenticated users.
  • Retrieve relevant content from multiple source types and synthesize a coherent answer.
  • Support multi-step reasoning: the agent may need to look up one piece of information before knowing what to look for next.
  • Enforce per-user access restrictions — users must never see content they are not authorized to view.

Non-Functional

  • Latency: time-to-first-token must be under 1 second at the 95th percentile.
  • Freshness: any document edit must be searchable within 5 minutes. Access-control changes must propagate at least as fast.
  • Scale: the system must sustain 500 requests per second, with documents ranging from a few sentences to many pages.

What Your Design Should Cover

  1. Ingestion pipeline — how documents from different sources are collected, split, enriched, and embedded, including incremental update handling.
  2. Retrieval layer — how you combine vector and keyword search, and how access control is enforced without leaking information.
  3. Agent orchestration — how the system decides whether one retrieval round is enough or whether additional hops are needed, given the hard latency target.
  4. Evaluation strategy — how you measure retrieval quality and answer quality in a way that is actionable.

You are not expected to write code. Walk through each component, call out the tensions between requirements, and justify your trade-offs.

Hints

Hint 1

Start by writing down a latency budget — divide the 1-second target across auth, retrieval, reranking, and generation. This immediately shows you how many sequential LLM calls you can afford before the first token.

Hint 2

Think carefully about where access control is enforced. Post-filtering after retrieval is tempting but creates correctness and information-leakage problems. Consider pre-filtering and why it has its own recall pitfalls, and what you do about both.

Hint 3

Distinguish the common case from the multi-hop case. Most questions need one retrieval round; designing everything around the agentic path will blow your latency budget. A router that classifies query complexity early lets you serve the two cases differently.