KatInterview

Building a Secure Enterprise Knowledge Search System

Machine LearningModel answer
HardModel answerMachine Learningretrievalsecurityrag

Last updated

Design a search system that answers questions from internal documents with citations while enforcing access permissions and preventing security exploits.

Context

Organizations accumulate vast amounts of internal knowledge across wikis, file storage, issue trackers, and code repositories. Employees waste time searching disconnected systems for information they need to do their work.

You need to design a knowledge search system that accepts natural language questions and produces answers synthesized from internal documents. The system must show where information came from, refuse to answer when evidence is insufficient, and never leak restricted content to unauthorized users.

Core Requirements

Access Control

  • Users see answers derived only from documents they have permission to read
  • Permission revocations must take effect within seconds
  • The system handles dynamic group hierarchies and individual access lists

Answer Quality

  • Responses must cite specific source passages that support each claim
  • When retrieved documents don't contain sufficient information or contradict each other, the system must decline to answer instead of fabricating content
  • Answers must be traceable to their supporting evidence

Security

  • Malicious documents containing embedded instructions to leak data or manipulate behavior must not compromise the system
  • No cross-user information leakage across permission boundaries

Performance Targets

  • 800 ms to begin streaming the first part of an answer (95th percentile)
  • Complete answer delivered within 2.5 seconds (95th percentile)
  • Documents become searchable within 5 minutes of creation or modification
  • 99.9% availability during business hours

System Scale

  • 50 million documents totaling 500 GB to 1 TB of text
  • Growth rate of 100,000 new documents daily
  • 100,000 employees generating up to 100 queries per second at peak
  • Complex access rules with group hierarchies and per-document permissions

What to Address

Design the end-to-end system covering:

  1. How documents are processed, chunked, and indexed while preserving permission metadata
  2. How queries are executed to retrieve relevant content respecting user permissions
  3. How answers are generated with proper citations and when the system should abstain
  4. How you defend against adversarial content and ensure users only see authorized information
  5. How you would evaluate and monitor the system in production

Hints

Hint 1

Think about whether access permissions should be checked before retrieval, after retrieval, or both—and why each stage matters for different reasons.

Hint 2

Consider what happens when most search results are documents the user can't access. How does this affect the quality of retrieved content?

Hint 3

For citations, generating an answer and verifying its claims can happen in overlapping stages to meet latency requirements while maintaining accuracy.