Graders and rewards

A grader scores a finished model’s answers. A reward guides reinforcement training by scoring each sampled answer. Choose a cheap reward for frequent scoring and a grader that measures your task.

Choose a grader

Set the project’s grader, or pass --grader for one evaluation:

Specification Use for

json-label-match

Exact matching of JSON fields, such as intent labels; the default.

model:NS/NAME[:VERSION]

Judging free text with a registered model.

http:URL

Calling an evaluator you operate.

bundle:REFERENCE#MODULE[:FUNCTION]

Running a custom scoring function; FUNCTION defaults to compute_score.

For model comparisons, use the same dataset, grader and instructions. An unscored answer is excluded from the mean, so check unscored counts before choosing a model.

Set judge instructions

Use graderInstructions in a plan or --grader-instructions on an evaluation to state the rubric explicitly. Ask for JSON with a score between 0 and 1 and a one-sentence explanation.

Without explicit instructions, a trained judge uses its first training row’s system message. That row must be available and contain instructions. Other judges use the scored dataset’s system message with built-in grading instructions, or the built-in instructions alone.

A judge receives input, output and any parsed outputCalls, but no expected answer or expected calls. Write your rubric accordingly. Check the instructions and their source in training evaluations get or training runs get. Different instructions produce different grader keys, so their scores are compared separately.

Define a reward

Set config.reward.terms to weighted terms. Weights are not normalized. If you omit the reward, the run uses its grader.

reward:
  terms:
    - kind: rule
      weight: 1.0
      bundle: maths/scoring
      module: reward
    - kind: json-label-match
      weight: 0.2

Choose from these term kinds:

Kind Required settings and purpose

rule

bundle and module; optional function, default compute_score. Custom Python scoring.

json-label-match

No extra fields. Match JSON labels against the expected answer.

model

model registry reference; optional instructions. A judge provisioned for the run.

endpoint

url and the served model name. Use an existing endpoint for any served model.

grader

No extra fields. Reuse the run’s grader.

Budget for a reward model

A run can use one reward model. Its endpoint needs additional GPUs in the same training project’s quota. Check training endpoints info and training capacity before submitting. If demand exceeds quota or the shared pool, reduce the run’s devices or use another scorer.

Check Reward model instructions in training runs get. The endpoint’s Held by row identifies the run that keeps it; wait for that run or cancel it before deleting the endpoint.

Score tool calls

Tool-call mismatches score zero before your reward terms run. Matching calls with no expected text receive the sum of the term weights. Otherwise, reward terms score the text before the calls. See tool-call comparison.

Inspect CALL MATCH and CALLS with training runs rollouts. If the model cannot support expected tool calls, correct the rows or choose another base model.

Write a bundle function

A rule term and a bundle: grader use this contract:

def compute_score(data_source, solution_str, ground_truth, extra_info=None) -> float:
    # Return a score for solution_str.

Use solution_str for the completion and ground_truth for the expected text. Tool calls are in extra_info["outputCalls"] and extra_info["expectedCalls"], with name and either parsed arguments or invalid argumentsText. A grader also receives the prompt in extra_info["input"]. The text excludes calls.

Return a numeric score; each reward term applies its weight to it. A grader exception fails evaluation. See Scoring bundles to package and register the function.

For an HTTP grader, accept input, output and outputCalls; expected is empty. Return a score from 0 to 1 or a boolean ok or passed. Ensure Optimize can reach the evaluator before submitting work.

Reward format before correctness

If every answer receives zero, a correctness-only reward gives no learning signal. Add a format reward, such as parseable JSON, or start from an SFT adapter. The GSM8K example combines format and correctness.