KatInterview

Building a Grounded Document Q&A System with Retrieval

Machine LearningModel answer
MediumModel answerMachine Learningragretrievalevaluation

Last updated

Design a question-answering system that retrieves evidence from a versioned, access-controlled document set, cites sources, abstains when unsupported, and measures retrieval and answer quality separately.

You are asked to design a question-answering system backed by a large language model that answers from a collection of documents. The collection is versioned, so documents are added, edited, and removed over time.

Describe the end-to-end design, and cover at least these areas:

  1. Ingestion and chunking: how documents are parsed, split into passages, and indexed.
  2. Retrieval and context assembly: how candidate passages are found, filtered, ranked, and packed into the model prompt.
  3. Evaluation: how you measure retrieval recall independently from the quality of the final generated answer, and how you compare alternative chunking strategies fairly.
  4. Insufficient evidence: what the system does when the collection does not contain enough support to answer.

Assumptions to respect

  • Answers must point to the evidence that supports them.
  • No domain, model, scale, or quality target is given. Choose reasonable baselines and state them explicitly.
  • Document text is untrusted input and must not be able to control the system.
  • Users may only see documents they are authorized to access. Those restrictions must hold when context is selected.
  • A fluent answer is not enough to count as success.

Questions you might raise with the interviewer

  • Which document types and question types must be supported, and how often does the corpus change?
  • Is relevance judged at the document, passage, or supporting-evidence level?
  • Who may read which documents, and can permissions change?
  • What latency and context-window budgets limit how much material can be retrieved?

Hints

Hint 1

Treat retrieval and generation as two separately measurable stages. A wrong answer may come from missing evidence or from misusing good evidence, and you need to tell which.

Hint 2

Think about what metadata each chunk must carry (document id, version, offsets, access labels) so that citations, permission filtering, and re-indexing all work.

Hint 3

For evaluation, define recall at a fixed depth k against labeled evidence passages, hold out a test set from tuning, and include unanswerable questions to test abstention.