KatInterview

Building a Permission-Aware Document Q&A Assistant with Citations

Machine LearningModel answer
HardModel answerMachine Learningragretrievalreranking

Last updated

Design a retrieval-augmented question-answering assistant over internal company documents, with ML detail on each stage, document-level access control, grounded cited answers and failure handling.

Problem

Your company wants a chat assistant that lets employees ask questions about internal knowledge: policies, wiki pages, design specs, support tickets and PDFs. The assistant should use retrieval-augmented generation, so answers come from retrieved passages rather than from the model's memory alone.

The discussion should concentrate on modeling and training decisions, not on generic infrastructure.

Constraints to assume

  • Each user may only see documents they are authorized to read.
  • Answers must be grounded in retrieved passages and carry citations.
  • If the documents do not support an answer, the assistant should say so rather than guess.

What to cover

  1. Propose an end-to-end design split into three parts:
    • a retriever that produces candidate passages,
    • an evaluator that reranks, verifies or filters them,
    • a generator that writes the cited answer.
  2. For each part, explain:
    • the model architecture and why you chose it,
    • the training objective or loss,
    • the optimizer and training recipe (batching, negatives, schedule, precision),
    • how you prepare training data (labels, weak supervision, synthetic data, privacy),
    • how you evaluate it offline, with humans, and in production.
  3. Explain how your design handles the typical failure modes: hallucination, outdated content, contradictory sources and very long documents.

State your scale and latency assumptions up front and justify them.

Hints

Hint 1

Start by fixing assumptions (users, corpus size, latency budget, hard constraints) and then walk the pipeline: ingest and chunk, hybrid retrieve, rerank and verify, generate, then check citations.

Hint 2

Think about where the permission filter belongs. Applying it before ranking, inside the index, avoids leaking information through scores or snippets, and caches must be keyed by access group.

Hint 3

For each stage, pair a loss with a data source: contrastive loss with hard negatives for the retriever, listwise loss for the reranker, supervised fine-tuning plus preference tuning with deliberately unanswerable examples for the generator.

Hint 4

Map every failure mode to a concrete mechanism: abstention training for hallucination, version and recency handling for stale content, conflict-aware training examples for contradictions, structure-aware chunking for long documents.