Concepts / Using AI as a Judge

Using AI as a Judge

An AI can judge responses in three ways: scoring one response against the original question, checking a generated answer against reference data, or comparing two generated responses to choose the better one.

  • Programming

Two Tools, Two Relevance Scores

Suppose you run one AI-generated answer through two different evaluation tools, and both report a relevance score for it. It is natural to assume that the two numbers measure the same thing, so a higher number from one tool should mean the same kind of quality as a higher number from the other. This belief is common and understandable, and it is the belief this article corrects.

To see why it fails, we first need to understand what an AI judge is being asked to do. An AI judge is a model that you give some text and a question about that text, and it returns a verdict. The verdict might be a number on a scale, a True or False answer, or a choice between two candidates. What the judge can see, and what question it is answering, determines what kind of judgment comes back.

Three Ways a Judge Can Work

An AI can judge responses in three main ways. In the first, it evaluates a single response by itself, given the original question. In the second, it compares a generated response to reference data, such as a known good answer, and decides whether the two match. In the third, it compares one generated response against another and decides which is better, or predicts which one users will likely prefer.

The three approaches differ mainly in what the judge is given to look at. Scoring alone needs the question and the response. Reference checking needs the question, the response, and a reference answer. Pairwise comparison needs the question and two responses, and it does not need a reference answer at all, because the judge only has to see the two candidates side by side and pick one.

Question andresponseInput to the judgeQuestion, response,referenceInput to the judgeQuestion and tworesponsesInput to the judgeScore on a scaleAnswers: how good is thisresponse?True or FalseAnswers: does the responsematch the reference?Preferred responseAnswers: which one isbetter?
How do the inputs the judge receives and the question it answers differ across the three judging modes?

Tracing a Single-Response Judge Call

Scoring alone is the easiest mode to follow step by step, so start there. The judge still needs the original question, because a response can only be called good or bad relative to what was asked. The source's naive example prompt defines its scale directly inside the instruction: a score of 1 means very bad and a score of 5 means very good. The judge is then given the question and the answer and asked to fill in a score.

text
Notes on the code
  • The instruction line states the task and the scale together
  • [QUESTION] is a placeholder that the program replaces before sending
  • [ANSWER] is a placeholder for the response under review
  • The final line tells the judge what to return
Worked example

What the program does before the judge sees anything

A program has the question 'What is the capital of France?' and a response 'Paris is the capital of France.' It wants to score the response using the prompt above.

  1. 1
    Load the template

    The program starts with the prompt text, which still contains the bracketed placeholders [QUESTION] and [ANSWER].

  2. 2
    Replace the question placeholder

    Every [QUESTION] is swapped for the actual question text, so the prompt now reads Question: What is the capital of France?

  3. 3
    Replace the answer placeholder

    Every [ANSWER] is swapped for the response under review, so the prompt now contains Paris is the capital of France.

  4. 4
    Send the completed prompt

    The judge receives one finished block of text. It does not see the placeholders, only the filled-in content and the instructions.

  5. 5
    Read the returned number

    The judge's only task is to produce the number after Score. The program reads that number as the result.

Result

The judge returns a number between 1 and 5. Its meaning is whatever the prompt author defined in the scale line.

Before
Question: [QUESTION]
Answer: [ANSWER]
Score:

Template with placeholders, not yet sent

After

Question: What is the capital of France? Answer: Paris is the capital of France. Score:

Filled prompt, ready for the judge to return a score

Reading a Judge Prompt Piece by Piece

Every judge prompt, whatever tool produces it, has three parts you should be able to find: the judging question, the score scale, and the required return format. In the example above, the judging question is the instruction to rate the answer. The scale is written into that instruction as the range 1 to 5 with its two endpoints defined. The return format is the final line, which asks for only the number after Score.

Rate the answerJudging question1 to 5Score scale1 means very badScale meaning, low end[QUESTION]Placeholder filled by theprogram[ANSWER]Placeholder for theresponseReturn only thenumberRequired return formatScore:Where the judge writes itsvalue
Where in a judge prompt do the judging question, the score scale, and the required return format each appear?

Reference Answers and Pairwise Choices

The reference approach changes the question the judge answers. Instead of rating quality on a scale, the judge receives a reference answer, which is a response someone already considers correct, and it decides whether the generated answer is the same. The source describes this as an alternative to human-designed similarity measurements. Rather than writing a rule that measures how close two answers are, you hand that comparison to an AI judge. The output for this mode is True or False.

The pairwise approach compares two generated responses and decides which is better, or predicts which one users will likely prefer. The source names two uses. One is generating preference data for post-training alignment, which is discussed in Chapter 2 of the source. The other is ranking models using comparative evaluation, which the source covers in the following section. Because the judge only picks between two candidates, it produces a choice rather than an absolute score.

A general-purpose judge can also be asked to evaluate against criteria you choose. The source gives two examples. A developer building a roleplaying chatbot might ask whether a response is consistent with the role users want, such as whether it sounds like something Gandalf would say. A developer generating promotional product photos might ask for a rating from 1 to 5 of how trustworthy the product in the image looks. Each of these is a custom criterion written by the developer, not a standard one.

Why Built-In Criteria Differ Between Tools

Some AI tools come with built-in criteria, which are predefined names for common things to judge. The source lists examples of these as offered by some tools as of September 2024. Azure AI Studio and MLflow.metrics both include a criterion called relevance, and Ragas includes one called answer relevance. Because the source notes that these tools change, treat any such list as a snapshot rather than a permanent catalogue.

The shared label suggests a shared meaning, but the source is explicit that AI judge criteria are not standardized. Its direct illustration is that Azure AI Studio's relevance scores might be very different from MLflow's relevance scores. The reason is that a score depends on the judge's underlying model and on the prompt used to ask the question. Two tools can use the same word for a criterion while asking the judge to do different work.

RelevanceCriterion name in Azure AIStudioRelevanceCriterion name inMLflow.metricsAnswer relevanceCriterion name in RagasJudge model andpromptWhat the score actuallydepends onJudge model andpromptWhat the score actuallydepends onJudge model andpromptWhat the score actuallydepends on
How do two tools that both report a score differ in the criteria and rubric behind that score, so their numbers are not directly comparable?

Mistakes About What a Score Means

  • Common mistake

    Assuming a higher score from one tool means the same kind of quality as a higher score from another

    What it looks like

    Tool A reports relevance 4 and Tool B reports relevance 4 for the same answer, and you conclude the two tools agree.

    Why it fails

    The source says AI judge criteria are not standardized, and scores depend on each judge's underlying model and prompt. The matching numbers may come from different rubrics.

    Do this instead

    Compare scores only within one tool and one prompt setup, or check each tool's criterion definition before comparing.

  • Common mistake

    Reading a score without checking the scale

    What it looks like

    You see a score of 2 and assume it is poor, but the prompt defined 5 as the worst result.

    Why it fails

    The meaning of each number is whatever the prompt author defined, so the scale determines the interpretation.

    Do this instead

    Find the scale definition in the judge prompt before interpreting any number.

  • Common mistake

    Forgetting the original question in a single-response judge

    What it looks like

    You send only the answer to the judge and ask for a score.

    Why it fails

    The source states that a response can only be judged as good or bad relative to what was asked.

    Do this instead

    Include the original question in the prompt alongside the response.

  • Common mistake

    Expecting a reference answer in pairwise comparison

    What it looks like

    You add a reference answer to a pairwise judge prompt because you think the judge needs one.

    Why it fails

    The pairwise approach does not need a reference answer; the judge only has to pick between two candidates.

    Do this instead

    Provide the question and the two responses, and ask which one is better.

Predicting Before Comparing Scores

What do you think happens?

Two tools both report a relevance score of 4 for the same answer. Can you conclude that both tools measured the same thing?

  • Yes, the same label means the same measurement

  • No, the scores may depend on different judge models and prompts

Reveal answer
Answer:

No, the scores may depend on different judge models and prompts

The source states that AI judge criteria are not standardized and that scores depend on each judge's underlying model and prompt, so identical labels and numbers do not guarantee identical meaning.

EASY

A colleague gives you this judge prompt: 'Decide whether the answer below matches the reference answer. Respond with True or False. Question: [QUESTION] Reference: [REFERENCE] Answer: [ANSWER]'. Identify which of the three judging modes this is, what inputs the judge receives, and what it returns.

Hints
  • Look at whether the prompt supplies a reference answer.
  • Check what the return format asks for: a scale value, a True or False, or a choice between two candidates.

Key Takeaways

  • An AI judge can score one response against the original question, check a generated answer against reference data, or compare two generated responses to choose the better one.
  • Each judging mode differs in what the judge receives: scoring needs the question and response, reference checking adds a reference answer and returns True or False, and pairwise comparison needs two responses and no reference.
  • A judge prompt contains a judging question, a score scale, and a required return format, and the meaning of a score is whatever that prompt defines.
  • AI judge criteria are not standardized, so identical labels such as relevance can produce scores that cannot be compared directly across tools.

Related concepts

More concepts starting with U