Part 1 introduced the pattern for verifiable visual AI. Let the model find the evidence, use deterministic code to measure it, apply governed rules to produce a pass, review, or fail verdict, and send anything uncertain to a human.
In a demo, that can feel like the whole problem is solved. The test documents behave the way you expect, the verdicts look right, and the trace gives you a clean explanation of how the system got there. Then real documents start arriving, and the questions change. What happens when an input breaks an assumption nobody wrote down? How do you know a model swap is safe before it ships? Who looks at the cases the system is unsure about, and what happens to their answers? At that point, the challenge is no longer just getting the right answer once. It's knowing when the system is wrong, changing it without breaking what already works, and learning from the cases that still need human judgment.
Part 2 is about this transition of taking the pattern from Part 1 and turning it into something you can operate, evaluate, and improve at scale on Databricks.
Every deterministic stage you write encodes quiet assumptions about the artifact, and you tend to find them the first time a new input breaks one. In the packaging example from Part 1, the step that computes the panel area assumed the panel was bounded by fold lines on the dieline. Round packaging has no fold lines, so the area came back wrong with no error raised, a confident number that happened to be off.
While obvious crashes are easily identified, measurement systems must be specifically engineered to defend against quiet failures, such as a wrong number that appears valid and slips past standard checks.
The defense is to decide what happens for every way the pipeline can be wrong, and to decide it before it happens. For decision uncertainty, almost every path leads to human review.
|
Failure mode |
Control response |
|---|---|
|
Locate uncertainty, like low confidence or a fallback-only pick |
route to review and record the locate source |
|
Measurement disagreement, the two measurement paths diverge beyond tolerance |
route to review with both values in the trace |
|
Missing or ambiguous rule for the measured class or tier |
route to review, don't assume a default threshold |
|
Malformed model output, bad JSON or an out-of-range index |
retry once, then route to review |
|
Distribution shift, a new document format or drift over time |
run scheduled profiling and a SQL alert over aggregate drift metrics, then investigate and add representative cases to the eval set |
Every one of these responses routes a hard case to solid evidence or to a person, and none of them ends in a silent pass. That check makes the system safe to rely on for decisions you have to defend.
The table covers decision uncertainty. Infrastructure failure is a different class and gets a different response, because a reviewer cannot fix a 429. Timeouts, rate limits, and provider errors get a bounded retry with backoff. Corrupt or unsupported artifacts go to quarantine instead of the review queue. Anything that exhausts its retries lands in a dead-letter path for an operator to inspect.
The model's reply deserves its own guard. Ask for a small, strict shape and check it before you trust it. Where the endpoint supports structured outputs, request the schema directly. Validate locally either way, since schema support varies by model and provider, and the guarantee you rely on should be your own. Anything off-shape counts as uncertainty and goes to review.
import json
REQUIRED_KEYS = {"index", "confidence"}
def parse_pick(raw: str, n_candidates: int):
# The locate call returns {"index": int, "confidence": "high|medium|low"}.
try:
pick = json.loads(raw)
except ValueError:
return None # malformed, route to review
if not isinstance(pick, dict) or set(pick) != REQUIRED_KEYS:
return None # wrong shape, route to review
idx, conf = pick["index"], pick["confidence"]
if type(idx) is not int or not 0 <= idx < n_candidates:
return None # not a valid index, route to review
if not isinstance(conf, str) or conf not in {"high", "medium", "low"}:
return None # not a valid confidence, route to review
return idx, conf
Sooner or later someone asks whether a change is safe. It might be a new model version, a tweak to candidate generation, or a library upgrade under the measurement code. Evaluation lets you answer with evidence, and it starts with a question that is harder than it looks, what counts as the right answer.
For a classification task, you can label by eye. A measurement is different. Correctness is a number within a tolerance, so you need a trusted way to produce that number for a set of known artifacts. The usual approach is to measure a small reference set by hand, using a more precise method than the pipeline itself, treat those values as gold, and score the pipeline against a tolerance band. Get this step wrong and the evaluation will measure the wrong thing with great confidence.
With gold labels in hand, score for safety on top of accuracy.
|
Metric |
What it tells you |
|---|---|
|
Locate recall |
how often the right evidence region was found |
|
Measurement error |
deterministic value against gold labels, as error and as within-tolerance rate |
|
Rule-tier accuracy |
how often the chosen threshold or tier matches ground truth |
|
Unsafe pass count |
automatic passes that should have been fail or review. The number you want at zero |
|
Review rate |
share routed to humans. The operational-load metric you reduce only while unsafe-pass count remains zero and measurement and tier metrics remain within their release targets |
|
Version regression |
the same metrics re-run on any engine or model change, so a swap is a measured decision |
The release gate is built around the unsafe pass count and that count has to stay at zero. The gate is deliberately asymmetric. A false pass blocks release, while a false review increases human workload but does not allow an unsafe result through. Locate is the semantic, model-driven stage, so release evaluation runs it several times for each reference artifact and reports both evidence-selection stability and final-verdict stability across those runs.
The evaluation criteria are deterministic code, even though the Locate call being evaluated is probabilistic. In MLflow 3, the golden set can be represented as an evaluation dataset and the safety criteria as code-based scorers, allowing the same metrics to be compared across engine and model versions. The minimal snippet below logs aggregate gate metrics to an MLflow run. A full implementation would express the remaining criteria as MLflow scorers and execute them against the versioned evaluation dataset.
import mlflow
def evaluate_release(results):
# results: per-artifact (verdict, expected, measured, gold, tolerance)
if not results:
raise SystemExit("empty evaluation set, release blocked")
n = len(results)
unsafe = sum(r.verdict == "pass" and r.expected != "pass" for r in results)
in_tol = sum(abs(r.measured - r.gold) <= r.tolerance for r in results)
reviews = sum(r.verdict == "review" for r in results)
with mlflow.start_run():
mlflow.log_metric("unsafe_pass_count", unsafe)
mlflow.log_metric("within_tolerance_rate", in_tol / n)
mlflow.log_metric("review_rate", reviews / n)
# asymmetric gate: a false pass blocks the release, a false review does not
if unsafe:
raise SystemExit(f"{unsafe} unsafe passes, release blocked")
What does a concrete release bar look like? For the packaging example, a reasonable one reads like this:
These are illustrative acceptance criteria to adapt to your own workload. The point is that every criterion is verified by a repeatable test rather than inferred from a handful of successful demonstrations.
The same gate works for any compatible model behind the locate call. Pin the version, run it at temperature zero where the endpoint supports it, and re-execute the gate with each swap. Temperature zero narrows the variance but does not make the call deterministic, so the stability requirement in the gate is doing real work. The gate then supports the release decision for each swap.
The review queue produces candidate labels rather than gold labels by default. Capture each reviewer’s confirmation or override together with the artifact version, check version, evidence, reviewer identity, and rationale, and write it to Delta. Promote a candidate to the golden set only after validation confirms that the record is complete, excludes system-error cases, detects conflicting decisions for the same artifact and check, and routes ambiguous or conflicting cases to a qualified second reviewer or adjudicator.
Keep a frozen regression set aside so improvements are measured against a fixed baseline. As the curated set grows, the evaluation covers more of the production distribution. Separate regulatory policy from automation routing: legal thresholds, such as a minimum type height, change only through an approved rule-governance process. Evaluation may tune operational routing settings such as confidence requirements, fallback restrictions, measurement-agreement tolerances, and review bands. Those settings determine when the engine may act automatically; they never move the legal boundary. Version both types of configuration independently.
Figure 1. The review queue is a labeling engine. Reviewer decisions become candidate labels, curation promotes the reliable ones to gold, the eval and routing thresholds improve, more cases clear automatically, and fewer documents reach a human each cycle.
Dense documents are expensive. A page containing many small text elements can generate enough candidates to require several Locate batches. End-to-end analysis can therefore take seconds or longer, which is too slow to keep an interactive request open. Make processing asynchronous: enqueue the document, run it in the background, and let the caller poll or receive a completion notification. Steady volume can use a scheduled batch path, while one-off uploads use an interactive path, with both invoking the same engine.
At volume, Lakeflow Jobs orchestrates the batch path. A For each task fans the documents out across parallel task runs, and serverless compute sizes itself to the load without a cluster to manage. Two defaults matter here. Iterations run sequentially until you raise the task's concurrency, and the task's input is capped at 48 KB, so pass document IDs rather than payloads and read the control table in bounded pages.
Drive the fan-out from a control table that tracks each document's state. The slow part is the model call, so throttle to the serving endpoint's quota and let Model Serving scale the inference behind it. Keep the writes idempotent, keyed on the artifact and its version, so a retried task cannot produce a duplicate verdict. Lakeflow Jobs owns the orchestration and the retries, and the endpoint owns the throughput.
The pattern maps cleanly onto Databricks services. Figure 2 shows the shape, and it follows the same separation that the Databricks lakehouse reference architectures use, with governed data and reference tables at the center.
Figure 2. End-to-end reference architecture on Databricks. Ingestion and serving on the left, the Locate, Measure, Judge engine in the center, governance, evaluation, and human review around the edges.
|
Concern |
Databricks primitive |
|---|---|
|
Store input artifacts |
Unity Catalog Volumes |
|
Run model calls |
Unity Gateway model services, including supported system.ai foundation models and governed external models |
|
Store rules, traces, and results |
Unity Catalog Delta tables |
|
Batch processing |
|
|
Interactive review |
Databricks Apps |
|
Experiment tracking and release gating |
MLflow, with the golden set as an evaluation dataset and the safety checks as code-based scorers |
|
Stage-level observability |
MLflow Tracing, so every verdict links back to the model call and stages that produced it |
|
Monitoring |
Data profiling in Databricks Data Quality Monitoring, formerly Lakehouse Monitoring |
Monitoring is where the distribution-shift failure mode gets caught. Log every verdict and its reported confidence to a Delta table, and point Databricks Data Quality Monitoring at it. It computes profiles and drift metrics against a configured baseline. Create a SQL alert on the metrics that matter, like the review rate and the verdict mix, and treat a firing alert as a signal to investigate rather than proof of drift. The alert says something changed. Investigating the flagged cases and their input attributes tells you whether the cause is a new document format or shifted model behavior, and adding representative cases to the eval set keeps the change from becoming an undetected trend.
Unity Gateway is the governance layer for the model services used by Locate. It applies Unity Catalog permissions, routes model traffic, supports rate limits, fallbacks, and service policies, and records usage in system.ai_gateway.usage. Supported foundation models are available through system.ai, while external providers can be governed through the same control plane.
Use gateway usage and request-and-response audit data for operational monitoring, debugging, and identifying candidates for the evaluation set. Keep the application’s own decision trace as the authoritative record linking the artifact, evidence, measurement, rule version, routing policy, and final verdict.
The guidance from both posts, condensed:
Reach for Locate, Measure, Judge framework when a decision gates money, safety, a release, or a regulatory step and someone will eventually ask you to prove it. It fits any visual workflow where a model can locate evidence and deterministic code can measure or validate it.
Skip it when a rough semantic classification is sufficient, like routing a ticket or tagging a photo for search. Model judgment also works well in an advisory role, where a human makes the final decision. The moment the model's output becomes the control, it needs an instrument behind it and a rule above it.
It is tempting to hand the whole problem to a capable model, and for exploration it's often the fastest way to learn. But once an AI decision affects money, safety, or compliance, the output needs to be reproducible, auditable, governed, and safe by default, and a model's estimate can't promise that on its own.
That is the idea behind Locate, Measure, Judge. Use the model for the part it is good at which is finding the relevant evidence. Use deterministic code for measurements that need to be repeatable. Keep policy decisions in governed rules, and send the cases that are genuinely uncertain to a human. Those review decisions become useful data for the next round of evaluation.
You can stand this up incrementally. Pick one check with a clear rule, define the shared contracts, build the deterministic measurement, add model-assisted semantic recognition where it is needed, place the policy threshold in governed data, and make the result fail closed. The next check can reuse the orchestration, evidence, provenance, evaluation, and review contracts while supplying its own tested analysis implementation.
If you missed the setup, Part 1 covers the pattern and the three stages.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.