KatInterview

Quality Assurance Pipeline for a Compliance-Grade RAG Assistant

Machine LearningModel answer
MediumModel answerMachine Learningragllm-evaluationmlops

Last updated

Design how to measure, gate, monitor, and debug a retrieval-augmented assistant that serves regulated, multi-tenant content, including root-cause triage of bad answers.

Scenario

A fintech platform runs a question-answering assistant built on retrieval-augmented generation. It answers developer, compliance, and enterprise-customer questions using fast-changing API documentation, regulatory guidance, and per-tenant integration rules. A wrong or invented answer could cause a security flaw or a compliance violation, and tenant access boundaries are strictly enforced.

Design the quality-assurance stack for this assistant. It should keep answers faithful to sources, block regressions before they ship, and let on-call engineers diagnose bad answers quickly.

Requirements

Functional

  • Staged evaluation: score retrieval quality (recall, precision, ranking) separately from generation quality (faithfulness, relevance, citation correctness).
  • Offline gating: build an automated suite with a golden dataset and LLM-judge scoring that can block deployments.
  • Live monitoring: observe real queries, explicit and implicit feedback (thumbs, rephrased retries), latency, token spend, semantic drift, and safety violations.
  • Root-cause localization: provide a structured way to decide whether a bad answer came from retrieval failure (missing or noisy chunks), context truncation, or model hallucination.
  • Privacy and tenancy: evaluation data and telemetry must honor tenant isolation and have PII and secrets redacted.

Non-functional

  • About 100,000 queries per day.
  • The offline suite must finish within 20 minutes on a pull request.
  • Zero cross-tenant leakage in telemetry, embeddings, and judge runs.

What to cover

  1. Metrics, and how to build and maintain a golden dataset (including synthetic expansion).
  2. Architecture: how telemetry flows from live traffic to evaluators, the offline harness, and alerts.
  3. A root-cause framework (decision tree or classifier) for triaging reported problems, for example using the context relevance / groundedness / answer relevance triad.
  4. Trade-offs between LLM-judge cost and latency versus heuristic or embedding-based checks.

Hints

Hint 1

Convert 100K queries/day into QPS and judge-token cost first. It shows why you cannot LLM-judge everything online and motivates tiering and sampling.

Hint 2

Measure recall at several points in the pipeline (retriever top-K, after reranking, after context packing). A drop between stages tells you which component is at fault.

Hint 3

For triage, walk the trace in order: was the gold evidence retrieved, did it survive packing, was the answer supported by the context, did it address the question? Each yes/no points at one component.

Hint 4

For a 20-minute CI gate, run cheap deterministic checks on the full set and the LLM judge on a risk-weighted sample, then use paired comparison against the baseline rather than absolute thresholds.