﻿---
title: Judgement sets
description: A judgement set is a YAML file, conventionally named *.judgements.yaml. It holds queries and, for each, the documents a person (or a reviewed LLM) judged,...
url: https://docs-v3-preview.elastic.dev/concepts/judgements
---

# Judgement sets
A judgement set is a YAML file, conventionally named `*.judgements.yaml`. It holds queries and, for each, the documents a
person (or a reviewed LLM) judged, with a grade.
```yaml
name: fruit
description: A tiny example set.
k: 5                        
threshold: 1                
gates:                      
  candidate: {ndcg@5: 0.7, success@1: 0.5}
queries:
  - q: yellow fruit
    id: q1                  
    intent: wants fruits that are yellow  
    tags: [colour]          
    ratings: {/banana: 3, /lemon: 2, /apple: 0}  
  - q: citrus
    relevant: [/lemon, /orange]              
```


## Grades

Grades are integers from 0 up; 0 is irrelevant and 3 is a perfect answer in the examples on these pages. A document counts as
relevant when its grade is at least `threshold`. [nDCG](https://docs-v3-preview.elastic.dev/concepts/metrics) uses the grades themselves, so a grade-3 document is worth much more than a grade-1 one. The other metrics
only need relevant or not.
`relevant: [...]` is shorthand for a list of documents at the threshold grade, for when you only know which documents are right.

## Query ids

`id` is optional and defaults to the query text. Give a query an id when:
- the query text changes but it is the same query (so comparisons stay paired across runs);
- a [TREC run file](https://docs-v3-preview.elastic.dev/reference/formats) keys its rows by topic id: the run's `q1` is matched to the set's `id: q1`;
- two queries have the same text but different intents (ids must be unique, and judy rejects a duplicate).


## Intent

`intent` says in a sentence what the searcher wants. The [LLM judge](https://docs-v3-preview.elastic.dev/llm/judging) reads it next to the query. It helps
with ambiguous queries ("jaguar").

## Tags

Every query can carry `tags`. Scorecards and results files report each metric per tag, next to the overall number. judy adds two groups itself. One is
`words:1`, `words:2` and `words:3+`, by query length. The other is `mode:lexical`, `mode:semantic` or `mode:hybrid`, by how
the query was answered (see [modes](https://docs-v3-preview.elastic.dev/concepts/modes)).

## Gates

`gates` maps a target name to minimum metric values. `judy run` prints each gate as `ok` or `FAIL`. It exits with code 1 when
a gate fails:
```text
gates
  FAIL ndcg@5 0.638 < 0.800
  FAIL success@1 0.333 < 0.500
```

See [In CI](https://docs-v3-preview.elastic.dev/workflow/ci).

## Where sets come from

- **By hand**, in YAML.
- **`judy import wands`** converts the WANDS dataset (Exact 3, Partial 1, Irrelevant 0). A product labelled twice for one query
  keeps the higher grade, and judy says how many that was.
- **`judy import trec`** reads TREC qrels, **`judy import docs-builder`** and **`judy import website-search`** read older judgement
  lists.
- **`judy synthesize`** has an LLM write queries for the documents of a corpus: each document is the grade-3 answer to its own
  queries. It is quick, and it flatters retrieval, because the queries come from the documents' own words. Use it for a first
  look, then replace it with real judgements.
- **`judy judge`** adds LLM labels for documents nobody judged (see [the judge](https://docs-v3-preview.elastic.dev/llm/judging)). They live in
  `{set}.llm.yaml`, never in your set.

`judy export trec` writes topics and qrels for `trec_eval` or `ranx`; `judy export run` writes a results file's run.

## Document ids

A hit and a judgement meet by id, so the id your target returns must be the id your judgements use. For URLs and paths, the
`docs.normalize` setting in `judy.yaml` makes both sides comparable: `lowercase`, `trailing-slash` and `strip-host`. They are
applied to the set and to the results alike.