Skip to main content
For the complete documentation index for agents and LLMs, see llms.txt.

LLM-as-a-Judge MetricsBeta

Beta
This is coming — this page describes a feature that's still being rolled out and may not be available to you yet.

An LLM judge rates a session against criteria you write in plain language.


You write the criteria, choose the answers the model can give, and pick the model, without writing code. The LLM-as-a-judge form writes the metric's code for you. You can switch to the code view to see it, and edit it by hand if you need more control. An LLM judge can be wrong, so check its rationales.

How an LLM Judge Works​

Knowing how an LLM judge works helps you understand why some sessions end in error for a metric, and how to write criteria the judge can finish. The judge works in these steps, in order:

  • It reads the parts of the session it needs, such as turns, retrieved documents, and tool calls.
  • It sends one report that answers every criterion at once. If the report is incomplete or in the wrong shape, it's sent back and the judge can correct it.
  • If the judge hasn't sent a valid report when its limited reading steps run out, it gets two more steps in which it can only report. It answers from what it has read and uses not applicable with a reason where it can't answer.
  • If it still doesn't report, the session ends in error for that metric.

A specific criterion with few questions to answer helps the judge finish. For how to fix these errors, see Fix Sessions Where the Judge Didn't Conclude.

What an LLM Judge Reads​

When an LLM judge reads a turn, it sees the turn's inputs by name, in the form component.socket, with chat input cut down to the turn's new messages. It also sees the turn's answer and its intermediate replies separately. This way, a judge doesn't mistake an Agent's "Let me look that up." for the answer. To judge whether the answer is faithful, the judge can also read the context the answering LLM was given.

Compare a Judge with a Test Case's Expected Data​

To check an answer against the expected one, a rubric in the LLM-as-a-judge form can compare the conversation with the expected data of a Dataset test case. Add a reference to an expected column in the rubric text, in the form {expected.<column>}. For example: Does the answer state {expected.answer}?

To add a reference, use the Insert expected column field under the rubric:

  • Click the field. It suggests the expected columns that the Datasets in your workspace hold. The columns load when you click the field.
  • Select a suggestion, or type any other column name and press Enter. A rubric is written once and run against many Datasets, so you can reference a column that no Dataset holds yet.
  • The form appends {expected.<column>} to the end of the rubric. A column name can't contain braces, so the form leaves them out of a name you type and doesn't suggest columns whose names hold them. Other text in braces stays plain text in the rubric.

A line under a rubric that references expected columns names the columns it compares with. It also tells you that the metric isn't applicable to conversations without a test case, or whose test case lacks the column. The judge returns not applicable for those sessions, so they're counted separately and don't distort your results.

The form writes code that gives the judge access to the test case only when a rubric references an expected column. Judges that reference no column produce the same code as before, so saving one in the form doesn't create a new metric version.

A judge opens in the form only when its code matches what the form would write: it either receives the test case and passes it to the judge, or does neither, and that agrees with whether a rubric references a column. Any other judge opens in the code view.

To try a judge that compares with expected data, pick a test case in the try bench. The test case picker appears as soon as a rubric references an expected column, even before you pick a model.