ML SYSTEM DESIGN (DEEP DIVES) · INTERVIEW QUESTION
Design a production RAG system for an enterprise knowledge assistant (10TB docs, 50k employees, ACL-aware).
🔴 advanced · LLM Systems
Hint: Ingestion -> chunking -> embedding -> hybrid retrieval -> reranker -> LLM -> guardrails. Discuss ACL, faithfulness, freshness.
Answer
1. Problem Formulation
"Build an internal knowledge assistant" is too vague — pin it down first.
Clarifying questions:
- Corpus? ~10 TB across Confluence, Google Drive (PDF/DOCX), Slack history, GitHub code, Jira tickets. Mixed languages, mostly English.
- Users? 50k employees with different roles and access controls. An engineer must not see HR salary docs.
- Latency? p95 ≤ 3 s for the first streaming token, full answer ≤ 8 s.
- Quality bar? Answers must cite sources. The system must refuse when evidence is missing rather than hallucinate.
- Freshness? New docs must appear in retrieval within 15 minutes.
Why ML, why RAG specifically? A fine-tuned LLM would memorize stale knowledge and cannot enforce per-user ACLs. Pure keyword search returns documents, not answers. RAG separates the slow-moving reasoner (LLM) from the fast-moving corpus (index) — the right factorization for an enterprise.
ML framing: retrieval-augmented generation = (1) retrieval R(query) → top-k passages with ACL filtering, and (2) generation G(query, passages) → cited answer.
2. Metrics
Offline (RAGAS on a hand-labeled ~500-pair eval set):
- Faithfulness: does every claim follow from cited passages? LLM-as-judge per sentence.
- Answer relevance: does the answer address the question?
- Context precision/recall: are retrieved passages the right ones?
- Citation accuracy: do citations actually contain the cited claim?
Online: thumbs-up rate per answer, escalation-to-human rate, follow-up question rate (lower = better; first answer was complete), abandonment. Plus cost: tokens/query, GPU-seconds/query, $/query.
Trade-off: more retrieved passages → higher recall but more tokens, more latency, more "lost in the middle". Tune top-k against the eval set, not by intuition.
This is the opening of a longer walkthrough. Read the full answer in the topic explorer, free.
Likely follow-up: How would you detect and mitigate hallucinated citations?
Related questions
- Design a YouTube-scale video recommendation system serving billions of users.
- Design a real-time payment fraud detection system (10k+ TPS, 100ms decision budget, delayed labels).
- Design X (Twitter) home timeline ranking — including in-network and out-of-network candidate sources.
- Design an ads CTR prediction and auction system for a major web property (100k QPS, 50ms budget).
- Design a visual search system (Pinterest-style) over 5B+ images with sub-500ms p95 latency.