Skip to main content

Grader description

A RangeJudgeGrader evaluates completions on a numeric scale instead of binary pass/fail. This is useful when quality exists on a spectrum and you want fine-grained feedback about model behavior. Unlike a BinaryJudgeGrader (which scores 0.0 or 1.0), a RangeJudgeGrader returns scores across a range (e.g., 1-5). The grader:
  • Accepts criteria describing what each score level means
  • Uses evaluation steps to guide the judge’s reasoning
  • Takes few-shot examples showing different score levels
  • Returns a normalized score (0-1 by default) based on logprob-weighted scoring
  • Optionally uses subrange expectations to help the judge understand the rubric

Pseudocode

This is the pseudocode for a range-based judge grader:
  • Define explicit criteria describing what each score level means
  • Provide numbered evaluation steps the judge should follow
  • Describe what each score range means using SubrangeExpectations (textual descriptions, not numeric mappings)
  • Include 2-3 few-shot examples showing what different score levels look like
  • Pass all components to RangeJudgeGrader with an InferenceModel
  • The LLM judge scores the completion on the numeric range (e.g., 1-5)
  • Return a normalized grade (0-1 by default)

Implementation

Defining the criteria and evaluation steps

Start by writing clear criteria that describe what each score level means. The rubric should make the boundaries explicit—what distinguishes a 1 from a 2, or a 3 from a 4. Then list numbered evaluation steps that guide the judge’s reasoning. These steps should be concrete and actionable.

SubrangeExpectations: textual descriptions of score ranges

SubrangeExpectations is a NamedTuple with subrange (a tuple of min and max score) and expectation (a text description of what that score range means). These help the judge understand the rubric by describing the expected quality level for each score range. This is different from reward mapping—these are purely textual descriptions to guide the LLM judge.

Few-shot examples for the judge

Few-shot examples teach the judge what each score looks like by showing real examples. Each shot is a RangeJudgeShot with:
  • thread: A StringThread with the prompt and completion
  • reasoning: The judge’s reasoning for that score
  • score: The gold-standard score for that example

Validation

We can validate all the setup objects and demonstrate score normalization without a live judge model.

Creating the RangeJudgeGrader

The RangeJudgeGrader constructor requires:
  • grader_key: Unique identifier for this grader
  • model: An InferenceModel (required)
  • criteria: Description of the scoring rubric
  • score_range: Tuple of (min, max) for the numeric scale (default: (1, 5))
  • evaluation_steps: List of strings describing evaluation steps (optional; auto-generated if None)
  • subrange_expectations: List of SubrangeExpectations describing what each score range means (optional)
  • shots: List of RangeJudgeShot few-shot examples (optional)
  • normalize_score: If True (default), scores are normalized to 0-1 range
By default, scores are normalized: score 1 → 0.0, score 5 → 1.0.

How scoring works

The RangeJudgeGrader uses logprob-weighted scoring internally:
  1. The LLM judge produces a score (1-5) with reasoning
  2. The grader computes logprobs for each possible score (1, 2, 3, 4, 5)
  3. These logprobs are converted to probabilities
  4. A weighted average is computed: sum(score_i * prob_i for each score)
  5. If normalize_score=True, the weighted score is mapped to [0, 1]:
    • Raw score 1 → 0.0
    • Raw score 5 → 1.0
    • Linear interpolation in between
This design captures the judge’s uncertainty about borderline cases and prevents sharp boundaries.

RangeJudgeGrader vs BinaryJudgeGrader

Use BinaryJudgeGrader when you have a clear PASS/FAIL threshold (e.g., “Does the output contain valid JSON?”). Use RangeJudgeGrader when quality exists on a spectrum (e.g., “How well does this summary capture the key points?”).

Key takeaways

  1. RangeJudgeGrader for spectrum-based quality - When binary PASS/FAIL is too coarse, numeric ranges capture degrees of quality
  2. Write explicit criteria - Define what each score level means so the judge has clear guidance
  3. Include numbered evaluation steps - Structured steps guide the judge’s reasoning process
  4. Few-shot examples are essential - Show examples at low, medium, and high scores so the judge understands the full scale
  5. Normalization is on by default - Scores are mapped to [0, 1] by default for consistency with other graders