Blog

    LLM Testing Architectures for Healthcare: Evaluation Sets, Calibrated Judges, CI Gates, Shadow and Canary Releases

    By GauravNovember 27, 20269 mins read
    On this page

    Teams shipping their first LLM feature often test it the way they test any other code: a few unit tests, a demo for clinicians and a release. Then a model update or a prompt tweak changes behaviour on cases nobody looked at, and the first report comes from a user.

    This post is for engineering, QA and clinical informatics teams preparing LLM features for production. It sets out the test layers an LLM feature needs before release: deterministic checks, evaluation sets, judge models calibrated against clinicians, regression gates in CI, and shadow and canary runs.

    How do you test LLM features before they reach production in healthcare?

    Need a way to evaluate your LLM features?

    Our LLM evaluation service covers evaluation sets, scoring, judge calibration and release gates for healthcare AI.

    Testing LLM features in healthcare before production means layering deterministic checks, scored evaluation sets, calibrated judge models and clinician review, then gating each release in CI and proving it in shadow and canary runs. Agnotic Technologies builds these test architectures so a model or prompt change cannot ship without evidence.

    No single layer is enough. Each one catches a different kind of failure, and the gates between them decide what reaches real users.

    Why don't ordinary unit tests cover LLM features?

    Ordinary unit tests expect one correct output for one input, and LLM outputs vary in wording even when they are right. Tests that compare exact strings either fail constantly or get loosened until they check nothing.

    Keep unit tests for the code around the model: input assembly, parsing, tool calls and output formatting. Judge the model's content with scored evaluations instead, where a good answer can be worded many ways.

    Some content rules are still deterministic and belong in fast checks. A triage label must be one of the allowed values, a summary must not include a field the feature never receives, and a refusal must use the approved wording.

    Which test layers does an LLM feature need?

    An LLM feature needs layers that move from cheap and fast to slow and realistic. Each layer has its own pass rule and runs at a different point in the release path.

    • Deterministic checks: schema, required fields, banned content and length, run on every commit.
    • Evaluation sets: scored cases by task and risk, run on every model, prompt or retrieval change.
    • Judge models: automated scoring of open-ended answers, checked against clinician ratings.
    • Clinician review: a sample of outputs rated by clinicians before significant releases.
    • Shadow and canary: real traffic with no user impact, then limited exposure, before full release.

    The NIST AI Risk Management Framework is a voluntary framework that organizes AI risk work into four functions: Govern, Map, Measure and Manage.

    Pre-release testing sits mostly in Measure. It produces the evidence that Manage uses to decide whether to release, roll back or restrict a feature.

    How should evaluation sets be built?

    Build evaluation sets from real tasks, labelled by people who know the right answer, and split them by risk. A set that is mostly easy cases will pass a model that fails on the cases that matter.

    • Sources: de-identified real inputs, plus written cases for rare but serious situations.
    • Labels: expected answer or rubric, written and checked by clinicians or domain experts.
    • Risk tiers: routine, sensitive and safety-critical cases scored and reported separately.
    • Hold-out: a portion never used while tuning prompts, so scores are not inflated.

    Version the evaluation set like code. When a production problem is found, add the case to the set so the same failure cannot return unnoticed.

    Size each tier so a change in score means something. A safety-critical tier with only a handful of cases can pass by luck, so write more cases there even when real examples are scarce.

    Can a judge model replace clinician review?

    A judge model can score most cases automatically, but only after its scores are shown to agree with clinicians on the same cases. Until then, it is an untested measuring instrument.

    • Calibration set: cases rated by several clinicians, with their agreement recorded.
    • Agreement check: judge scores compared with clinician ratings, per criterion and per risk tier.
    • Known weak spots: criteria where the judge disagrees often stay with human review.
    • Recalibration: repeated when the judge model, its prompt or the feature changes.

    Keep clinicians in the loop for safety-critical tiers even when the judge agrees well. A judge that is right on average can still miss the rare dangerous answer.

    Give the judge the same rubric clinicians used, written as explicit criteria. Vague instructions such as rate the quality produce scores that drift with every judge model update.

    Adversarial and safety cases

    Adversarial cases test what happens when inputs are hostile, strange or out of scope. Healthcare features receive patient messages, documents and notes written by many people, and some will contain instructions aimed at the model.

    The OWASP Top 10 for LLM Applications (2025) ranks prompt injection first: user prompts that alter a model's behavior or output in unintended ways.

    • Injection: instructions hidden in a patient message or document the feature reads.
    • Out of scope: questions the feature must refuse or hand to a person.
    • Missing data: inputs with empty or contradictory fields.
    • Unsafe asks: requests for dosing or diagnosis the feature is not meant to give.

    In July 2024, NIST released the Generative AI Profile (NIST AI 600-1), a companion to the AI RMF that helps organizations identify risks specific to generative AI and proposes actions to manage them.

    Write expected behaviour for each adversarial case, not only a pass or fail. A refusal that still repeats the injected instruction back to the user is a failure.

    How should regression gates work in CI?

    Regression gates should block a merge or release when evaluation scores fall below agreed thresholds, especially on safety-critical tiers. A gate that only warns is soon ignored.

    • Triggers: any change to the model version, prompt, retrieval index, tools or output parsing.
    • Thresholds: set per risk tier, with no tolerance for new failures on safety-critical cases.
    • Comparison: scores shown against the current production version, case by case.
    • Override: a named clinical and engineering approver, recorded with the reason.

    Run the cheap layers on every commit and the full evaluation set on release candidates. That keeps CI fast without letting a large change skip the slow checks.

    Shadow mode and canary release

    Shadow mode runs the new version on real inputs without showing its output to users, then compares it with the current version. Canary release shows the new version to a small, defined group before everyone.

    Shadow runs catch differences evaluation sets missed, because real inputs are messier. Review a sample of disagreements with clinicians before moving on.

    A canary needs exit rules written in advance: which measures must hold, for how long, and who decides to widen or roll back. Choose a group that can report problems quickly, such as a unit with a clinical champion.

    What goes wrong in LLM testing?

    LLM testing usually fails because the tests are easier than real use or because the gates have holes.

    • Demo-driven sets: evaluation cases written to show the feature working, not to break it.
    • Uncalibrated judges: automated scores trusted without ever being compared with clinicians.
    • Silent vendor updates: a hosted model changes and no gate runs because no code changed.
    • Tuning on the test: prompts adjusted until the evaluation set passes, then scores look better than reality.
    • Shadow without review: disagreements logged but never read.

    Fix each with a rule: hard cases in every set, judge calibration before use, pinned model versions, a hold-out set and named reviewers for shadow results.

    A worked example: a patient message triage feature

    A clinic group wants an LLM to sort incoming patient portal messages into routine, same-day and urgent queues. The urgent tier is safety-critical.

    The team builds an evaluation set from de-identified messages labelled by triage nurses, adds written cases for chest pain, suicidal language and injected instructions, and holds back a portion. A judge model scores explanations, and its agreement with nurses is checked first.

    The CI gate blocks any change that misses an urgent case in the set. After shadow runs show a handful of disagreements, nurses review them, two become new test cases, and a canary starts in one clinic.

    Who owns what?

    LLM testing needs clinical, engineering and quality owners, because each layer depends on different expertise.

    • Clinical lead: labels, rubrics, risk tiers and review of shadow disagreements.
    • ML or AI engineering: the evaluation runner, judge calibration and scoring.
    • Platform team: CI gates, model version pinning and shadow and canary routing.
    • Quality or risk: thresholds, override rules and release records.

    Make the clinical lead a required approver on changes to rubrics and thresholds. Engineers can adjust how tests run, but what counts as a safe answer is a clinical decision.

    How do you know the test architecture is working?

    It is working when problems found in production are rare and, when found, would have been caught by a case you then add. Track escapes, not only pass rates.

    • Escapes: production issues per release that no test layer caught.
    • Judge agreement: current agreement with clinicians on the calibration set.
    • Gate activity: blocked changes and overrides per quarter, with reasons.
    • Set growth: new cases added from incidents and shadow reviews.

    Review these measures at each release planning meeting. A test architecture that never blocks anything is probably not testing hard enough.

    What are LLM testing architecture best practices?

    Layer deterministic checks, risk-tiered evaluation sets, calibrated judges and clinician review, and gate every model, prompt or retrieval change in CI. Pin model versions so vendor updates trigger the same gates.

    Keep a hold-out set, add every escaped failure as a new case, and use shadow and canary runs with written exit rules before full release.

    How Agnotic can help

    Agnotic builds LLM test architectures for healthcare teams: evaluation runners, risk-tiered sets with clinician labels, judge calibration, CI gates and shadow and canary routing. We fit them to your release process and quality records.

    Strengthen your healthcare QA

    Our healthcare quality assurance services cover test strategy, automation and validation for regulated software.

    Sources

    Frequently Asked Questions

    A versioned collection of real and written test cases with expected answers or rubrics, scored automatically or by people, and split by risk tier.

    Talk to an engineer about your project

    Share your LLM feature, its risks and your release process. We will outline the test layers and gates it needs.

    Go deeper

    Services and solutions on this topic