Skip to main content
In the previous lesson, we could compare the requested products and quantities with the saved order. Our budget check needs a little more interpretation. When an answer mentions an expensive toy, is it recommending that toy or explaining why it doesn’t fit the budget? We can ask a model to make that decision using rules we provide. This is an LLM judge. Like any model, it can make mistakes, so we’ll check its decisions against your own reviews before relying on its scores.
A saved request and answer and a rubric go to an LLM judge, which returns a label and explanation. Compare that label with the independent human reference label afterward.Request and answer plus rubric go to the judge. Its verdict and a separate human reference label go to an agreement check.A saved request and answer and a rubric go to an LLM judge, which returns a label and explanation. Compare that label with the independent human reference label afterward.Request and answer plus rubric go to the judge. Its verdict and a separate human reference label go to an agreement check.

The judge receives the request, answer, and rubric. Your reference label is used afterward to check its decision.

Before you start

Use the Wonder Toys checkout from the previous lessons. You’ll need:
  • Python 3.11 and uv installed.
  • Phoenix running.
  • Your Anthropic API key in the app’s .env.local from Capture your first agent run, or set as ANTHROPIC_API_KEY in your environment.
We’ll use saved Wonder Toys answers from the lesson files. That lets us review the same answers ourselves and with the judge, without running the shopping agent again.

Step 1: Review and label example answers

Before we ask the judge to review an answer, let’s decide how we’d label it ourselves. You’ll review 4 saved answers now so that, later, we can see whether the judge reaches the same decisions. From the Wonder Toys repository root, make a working copy of the example file:
Open academy/evaluations/artifacts/budget-review.json. Each case is one shopper request paired with an answer. Read both fields:
  • request: What the shopper asked for, including the budget.
  • response: The answer you’re reviewing.
Then choose a label using the budget criteria:
  • pass: Recommendations meet the budget, or the answer reports no match without recommending an expensive alternative.
  • fail: It recommends an over-budget product without the shopper agreeing to change the budget.
  • needs_review: You can’t decide from the supplied evidence, such as a recommendation with no price.
The first case looks like this. We’ve shortened the answer here, so read the full version in your file before choosing a label:
Once you’ve decided, record your review in that case:
  • review_label: Replace null with "pass", "fail", or "needs_review".
  • review_source: Change "unreviewed" to "human" to record that you’ve reviewed the answer yourself.
Do the same for the other answers, then save the file without changing its other fields. Your decisions are the reference labels we’ll use to check the judge. Making them before you see its results keeps your review independent.

Step 2: Write a rubric the judge can apply

You’ve made your own decisions. Now let’s explain those same rules to the model in a rubric, the instructions it will use to review an answer. Open academy/evaluations/budget_rubric.txt. We’ve included a starting rubric so you can see how the budget criteria become instructions for the judge:
The prompt tells the judge what to check, how to decide, and what evidence to use:
  • Scope: The first two lines keep the review focused on budget compliance.
  • Labels: The pass, fail, and needs_review sections explain when to choose each decision.
  • Evidence: The closing instructions tell the model to use the supplied request and answer and explain its decision.
  • Placeholders: The script fills {{request}} and {{response}} with each saved case’s text.
Let’s practice making one rule clear. Find the fail rule beginning “Acknowledging the higher price” and rewrite it in your own words. It should still say that acknowledging the price or asking the shopper to spend more doesn’t excuse an over-budget recommendation without their agreement. Leave the other rules and both placeholders unchanged, then save the file. We’ll use your version in the next step to see how the judge interprets it.

Step 3: Run the judge

We now have your reviewed answers and the instructions you want the judge to follow. To compare its decisions with yours, we’ll use 2 provided files in academy/evaluations/:
  • budget_judge.py defines the judge. It connects your rubric to a model and returns a label with an explanation.
  • validate_judge.py runs the comparison. It calls that judge on your saved answers, compares its labels with yours, and saves the results in Phoenix.
Let’s first look at the judge defined in budget_judge.py. The code is already provided; the examples below explain how it works. Afterward, you’ll run validate_judge.py using the terminal command.
Phoenix’s ClassificationEvaluator combines the model (LLM), your rubric (prompt_template), and the labels it can choose (choices). Setting include_explanation=True also asks the judge to explain its decision. When validate_judge.py reviews an answer, it uses that judge to evaluate the case’s request and response, as shown below. Your review label stays out of this call:
We’ll start with 2 of the answers you reviewed. These are the ones we’ll use to improve the rubric. The other 2 are kept aside for a final check in Step 5. The file already marks these groups in its split field: Keep those split values as they are. The script creates these groups in Phoenix from the file. You don’t need to create them yourself; Phoenix’s dataset splits guide covers Python and UI setup if you want to use it with your own data. Now run validate_judge.py with the command below from the repository root. It uses the judge from budget_judge.py, and --split dev selects the 2 answers we’ll practice with:
Use your Phoenix address for --phoenix-url and your app’s environment file for --env-file if they differ from the example. Phoenix records this run as an experiment, where you can inspect the judge’s decisions alongside your reviews. Follow the Dataset link printed by the command to open budget-judge-review. Let’s look at those results next.

Step 4: Inspect decisions and disagreements

The judge has now reviewed the first 2 answers. Let’s compare its decisions with yours and see whether its explanations follow your rules:
  • Select the budget-judge-dev-... experiment you just ran.
  • Open an answer with View example run details.
  • Compare the judge’s label with your label in Reference Output, then read its explanation.
Phoenix experiment showing budget judge verdicts, reference review labels, and agreement results for practice cases.

This recorded practice run used the supplied rubric and assistant review labels. It demonstrates the comparison, not human validation.

You may notice that the screenshot shows a budget score of 0 and an agreement score of 1. They measure different things: The judge and reviewer agree that the answer fails the budget check, so both scores make sense. Still, read the explanation: a matching label doesn’t guarantee that the judge used the right evidence. When the judge’s decision differs from yours, go back to the request and answer. Look for:
  • Missed failure: You chose fail, but the judge chose pass.
  • False alarm: You chose pass, but the judge chose fail.
  • Uncertain decision: Either review used needs_review; check whether the evidence supports a decision.
Sometimes the instructions need work; sometimes your own review needs correcting. Use the evidence to decide, rather than changing your label to match the judge. Then run the comparison again:
  • If you changed the rubric, rerun the Step 3 command.
  • If you changed an answer or your review label, add --dataset-name budget-judge-review-v2 to the Step 3 and Step 5 commands. That keeps the revised reviews in a separate dataset.

Step 5: Check the judge on other answers

Once you’re happy with how the judge handles the practice answers, let’s try the other 2. You already reviewed them in Step 1, but we haven’t used their results to improve the rubric:
  • recorded-budget-1: The saved answer to the shopper asking for toys under $1.
  • practice-no-match: A practice answer we wrote to show what happens when no toy meets the budget.
These are the test cases, marked "split": "test" in your file. Comparing the judge with your human labels here helps us check whether the instructions work beyond the answers we practiced with. Keep the model and rubric as they are, then run the command with --split test to select those 2 answers:
Use the same Phoenix address, environment file, and any --dataset-name you used for the earlier run. When the command finishes:
  • Follow the printed Dataset link and open budget-judge-test-....
  • Open each answer and compare the judge’s label with your human label in Reference Output.
  • Read the explanation to see whether the judge applied your rules correctly.
If you revise the rubric after seeing these results, these answers have helped shape it too. You’ll need new answers you’ve reviewed yourself for the next final check. By the end of this exercise, you should be able to explain where the judge agrees with you, where it doesn’t, and whether its reasons follow your rules. Keep your rubric and review file so you can repeat the comparison after future changes. These 4 answers let you practice the workflow. Before relying on the judge, try a larger set of independently reviewed answers and decide how many missed failures and false alarms your use case can tolerate.
Open PXI and paste your rubric, then ask:
PXI suggests development cases for the price boundary, a product ruled out without further recommendations, and a recommendation with a missing price.

PXI suggests development cases after reviewing the rubric and clarifying its suggestions.

If a suggestion helps you clarify a rule, try it as another practice answer and review it yourself first. Keep a separate set of answers for your next final check.
We’ve been checking whether the judge follows your rules. Next, let’s use what we’ve learned to improve the agent’s answers. In Compare prompt changes in Playground, you’ll try a budget instruction on one captured model call before testing the full agent.