KatInterview

Building an Enterprise Document Q&A Assistant with Retrieval

Machine LearningModel answer
HardModel answerMachine Learningragretrievalembeddings

Last updated

Design a production retrieval-augmented question-answering service over company documents, covering indexing, search, grounding, freshness, access control, evaluation and operations.

You are asked to design an internal question-answering assistant for a large organization. Employees ask natural-language questions, and the assistant answers using the company's own content: wikis, tickets, PDFs, chat archives and similar sources. Answers are produced by a language model that is given retrieved passages as context.

Describe the full system, from raw documents to a streamed, cited answer. Your design should cover:

  1. Ingestion: how documents are parsed, split into chunks, embedded and indexed.
  2. Retrieval: how candidates are found and ranked (vector search, keyword search, hybrid combination, reranking).
  3. Prompt orchestration: how context is assembled and how the model is instructed.
  4. Grounding and citations: how answers are tied to sources and how unsupported claims are handled.
  5. Freshness: how edits, deletions and permission changes propagate.
  6. Performance: latency and throughput targets, with rough capacity numbers.
  7. Privacy and security: access control, sensitive data handling, and untrusted retrieved text.
  8. Evaluation: how you measure retrieval relevance and answer quality, and how you reduce hallucinations.
  9. Operations: how you scale and monitor the system in production.

State your assumptions about scale (users, corpus size, QPS) up front and explain the main trade-offs you make.

Hints

Hint 1

Begin by clarifying scale and SLAs, then do quick arithmetic: documents to chunks to vector storage, and QPS to the number of retrieval and GPU workers you need.

Hint 2

Split the design into an asynchronous ingestion path and a synchronous query path. For the query path, think in stages: query rewrite, parallel dense and keyword retrieval, fusion, cross-encoder rerank, prompt building, generation, verification.

Hint 3

Treat permissions as a first-class constraint: where in the pipeline are they enforced, and what happens if you filter after retrieval instead of during it? Also decide what the system does when evidence is weak.

Hint 4

For evaluation, separate retrieval metrics (recall@k, MRR, nDCG) from generation metrics (faithfulness, answer relevance, citation accuracy), and say how you would gate releases and monitor drift online.