KatInterview

Designing a Quality Gate for a Permission-Aware Document Q&A Assistant

Machine LearningModel answer
HardModel answerMachine Learningragllm-evaluationretrieval-metrics

Last updated

Design an offline and online evaluation system for a retrieval-based enterprise assistant, covering retrieval, faithfulness, citations, abstention, access control, freshness and cost.

Scenario

Your company is rolling out a chat assistant that lets employees ask questions about internal material: engineering specs, financial reports, HR policies and customer contracts. People will make real decisions from its answers, so invented facts, outdated information and exposure of documents a user should not see are all serious failures.

You must design the evaluation framework used to gate releases, monitor production and drive improvement of this retrieval-augmented generation (RAG) assistant.

Assumptions

  • Corpus: 10 million documents in several access tiers, updated incrementally every day.
  • Traffic: peak of 50 queries per second, with a p95 end-to-end latency target under 2.0 s.
  • Budget: average inference cost under $0.02 per query.
  • Labels: 5,000 expert-curated (query, context, answer) examples exist for regression testing. You may also generate synthetic evaluation data.

What your design must cover

  1. Component-level evaluation
    • Retrieval quality for dense and hybrid retrievers, measured independently of the generator.
    • Generation quality: faithfulness to the retrieved context, relevance to the question, and completeness.
    • Claim-level attribution: do the inline citations really support the specific claims they are attached to?
  2. Enterprise safety constraints
    • Abstention and negative testing (out-of-scope questions, missing evidence, contradictory sources).
    • Permission enforcement: how to test that users cannot obtain content outside their role or attributes.
    • Freshness: how to detect regressions when documents change version or contradict earlier snapshots.
  3. Online monitoring
    • Implicit signals (source clicks, dwell time, follow-up behavior) and explicit signals (ratings, corrections).
    • Production guardrails: latency, token budgets, and sampled drift and hallucination checks.

Deliverables

  • A flow or diagram contrasting the offline evaluation harness with online telemetry.
  • How you would build and maintain the evaluation dataset (human-labeled vs. synthetic).
  • Metric definitions, how you would calibrate an LLM judge, and which checks can be deterministic.
  • The trade-offs between evaluation depth, speed and cost in a CI/CD pipeline.

Hints

Hint 1

Evaluate retrieval and generation separately. One useful trick is to run the generator once with retrieved context and once with the known-correct context, then compare the outcomes to see where the fault lies.

Hint 2

Split requirements into hard gates (permission leakage, fabricated numbers) that must be exactly zero and soft quality metrics you try to improve. Do not average the two together.

Hint 3

Do the arithmetic on volume and cost: 50 QPS is on the order of a million or more queries a day, so judging with an LLM on every request is unaffordable and must be sampled or done offline. Inline checks need to be deterministic or tiny models.

Hint 4

Every label must be tied to a document version, otherwise daily updates will silently make your gold set wrong.