Judge
An LLM-as-judge verdict with a calibrated guarantee on agreement with human raters, and an optional escalation cascade so an expensive judge only runs on genuinely ambiguous comparisons.
Request
from cli_sdk import CLIClient, Judge, OpenAIBackend
with CLIClient() as client:
result = client.evaluate(
context={"prompt": prompt, "response_a": a, "response_b": b},
queries={
"verdict": Judge(
instructions="Which response better follows the prompt?",
calibration_profile="pairwise-judge-v2",
alpha=0.10,
cascade=[
{"backend": OpenAIBackend(model="gpt-4.1-mini-2025-04-14")},
{"backend": OpenAIBackend(model="gpt-4.1-2025-04-14")},
{"backend": "human_queue"},
],
),
},
)
verdict = result.answers["verdict"]
if verdict.needs_human:
enqueue_for_review(prompt, a, b)
else:
record(verdict.winner) # "response_a" or "response_b"A cascade stage’s backend can be a backend object (as above), a plain
dict such as {"provider": "openai", "model": "gpt-4.1"}, or the string
"human_queue", which may only be the last stage; a cascade has at most 6
stages. A Judge with a cascade needs no request-level backend. Without
a cascade, the request’s backend is the one judge, and it may be a
CustomBackend (client evidence); a
cascade must use hosted backends.
Response
{
"verdict": {
"type": "judge",
"winner": "response_a",
"escalated_to": null,
"decided_by": "openai:gpt-4.1-mini-2025-04-14",
"guarantee": {
"type": "risk_high_probability",
"method": "trust-or-escalate",
"alpha": 0.10,
"target": 0.10,
"delta": 0.10,
"statement": "With 90% confidence, verdicts that are not escalated agree with human labels at least 90% of the time (n=1800).",
"calibration_profile": "pairwise-judge-v2",
"calibration_n": 1800,
"profile_version": 2,
"stats_version": "cci-sdk/0.1.1+hosted.1"
}
}
}How the cascade works
Each stage in cascade scores both responses and takes the more probable
one as its verdict, with that probability as its confidence. Calibration
learns one confidence threshold per stage, by a selective Learn-then-Test
procedure on the human-labelled examples: the lowest threshold at which
the verdicts the stage keeps agree with humans at the target rate, with
the error budget split across the stages. At answer time, if the
stage’s confidence clears its threshold, the verdict is returned with
escalated_to: null when the first stage resolved it, or naming the stage
that did (as provider:model). Otherwise the next stage runs — up to and
including a human review queue, in which case escalated_to is
"human_queue" and needs_human is True. This spends the expensive
stage only on the fraction of comparisons the cheap stage could not
resolve.
The guarantee is about non-escalated verdicts: with probability at
least over the calibration draw (), the rate at
which those verdicts disagree with human raters is at most target
(), over comparisons exchangeable with the calibration set. It
says nothing about any one comparison, and nothing about comparisons sent
to the human queue. The profile needs at least
human-labelled comparisons for
stages (40 for one stage at ).
Building the calibration profile
A Judge profile is calibrated on comparisons with human preference
labels — not judge labels, since the guarantee is specifically about
agreement with humans:
from cli_sdk import CalibrationExample, CLIClient, OpenAIBackend
with CLIClient() as client:
client.calibration_profiles.create(
name="pairwise-judge-v2",
backend=OpenAIBackend(model="gpt-4.1-mini-2025-04-14"),
method="trust-or-escalate",
alpha=0.10,
)
client.calibration_profiles.add_examples(
"pairwise-judge-v2",
examples=[
CalibrationExample(
context={"prompt": p, "response_a": ra, "response_b": rb},
label=human_choice, # "response_a" or "response_b"
source="human",
)
for p, ra, rb, human_choice in human_preferences
],
)The service runs every stage on each example when it calibrates, so a
cascade’s calibration costs one scoring pass per stage and example; the
first evaluate with the Judge query binds the profile to that
cascade. See label-efficient calibration
for combining a modest human-labelled sample with a larger pool that a
judge labels first (judge-labelled rows never set the thresholds), and the
judge cascade guide for an eval pipeline built on
this.
Answer attributes
| Attribute | Type | Meaning |
|---|---|---|
winner | str | None | The verdict, for example "response_a"; None while pending human review |
escalated_to | str | None | None if the first stage resolved it; otherwise the stage that did ("provider:model"), or "human_queue" |
raw["decided_by"] | str | The stage that produced the verdict |
needs_human | bool | escalated_to == "human_queue" |
guarantee, is_heuristic | The guarantee card, and whether it is heuristic |
Parameters
| Parameter | Type | Description |
|---|---|---|
instructions | str | Required. The comparison or verdict to produce. |
calibration_profile | str | Required; calibrated against human labels. |
alpha | float, optional | Target: human agreement on non-escalated verdicts. |
cascade | list[dict], optional | Ordered stages, each {"backend": ...}, cheapest first; end with "human_queue" to guarantee a resolution. |