KatInterview

OOD Guardrails for a Domain-Restricted Financial Chatbot

Machine LearningModel answer
MediumModel answerMachine Learningood-detectionllm-guardrailsrag

Last updated

Design a low-latency pipeline that classifies chatbot queries as in-domain or out-of-domain, routes them safely, and stays calibrated as traffic drifts.

Context

A customer-facing assistant answers questions about personal finance, grounded in a curated corpus of corporate documents. Traffic has outgrown the corpus: users now ask about medical symptoms, legal disputes, and everyday small talk. You must design the guardrail that decides, for each incoming query, whether it is answerable from the corpus, adjacent-but-unsupported, or clearly outside scope — and what the system does with each verdict.

What to deliver

  • An end-to-end architecture for the real-time decision path, plus any secondary check placed around generation.
  • The signals you would compute and why each one earns its latency.
  • A routing policy for each verdict class, including refusals and handoffs.
  • How thresholds are set given that error costs are asymmetric, and how humans keep the thresholds honest over time.
  • A monitoring plan that distinguishes "users are phrasing things differently" from "users are asking about new topics."
  • How the system accommodates a new domain or an expanded corpus without retraining a large model.

Constraints

  • Sustained load of roughly 5,000 queries per second; size for a few times peak.
  • Detection latency must stay under 50 ms at p99 on the synchronous path.
  • New domains and corpus updates must be absorbed without full model retraining.

Edge cases to address

  • The query is financial in topic but not covered by the corpus (a knowledge gap, not a scope violation).
  • The query is in-domain but written in another language, filled with slang, or misspelled.
  • The query starts benign and drifts into a prohibited topic partway through the generated answer.