Graders¶
Grader implementations for evaluating responses against rubrics.
Overview¶
Graders evaluate responses against rubrics and return structured reports. The main implementation is CriterionGrader, which supports single LLM, ensemble, and few-shot modes. All combinations work orthogonally.
Quick Example¶
from autorubric import LLMConfig, FewShotConfig
from autorubric.graders import CriterionGrader, JudgeSpec, Grader
# Single LLM mode
grader = CriterionGrader(
judge_model_config=LLMConfig(model="openai/gpt-4.1-mini"),
)
# One call per item: the judge grades the whole rubric in a single call
# instead of one call per criterion
grader = CriterionGrader(
judge_model_config=LLMConfig(model="openai/gpt-4.1-mini"),
llm_calls="per_item",
)
# With custom system prompt
grader = CriterionGrader(
judge_model_config=LLMConfig(model="openai/gpt-4.1-mini"),
system_prompt="You are evaluating technical documentation...",
)
# Ensemble mode
grader = CriterionGrader(
judges=[
JudgeSpec(LLMConfig(model="gemini/gemini-3-flash-preview"), "gemini", weight=1.0),
JudgeSpec(LLMConfig(model="anthropic/claude-sonnet-4-5-20250929"), "claude", weight=1.2),
],
aggregation="weighted",
)
# Single LLM + few-shot
grader = CriterionGrader(
judge_model_config=LLMConfig(model="openai/gpt-4.1-mini"),
training_data=train_data,
few_shot_config=FewShotConfig(n_examples=3, balance_verdicts=True),
)
# Grade
result = await rubric.grade(to_grade=response, grader=grader)
judge_model_config sets up a single judge and judges sets up an ensemble. Pass exactly one of them.
Either accepts a DecisionModelConfig as well as an LLMConfig: a decision-model judge grades each item with one request for the whole rubric. escalation=EscalationConfig(...) makes a grader with one decision-model judge a confidence cascade that escalates uncertain criteria to LLM judges. See Decision Models for the API, and the LLM Judges and Decision-Model Judges chapters for guided introductions to the two judge kinds.
llm_calls="per_item" makes every LLM judge of the grader — the judge of judge_model_config, each judge of judges, and a cascade's escalation judges — grade an item's whole rubric in one call instead of one call per criterion, the way a decision-model judge always does. The default, "per_criterion", is unchanged. See Grading a whole rubric in one call for what the single call looks like, and Decision-Model Judges for what it shares with a decision model's request.
llm_config is deprecated
llm_config is a deprecated alias of judge_model_config. It builds the same judge but emits a
DeprecationWarning. To migrate, rename the keyword; nothing else changes. Passing both raises
ValueError. llm_config will not be removed before the next major version.
Grading Options¶
grader = CriterionGrader(
judge_model_config=LLMConfig(model="openai/gpt-4.1-mini"),
# Score normalization
normalize=True, # True: 0-1 range, False: raw weighted sum
# CANNOT_ASSESS handling
cannot_assess_config=CannotAssessConfig(strategy=CannotAssessStrategy.SKIP),
# Length penalty
length_penalty=LengthPenalty(free_budget=6000, max_cap=8000),
# Position bias mitigation (for multi-choice)
shuffle_options=True, # Default: enabled
# Multi-choice abstain channel
auto_na_option=True, # Default: True — guarantees every multi-choice criterion a
# first-class NA/abstain option (auto-injected if absent).
# Set False for forced-choice (no auto NA option).
# Reproducibility — pins all non-LLM randomness (shuffles, few-shot selection)
seed=42, # Default: auto-generated
)
With auto_na_option=True, an auto-injected NA option is appended at the end (highest index), so existing option indices are preserved; an author-supplied NA option is never stripped.
CriterionGrader¶
Main grader with support for single LLM, ensemble, and few-shot modes.
CriterionGrader
¶
CriterionGrader(*, judge_model_config: LLMConfig | DecisionModelConfig | None = None, judges: list[JudgeSpec] | None = None, aggregation: AggregationStrategy = 'majority', ordinal_aggregation: OrdinalAggregation = 'mean', nominal_aggregation: NominalAggregation = 'mode', training_data: RubricDataset | None = None, few_shot_config: FewShotConfig | None = None, system_prompt: str | None = None, multi_choice_system_prompt: str | None = None, length_penalty: LengthPenalty | None = None, normalize: bool = True, cannot_assess_config: CannotAssessConfig | None = None, shuffle_options: bool = True, auto_na_option: bool = True, seed: int | None = None, binary_response_format: type[BaseModel] | None = None, multi_choice_response_format: type[BaseModel] | None = None, escalation: EscalationConfig | None = None, llm_calls: LLMCalls = 'per_criterion', llm_config: LLMConfig | DecisionModelConfig | None = None)
Bases: Grader[EnsembleEvaluationReport]
Unified criterion-based grader with compositional few-shot and ensemble support.
This grader evaluates each criterion independently and supports: - Single-judge mode (via judge_model_config) - Ensemble mode with multiple judges (via judges) - Few-shot prompting (via training_data + few_shot_config)
All combinations work: single judge, single + few-shot, ensemble, ensemble + few-shot.
Parameters are orthogonal: - judge_model_config OR judges: Choose single-judge or ensemble mode - training_data + few_shot_config: Enable few-shot prompting (applies to every LLM judge)
A judge is an LLM (LLMConfig) or a decision model (DecisionModelConfig), alone
or mixed in one ensemble. An LLM judge is asked about each criterion in its own call. A
decision-model judge is asked about the whole rubric in one request per item: the
submission goes once as shared state and every criterion it can express becomes one
question; a criterion it cannot express fails alone, and a failed request fails every
criterion posed in it, through the same failure routing as an LLM judge's failed call.
Its votes carry probabilities and confidence and no explanation (reason is
None). In a mixed ensemble every judge votes on every criterion, and the votes
aggregate exactly as an all-LLM ensemble's do.
With llm_calls="per_item", each LLM judge of judge_model_config or judges is
asked about the whole rubric in one call per item instead, as a decision model is:
the submission and its context are sent once; the system prompt embeds the binary and
multi-choice system prompts, for the kinds of criteria the rubric has, as guides to
apply to each criterion separately and independently; every criterion is listed under
its decision-model question id (c0, c1, ...), posed as in a per-criterion call
and with its options shuffled exactly as there; and the answer (RubricJudgment) maps
back to one result per criterion. A missing or unusable answer fails only its criterion
(parse), a failed call fails every criterion, and the call's usage and cost ride on
the item's first result. With few-shot examples, the call shows whole training items,
each once with its ground truth for every criterion, instead of examples drawn for each
criterion. Votes, aggregation and scoring are the same in both modes. A cascade's
escalation judges make that call too, but only for an item with an escalated criterion,
and keep only the escalated criteria's results (see below).
A confidence cascade (escalation=EscalationConfig(...)) puts one decision model
first and LLM judges behind it. The decision model judges every criterion in its one
request per item; a criterion it errored or abstained on, or answered with a
confidence below the criterion's threshold, is escalated, and each escalation judge
votes on the escalated criteria only. Called per criterion, an escalation judge is
asked about each escalated criterion in a call of its own. Under
llm_calls="per_item" it is asked about the whole rubric in one call, made only for
an item with an escalated criterion; its judgments of the other criteria are
discarded, a failed call fails its votes on the escalated criteria, and the call's
usage and cost ride on the first escalated criterion's result. Either way each call is
the one the judge would make in an otherwise identical grader without the cascade (the
same seed, judge_id and LLM settings, llm_calls included). An escalated
criterion's report is marked escalated=True, keeps the decision model's vote with
superseded=True, and takes its verdict from the escalation judges' votes alone,
aggregated as any ensemble's; it never falls back to the decision model's vote. The
decision model's judge_scores entry is its own score over every criterion; an
escalation judge's is None by role, as it votes only where the decision model
escalated, even on an item where every criterion escalated.
Some settings exist for LLM judges only. Few-shot examples, the system prompts and
shuffle_options apply to the LLM judges of a mixed ensemble or a cascade and never
reach a decision model; so does llm_calls. A grader whose judges are all decision
models rejects few-shot examples and warns when a system prompt is given,
shuffle_options is False or llm_calls is "per_item", since it has no judge
to apply them to. A custom response format describes a generated judgment, which only an
LLM judge produces, so it cannot be combined with any decision-model judge; it describes
one criterion's judgment, so it cannot be combined with llm_calls="per_item" either.
Example
from autorubric import DecisionModelConfig, LLMConfig, FewShotConfig, RubricDataset from autorubric.graders import CriterionGrader, JudgeSpec
Single LLM¶
grader = CriterionGrader( ... judge_model_config=LLMConfig(model="gemini/gemini-3-flash-preview") ... )
Single LLM + few-shot¶
train, test = dataset.split_train_test(n_train=100) grader = CriterionGrader( ... judge_model_config=LLMConfig(model="gemini/gemini-3-flash-preview"), ... training_data=train, ... few_shot_config=FewShotConfig(n_examples=3), ... )
Ensemble¶
grader = CriterionGrader( ... judges=[ ... JudgeSpec(LLMConfig(model="gemini/gemini-3-flash-preview"), "gemini"), ... JudgeSpec(LLMConfig(model="anthropic/claude-sonnet-4-5-20250929"), "claude"), ... ], ... aggregation="majority", ... )
Ensemble + few-shot¶
grader = CriterionGrader( ... judges=[JudgeSpec(...), JudgeSpec(...)], ... aggregation="majority", ... training_data=train, ... few_shot_config=FewShotConfig(n_examples=3), ... )
Single LLM, one call per item for the whole rubric¶
grader = CriterionGrader( ... judge_model_config=LLMConfig(model="gemini/gemini-3-flash-preview"), ... llm_calls="per_item", ... )
Decision model: one request per item for the whole rubric¶
grader = CriterionGrader(judge_model_config=DecisionModelConfig(model="jev-latest"))
Mixed ensemble of a decision model and an LLM¶
grader = CriterionGrader( ... judges=[ ... JudgeSpec(DecisionModelConfig(model="jev-latest"), "jev"), ... JudgeSpec(LLMConfig(model="gemini/gemini-3-flash-preview"), "gemini"), ... ], ... )
Cascade: the decision model first, an LLM for what it is unsure of¶
grader = CriterionGrader( ... judge_model_config=DecisionModelConfig(model="jev-latest"), ... escalation=EscalationConfig( ... judges=LLMConfig(model="gemini/gemini-3-flash-preview"), threshold=0.72 ... ), ... )
Initialize the criterion grader.
| PARAMETER | DESCRIPTION |
|---|---|
judge_model_config
|
Configuration of the single judge (single-judge mode), which
is given
TYPE:
|
judges
|
List of JudgeSpec for ensemble mode, each an LLM or a decision model,
each with its own
TYPE:
|
aggregation
|
Strategy for aggregating votes in ensemble mode (binary criteria).
TYPE:
|
ordinal_aggregation
|
Strategy for aggregating ordinal multi-choice votes. Central tendency: "mean", "median", "weighted_mean", "mode". Conservative/ permissive (analogs of binary unanimous/any): "min" (lowest selected option) / "max" (highest selected option).
TYPE:
|
nominal_aggregation
|
Strategy for aggregating nominal multi-choice votes. Options: "mode", "weighted_mode", "unanimous". "unanimous" abstains via the NA option on disagreement, or falls back to mode + warns if there is no NA option.
TYPE:
|
training_data
|
Dataset for few-shot examples. If provided, enables few-shot
prompting for the LLM judges; examples are selected for, and sent to, LLM
judges only, never to a decision-model judge, whose request is exactly what
it would be without them. An example shows its item's ground truth for the
criterion and, when
TYPE:
|
few_shot_config
|
Configuration for few-shot example selection (LLM judges only).
Under
TYPE:
|
system_prompt
|
Custom system prompt for binary criteria. Applies to LLM judges only (a decision model's request has no system prompt); in a mixed ensemble the LLM judges use it.
TYPE:
|
multi_choice_system_prompt
|
Custom system prompt for multi-choice criteria. Applies
to LLM judges only, like
TYPE:
|
length_penalty
|
Optional length penalty configuration.
TYPE:
|
normalize
|
If True, normalize score to [0, 1]. If False, return raw sum.
TYPE:
|
cannot_assess_config
|
Configuration for handling CANNOT_ASSESS verdicts.
TYPE:
|
shuffle_options
|
If True (default), randomize the order of multi-choice options presented to the LLM to mitigate position bias. Each judge/call sees a different random order, and responses are mapped back to original indices. Disable for deterministic behavior in tests. Applies to LLM judges only: a decision model's question offers the options in the rubric's order, and in a mixed ensemble the LLM judges shuffle as set here.
TYPE:
|
auto_na_option
|
If True (default), auto-inject a canonical NA / "cannot assess" option into any multi-choice criterion that lacks one, giving the judge a first-class abstain channel analogous to binary CANNOT_ASSESS. The injected option is appended at the end (highest index) so existing option indices are preserved. Set False for forced-choice classification (the judge must pick a scored option). Never strips an author-supplied NA option — author intent wins.
TYPE:
|
seed
|
Master seed for all non-LLM randomness (option shuffling, few-shot
example selection). Auto-generated when None so that randomness is always
pinned and reproducible. Inspect via the
TYPE:
|
binary_response_format
|
Pydantic model to use as the structured output schema
for binary criterion judgments. Must be a subclass of (or compatible with)
CriterionJudgment. If the model includes an
TYPE:
|
multi_choice_response_format
|
Pydantic model to use as the structured output
schema for multi-choice criterion judgments. Must be a subclass of (or
compatible with) MultiChoiceJudgment. If the model includes an
TYPE:
|
escalation
|
Makes the grader a confidence cascade (see the class docstring):
the escalation judges, all LLMs, vote only on the criteria the decision
model errored or abstained on or answered with a confidence below the
criterion's threshold. The grader's one judge (
TYPE:
|
llm_calls
|
How each LLM judge, a cascade's escalation judges included, is called
for an item:
TYPE:
|
llm_config
|
Deprecated alias of
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If neither judge_model_config nor judges is provided, if both are
provided, or if both judge_model_config and its deprecated alias
llm_config are provided; if escalation is given while the grader's judges
are not exactly one decision model, with a |
ImportError
|
If a judge is a decision model and the TypeSafe SDK is not
installed ( |
| WARNS | DESCRIPTION |
|---|---|
UserWarning
|
If system_prompt or multi_choice_system_prompt is not None,
shuffle_options is False, or llm_calls is |
FutureWarning
|
If a |
Source code in src/autorubric/graders/criterion_grader.py
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 | |
is_ensemble
property
¶
Whether this grader has several judges that each judge every criterion.
A cascade is not an ensemble: its escalation judges vote only on the criteria its decision model escalates.
judge_ids
property
¶
The judge_id of every judge, in order: the judges that judge every criterion
(judges, or the single "default" judge), then a cascade's escalation judges.
judge
async
¶
judge(to_grade: str, rubric: list[Criterion], query: str | None = None, reference_submission: str | None = None, *, guidelines: str | None = None) -> list[JudgeCriterionResults]
Judge all criteria with all judges (parallel across judges).
In a cascade the decision model judges every criterion first; then every escalation
judge judges the escalated criteria (_escalates: an error, an abstention, or a
confidence below EscalationConfig.threshold_for the criterion), all at once, and
none when nothing is escalated: in a call per escalated criterion, or, under
llm_calls="per_item", in one call about the whole rubric whose judgments of the
other criteria are discarded (_judge_escalated_criteria).
| PARAMETER | DESCRIPTION |
|---|---|
to_grade
|
The submission, as
TYPE:
|
rubric
|
The criteria.
TYPE:
|
query
|
Optional input/query that prompted the submission.
TYPE:
|
reference_submission
|
Optional exemplar response for grading context.
TYPE:
|
guidelines
|
Optional rubric guidelines (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[JudgeCriterionResults]
|
One |
list[JudgeCriterionResults]
|
decision model's ( |
list[JudgeCriterionResults]
|
( |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
| WARNS | DESCRIPTION |
|---|---|
UserWarning
|
Once per grader, when an |
Source code in src/autorubric/graders/criterion_grader.py
2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 | |
aggregate
async
¶
aggregate(judge_results: list[JudgeCriterionResults], *, normalize: bool = True) -> EnsembleEvaluationReport
Aggregate results from all judges into final report.
Handles both binary and multi-choice criteria: - Binary: Uses JudgeVote and _aggregate_votes() - Multi-choice: Uses MultiChoiceJudgeVote and _aggregate_multi_choice_votes()
In a cascade the escalated criteria are the ones the escalation judges have results
for (their results are None everywhere else). On those, the primary judge's vote
is marked superseded=True and the final verdict, reason and error come from the
votes that are not superseded, which are the escalation judges'; the report is
marked escalated=True. judge_scores holds each primary judge's score over its
own verdicts (superseded ones included) and None for each escalation judge, by
role: it votes only where the decision model escalated, even on an item where every
criterion escalated.
Source code in src/autorubric/graders/criterion_grader.py
2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 | |
Grader¶
Abstract base class for grader implementations.
Grader is generic in the report type it returns. CriterionGrader is a
Grader[EnsembleEvaluationReport], so a type checker types await rubric.grade(..., grader=grader)
as EnsembleEvaluationReport. A custom grader declares its own, for example
class MyGrader(Grader[EvaluationReport]); one that names no type still works.
Grader
¶
Grader(*, length_penalty: LengthPenalty | None = None, normalize: bool = True)
Bases: ABC, Generic[ReportT]
Base class for LLM-backed grading implementations.
All graders require an LLMConfig for the LLM client. Subclasses must implement judge() and aggregate() methods.
Rubric guidelines reach judge only if it accepts them: a judge with a
guidelines parameter that can be passed by keyword (e.g. keyword-only
guidelines: str | None = None) or with **kwargs receives them as
guidelines=. A judge with the abstract signature keeps working unchanged; the
grader then grades without the guidelines and warns once (see grade).
| PARAMETER | DESCRIPTION |
|---|---|
length_penalty
|
Optional configuration for penalizing overly long outputs. When provided, a penalty based on the token/word count is subtracted from the final score.
TYPE:
|
normalize
|
If True (default), scores are normalized to 0-1. If False, raw weighted sums are returned, which is useful for RL training scenarios.
TYPE:
|
Source code in src/autorubric/graders/base.py
judge
abstractmethod
async
¶
judge(to_grade: str, rubric: list[Criterion], query: str | None = None, reference_submission: str | None = None) -> Any
Collect raw judge results for the provided submission.
An implementation may also take the rubric's guidelines, as a guidelines
parameter that can be passed by keyword or through **kwargs; grade passes
them, when there are any, only to an implementation that does.
| PARAMETER | DESCRIPTION |
|---|---|
to_grade
|
The text to evaluate.
TYPE:
|
rubric
|
List of criteria to evaluate against.
TYPE:
|
query
|
Optional input/query that prompted the response.
TYPE:
|
reference_submission
|
Optional exemplar response for grading context.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
Raw judge results (format depends on implementation). |
Source code in src/autorubric/graders/base.py
aggregate
abstractmethod
async
¶
Transform judge results into an EvaluationReport.
| PARAMETER | DESCRIPTION |
|---|---|
judge_results
|
Raw results from judge().
TYPE:
|
normalize
|
If True, normalize score to 0-1. If False, return raw weighted sum.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReportT
|
EvaluationReport with score and optional per-criterion breakdown. |
Source code in src/autorubric/graders/base.py
grade
async
¶
grade(to_grade: ToGradeInput, rubric: list[Criterion], query: str | None = None, reference_submission: str | None = None, *, guidelines: str | None = None) -> ReportT
Grade the submission against the rubric.
This is the main entry point for the grader.
| PARAMETER | DESCRIPTION |
|---|---|
to_grade
|
The text to evaluate. Can be either:
- A string (optionally with
TYPE:
|
rubric
|
List of criteria to evaluate against.
TYPE:
|
query
|
Optional input/query that prompted the response.
TYPE:
|
reference_submission
|
Optional exemplar response for grading context.
TYPE:
|
guidelines
|
Optional rubric guidelines: free text that applies to every
criterion (
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ReportT
|
EvaluationReport with score and optional per-criterion breakdown. |
ReportT
|
If normalize=True (default), score is 0-1. If normalize=False, score is raw |
ReportT
|
weighted sum. If length_penalty was configured, the penalty is subtracted from |
ReportT
|
the score. The raw_score field contains the unnormalized weighted sum before |
ReportT
|
length penalty. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If |
| WARNS | DESCRIPTION |
|---|---|
UserWarning
|
" |
Source code in src/autorubric/graders/base.py
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 | |
JudgeSpec¶
Configuration for a single judge in an ensemble.
JudgeSpec
dataclass
¶
JudgeSpec(llm_config: LLMConfig | DecisionModelConfig, judge_id: str, weight: float = 1.0)
JudgeSpec(*, judge_model_config: LLMConfig | DecisionModelConfig, judge_id: str, weight: float = 1.0)
JudgeSpec(llm_config: Any = MISSING, judge_id: Any = MISSING, weight: float = 1.0, *, judge_model_config: Any = MISSING)
Specification for a single judge in an ensemble.
judge_model_config is the preferred keyword for the judge's configuration, and the
positional form is unchanged. llm_config= keeps working without a warning: it is
the name of the stored dataclass field, which is deliberately not renamed so that
dataclasses.fields/asdict/replace, the repr, equality and pickles stay
exactly as they were. dataclasses.replace therefore takes llm_config=, and
passing both judge_model_config= and llm_config= raises ValueError.
The configuration decides the judge's kind: an LLMConfig makes an LLM judge, which
is asked about each criterion in its own call (or about every criterion of an item in
one call, when the grader's llm_calls is "per_item"), and a
DecisionModelConfig makes a decision-model judge, which is asked about every
criterion of an item in one request. Both kinds mix freely in one ensemble.
| ATTRIBUTE | DESCRIPTION |
|---|---|
llm_config |
The judge's model configuration, an
TYPE:
|
judge_id |
Unique identifier for this judge (e.g., "gpt-4", "claude-sonnet").
TYPE:
|
weight |
Voting weight for weighted aggregation (default 1.0); a positive, finite number.
TYPE:
|
Example
gemini = LLMConfig(model="gemini/gemini-3-flash-preview") JudgeSpec(judge_model_config=gemini, judge_id="gemini") JudgeSpec(gemini, "gemini", weight=2.0) # positional form JudgeSpec(DecisionModelConfig(model="jev-latest"), "jev") # a decision model
Initialize from judge_model_config (or its stored-field name llm_config).
| PARAMETER | DESCRIPTION |
|---|---|
llm_config
|
The judge's model configuration, positionally or by the stored
field name. Mutually exclusive with
TYPE:
|
judge_id
|
Unique identifier for this judge.
TYPE:
|
weight
|
Voting weight for weighted aggregation (default 1.0); a positive, finite number.
TYPE:
|
judge_model_config
|
The judge's model configuration (preferred keyword).
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If both |
TypeError
|
If the configuration or |
Source code in src/autorubric/graders/criterion_grader.py
judge_model_config
property
writable
¶
judge_model_config: LLMConfig | DecisionModelConfig
The judge's model configuration (read/write alias of the llm_config field).
LLMCalls¶
How CriterionGrader calls each LLM judge for an item: "per_criterion" (the default) or "per_item".
LLMCalls
module-attribute
¶
How CriterionGrader calls each LLM judge for an item (its llm_calls).
- per_criterion: One call per criterion (the default).
- per_item: One call for the whole rubric: the submission and its context are sent once,
every criterion is listed under its id (
c0,c1, ...), and the answer holds one judgment per criterion (RubricJudgment).
A cascade's escalation judges are called the same way, only where the decision model
escalated: per_item makes one full-rubric call for an item with any escalated criterion.
replay_escalation and calibrate_escalation take it to know how an LLM run was
called, which sets how they estimate a cascade's cost and time from that run's.
A decision-model judge always makes one request per item, whatever this is. The name counts
LLM calls per item; it is unrelated to compute_metrics(per_item_metrics=...) and to
per-item rubrics.