KatInterview

Fix a broken medical message routing classifier

Machine LearningModel answer
MediumModel answerMachine Learningml-debugginghealthcaresafety-critical

Last updated

Debug a telehealth triage service that returns wrong categories with negative confidence scores, then redesign the classification and escalation logic.

You're working on a telehealth platform where incoming patient messages must be routed to the appropriate care team. The existing service classifies messages into clinical categories (like "upper respiratory," "dermatology," etc.) and assigns an urgency level and confidence score.

The service exposes three endpoints:

triage(msg: str) -> dict  # returns: message, category, urgency, confidence_level
get_categories() -> list[str]
health_check()

The engineering team reports that classification accuracy is poor. Initial testing reveals that vague patient messages return obviously incorrect categories paired with negative confidence_level values, and these results are sent directly to callers without any filtering or review.

You have one hour to investigate, fix the core issues, and document your findings.

An external LLM API is available if needed. You may use an AI coding assistant during the exercise.

Your Task

Part 1: Investigation (15–20 minutes)

Describe your debugging approach. What would you check in the code and response structure? Which test inputs would you use? What does the "negative confidence with wrong answer" symptom suggest about the underlying bugs?

Part 2: Implementation (25–30 minutes)

Refactor the triage function to stop returning confident-looking incorrect results. Design a decision path that determines when to:

  • Return a classification directly
  • Call the LLM API for ambiguous cases
  • Escalate to manual review

Explain how you'll prevent the LLM from introducing new errors, and how you'll handle urgency differently than category assignment.

Part 3: Documentation (10–15 minutes)

Write a brief report covering:

  • Bugs found, with evidence
  • How you prioritized fixes
  • Trade-offs made (latency, cost, review load, accuracy)
  • What you'd build next with more time

Clarifying Questions to Consider

  • Is there a labeled test set, or do you need to create probe cases?
  • What is the intended range and semantics of confidence_level?
  • Are there privacy or compliance constraints on sending patient messages to external APIs?
  • Which error is more costly: wrong department routing, or missed urgent cases?
  • Does a manual review queue already exist?
  • Must the response format remain backward compatible?

Hints

Hint 1

Start by examining edge cases: empty strings, very short messages, and out-of-domain content to understand how confidence is calculated

Hint 2

A negative confidence score suggests a logic error or missing validation, not just model uncertainty

Hint 3

For a safety-critical system, the cost of a false negative on urgency (missing something serious) is much higher than a false positive (extra caution)