Measure, judge and improve your Elasticsearch search.
judy scores your search against queries that people have rated. It asks an LLM to rate the results nobody has rated. It tests every change before you ship it, and it tells you if the change is real. It runs on your laptop and in CI, as one native binary.
$ judy compare lexical hybrid --set wands.judgements.yaml
ran 480 queries against lexical in 12.1s
ran 480 queries against hybrid in 15.4s
ndcg@10: lexical -> hybrid over 479 paired queries
mean 0.594 -> 0.661 (+0.067)
244 better, 146 same, 89 worse p = 0.0001 (a real difference at 5%)
…
in plain words
hybrid is better than lexical, and the difference is unlikely to be chance (p = 0.0001). On
average ndcg@10 goes up by 0.067 (11% more than the baseline's 0.594).
244 of 479 queries improved (51%), 89 got worse (19%) and 146 did not change.
A better average can hide queries that got worse, and here 19% did. Read 'most regressed' before
you ship: if those are queries your users care about, the average is not the whole story.
That is a real run on a public example dataset (WANDS, 480 rated queries) against an Elasticsearch
Serverless project. judy works with any index, alias or data stream: WANDS only lets you try it in minutes. Every report ends with
an in plain words block that says what the numbers mean. --no-explain leaves it out.
judy is built for Elasticsearch: it sends Query DSL, ES|QL or your own query-building code. It also scores any search API over HTTP, and the run files that other tools write (TREC format).
New to the terms? Read the glossary and the metrics guide.
- An LLM as the judge, so you do not have to rate every result. Semantic search returns documents that nobody rated. An
unrated result counts as not relevant.
judy judgehas a model label them from the query and the document text alone. It works with the Elastic Inference Service, Anthropic, and any OpenAI-compatible endpoint. Labels are cached, never overwrite a human rating, and you can approve them withjudy review. See LLM as a judge. - A loop an agent can run.
judy diagnoseexplains why the worst queries fail, with the index mapping in view.judy suggesttries its ideas against your judgements, including queries the model never saw. Judge, diagnose, suggest and a gated compare make one scriptable loop: the model proposes, judy decides, the same way every time. - Numbers you can trust. judy reports nDCG, MRR, ERR, Success@k, Precision@k and Recall@k. It adds Judged@k, which tells
you how much of your top results anyone has rated. On the validation set, judy's mean nDCG@5 is
0.9237767155100333and Elasticsearch's own_rank_evalsays0.923776715535. - Differences, not just scores. Every comparison is paired per query, lists the most improved and most regressed queries, and
runs a randomization test. A gain over three queries says so:
p = 0.25 (not distinguishable from noise). - Your search, however you build it. Use Query DSL templates, ES|QL, or your own query-building code. judy runs that code once per query, so a shell script can try it. If your application builds queries dynamically, judy measures the queries your application really sends.
- Knows how each query was answered. Lexical, semantic or hybrid is worked out per query.
judy modesshows whether a router, the logic that picks a mode per query, is worth having. - Built for CI. Gates per target, exit codes that mean something, a markdown summary for the GitHub step summary, and
compare --max-regression. - One binary, no runtime. About 9 MB, native AOT. No Python environment, no notebook, no service to run.
judy is pre-release: it is not on NuGet yet. Until the first release, build it with dotnet build -c Release src/Nullean.Judy.Cli
(.NET 11 SDK). The rest of this page assumes judy is on your PATH.
A judgement set says which results are good for which query. A target is whatever answers the queries. Point judy at your index, describe how you search it, and write down some queries:
# judy.yaml
clusters:
live: {url: "env:ES_URL", api_key: "env:ES_API_KEY"}
targets:
current: {dsl: {cluster: live, index: my-index, file: queries/current.json}} # an index, an alias or a data stream
docs: {id: url, title: title, text: [summary, body]} # how a hit becomes an id and text
judge: {provider: eis, cluster: live} # or anthropic, or openai (see below)The target is a Query DSL body with {{query}} and {{size}} placeholders. Secrets are env: references, so the file can be
committed. A judgement set can start from nothing. judy synthesize has an LLM write queries for your documents, and judy judge
labels what comes back (see LLM as a judge). Or write it by hand, see Judgement sets.
judy run my.judgements.yaml --target currentWANDS is Wayfair's product search dataset (MIT licence): 480 queries, 42,994 products and 231,873 human judgements. It is an example, chosen because the answers are not obvious. One command downloads it at a pinned commit, writes the judgement set, creates an index and loads the products:
export ES_URL=https://… ES_API_KEY=…
judy import wands --url env:ES_URL --api-key env:ES_API_KEYdownloading WANDS at 3b74dcf from github.com/wayfair/WANDS
wands.judgements.yaml: 480 queries, 231873 judgements
1575 products were labelled twice for the same query (16 with different labels; the higher grade was kept)
loading 42994 products into judy-wands with a semantic_text field, which runs inference over every product (a few minutes)
4500/42994
…
judy-wands: 42994 products
That took 2 minutes 45 seconds here.
Options: --cluster live uses a cluster from judy.yaml. --no-semantic leaves out the semantic_text field and its inference
cost. --index names the index, and --commit picks another revision. --recreate replaces an existing index. Without it,
judy refuses to touch one. Run judy import wands without --url or --cluster to write the judgement set
only.
Then describe the search. Write queries/lexical.json:
mkdir queries && cat > queries/lexical.json <<'EOF'
{"size": "{{size}}",
"_source": ["product_id", "product_name", "product_class", "product_description"],
"query": {"multi_match": {"query": "{{query}}",
"fields": ["product_name^3", "product_class^2", "category_hierarchy", "product_description", "product_features"]}}}
EOF
cat > judy.yaml <<'EOF'
clusters:
live: {url: "env:ES_URL", api_key: "env:ES_API_KEY"}
targets:
lexical: {dsl: {cluster: live, index: judy-wands, file: queries/lexical.json}}
docs: {id: product_id, title: product_name, text: [product_description]}
EOFAnd score it:
$ judy run wands.judgements.yaml --target lexical
ran 480 queries against lexical in 12.4s
set wands target lexical labels human
queries 480 (479 scorable)
all
success@1 0.818
success@3 0.900
mrr@10 0.859
ndcg@10 0.594
recall@10 0.058
err@10 0.539
judged@10 0.865
tag words:1
success@1 0.957
success@3 0.957
mrr@10 0.957
ndcg@10 0.900
…
tag words:3+
success@1 0.810
success@3 0.905
mrr@10 0.858
ndcg@10 0.567
…
misses: no relevant result in the top 10 (32)
beds that have leds
bathroom vanity knobs
non slip shower floor tile
medium size chandelier
nautical platters
palram harmony greenhouses
low profile loveseat recliner
wishbone chair
star wars rug
promo codes or discounts
... and 22 more
in plain words
For 82% of queries the first result is relevant (success@1), and 90% have a relevant result in the
first three (success@3).
ndcg@10 is 0.594: the top 10 earns 59% of what a perfect ordering of the judged documents would
(1.0 is perfect). Use it to compare against a baseline: what is achievable depends on your data.
mrr@10 is 0.859: the first relevant result sits at roughly rank 1.2.
recall@10 is 0.058: the top 10 holds 6% of all the documents judged relevant, which is low when
many documents answer each query, however good the ranking.
87% of the top 10 results have a judgement (mostly covered). Results nobody judged count as not
relevant, so scores are a floor.
32 of 479 queries (7%) returned nothing relevant in the top 10. These are the clearest failures:
start with the misses listed above.
By words, words:3+ scores lowest on ndcg@10 (0.567) and words:1 highest (0.900): look at words:3+
first.
wrote wands.lexical.results.yaml
What you get from one command:
- Headline metrics. Seven numbers, so a change that trades one for another is visible.
- Automatic groups. judy tags every query with its length (
words:1,words:2,words:3+) and how it was answered (mode:lexical). Here a one-word query scores 0.900 and a three-word query 0.567: the long queries are where this search is weak. - Misses. The 32 queries with nothing relevant in the top ten, named. Start there.
- In plain words. The
in plain wordsblock says what the numbers mean, for someone who does not know what nDCG is. It tells you how many queries get a relevant first result, how good the order is, and whether the judgements cover the results. It says where to look first. It is added after the numbers and changes none of them. - A results file.
wands.lexical.results.yamlholds every query's metrics and ranked ids, so later comparisons need no cluster.wands.lexical.requests.jsonlholds the exact request sent for each query.
judged@10 0.865 says 86.5% of what the search returned in the top ten has a judgement. The rest counts as not relevant. Watch this number, especially for semantic search, which surfaces documents that nobody
rated (see LLM as a judge).
Add a hybrid target, which fuses the lexical and semantic results with rrf:
cat > queries/hybrid.json <<'EOF'
{"size": "{{size}}",
"_source": ["product_id", "product_name", "product_class", "product_description"],
"retriever": {"rrf": {"rank_window_size": 50, "retrievers": [
{"standard": {"query": {"multi_match": {"query": "{{query}}",
"fields": ["product_name^3", "product_class^2", "category_hierarchy", "product_description", "product_features"]}}}},
{"standard": {"query": {"semantic": {"field": "product_semantic", "query": "{{query}}"}}}}]}}}
EOFwith hybrid: {dsl: {cluster: live, index: judy-wands, file: queries/hybrid.json}} under targets:. Then:
$ judy compare lexical hybrid --set wands.judgements.yaml
ran 480 queries against lexical in 12.1s
ran 480 queries against hybrid in 15.4s
ndcg@10: lexical -> hybrid over 479 paired queries
mean 0.594 -> 0.661 (+0.067)
244 better, 146 same, 89 worse p = 0.0001 (a real difference at 5%)
479 queries were sent a different search request
1 queries could not be paired
most improved
+0.775 0.000 -> 0.775 donaldson teak couch
+0.716 0.220 -> 0.936 black fluffy stool
+0.716 0.284 -> 1.000 china clock
+0.676 0.202 -> 0.878 turquoise pillows
+0.631 0.369 -> 1.000 cake cutlery
most regressed
-0.721 0.950 -> 0.228 board game storage cabinet
-0.642 0.706 -> 0.064 gurney slade 56
-0.569 1.000 -> 0.431 pennfield playhouse
-0.515 0.841 -> 0.326 mystic swivel
-0.507 0.840 -> 0.333 itchington butterfly
in plain words
hybrid is better than lexical, and the difference is unlikely to be chance (p = 0.0001). On
average ndcg@10 goes up by 0.067 (11% more than the baseline's 0.594).
244 of 479 queries improved (51%), 89 got worse (19%) and 146 did not change.
A better average can hide queries that got worse, and here 19% did. Read 'most regressed' before
you ship: if those are queries your users care about, the average is not the whole story.
The mean says hybrid is better. The counts say it is not better everywhere: 89 queries got worse, one of them by 0.72. judy shows you both, and the five worst regressions are a ready list to look at before you ship.
Either side can be a target to run now (needs --set) or an earlier results file. name:key=value runs a target with a parameter
changed ({{params.key}} in the template), so a boost sweep is a loop of compares.
Judging every result by hand does not scale, and a judgement set only knows what someone judged. Semantic search surfaces
documents nobody rated, and unjudged counts as not relevant, so the better the search the more it is punished. judy judge has an
LLM label the unjudged documents a target returns. First count the cost:
$ judy judge wands.judgements.yaml --target hybrid --dry-run
ran 480 queries against hybrid in 15.8s
557 documents need a label, which takes up to 179 calls to .anthropic-claude-4.5-haiku-chat_completion. Nothing was sent.
Then run it, with a cap on calls if you like:
$ judy judge wands.judgements.yaml --target hybrid --max-calls 60
ran 480 queries against hybrid in 15.7s
labelled 178 of 557 documents with .anthropic-claude-4.5-haiku-chat_completion (v1); wrote wands.llm.yaml
…
Review them with 'judy review'; until approved they count only with --labels all, and a human rating always wins.
(When the cap is reached, judy says how many queries were left unjudged. It is not a failure.) Those 178 labels moved hybrid from judged@10 0.886 to 0.923, and ndcg@10 from 0.661 to 0.666. judy prints the
human-only number beside each metric, so you see the effect:
ndcg@10 0.666 (human labels only: 0.661)
judged@10 0.923 (human labels only: 0.886)
What makes it a fair judge:
- It sees the query, an optional
intentand each document's text. It never sees the search request, the scores or the ranks, so it cannot be swayed by how the engine did. - Labels are a cache, in
wands.llm.yaml.--labels humanignores them, andjudy reviewlets you approve, reject or skip each one. An approved label becomes a human rating, and a human rating always wins. - Three providers. Use
judge: {provider: eis, cluster: live, inference_id: …}for the Elastic Inference Service (the run above). Use{provider: anthropic}withANTHROPIC_API_KEYfor Anthropic. Use{provider: openai, base_url: …, model: …}for any OpenAI-compatible endpoint. See LLM as a judge in the docs.
They both use a model, and they answer different questions, so they see different things.
judy judge |
judy diagnose (and suggest) |
|
|---|---|---|
| Question | Is this document relevant to this query? | Why does this query rank its relevant documents badly, and what should I change? |
| Sees | the query, the intent, the document text | the query, the request judy sent, what came back, the relevant documents that did not, and the index mapping |
| Never sees | the request, the scores, the ranks | |
| Produces | grades, cached in {set}.llm.yaml |
a written diagnosis, or variants of your request that judy runs and measures |
| Changes your scores | yes, when labels are included | never |
The judge must not know how the engine answered, or it would grade its own homework. The advisor must know, because its job is the engine's behaviour. Use the judge first, so the scores are fair, then diagnose the worst queries.
Judge, diagnose and suggest are three steps of one loop, and the loop is built to be driven by a script or an agent:
The model does the creative part: it labels, explains and proposes. judy does the part that has to be trusted. It runs every proposal against your judgements, on queries the model never saw, and answers with a number, a p-value and an exit code. A bad idea cannot get through by sounding good.
# 1-2. measure, then label what nobody rated
judy run wands.judgements.yaml --target lexical
judy judge wands.judgements.yaml --target lexical --max-calls 100
# 3-4. why do the worst queries fail? what would help?
judy diagnose wands.judgements.yaml --target lexical
judy suggest wands.judgements.yaml --target lexical --variants 3
# 5. add the best variant as a target in judy.yaml, then gate it
judy compare lexical candidate --set wands.judgements.yaml --max-regression 0.01 && adopt || discard # exit 0 or 1- Deterministic where it counts. The proposals vary from run to run. The measurement does not: the same requests against the same judgements give the same numbers and the same p-value, from a fixed seed.
- Scriptable end to end. Every step has
--format json,--dry-runor--max-calls, and an exit code. - Proposals are files, not edits. Your configuration changes only when your script or agent copies a variant over a template. It does that after the gate says yes.
- The model sees only what it needs. The judge never sees the request. The advisors do, and the index mapping, but never the held-out queries.
That is a real judy suggest run on WANDS. The idea that sounded sensible lost on queries the model never saw. The idea that
used the unused semantic_text field won on both halves. Judged queries wear out, though: a holdout you reuse every round stops being
held out, so bring fresh judged queries now and then.
Most real search is not one static template. The application looks at the query and decides. A short query goes lexical, and a long one goes semantic. A filter depends on the region, and a boost depends on the tenant. A static template cannot measure that, and a copy of the logic in a test drifts from production.
A builder target runs your query-building code, once per query by default. judy starts the command and writes the
request as JSON to its standard input and environment (JUDY_QUERY, JUDY_SIZE, …). It reads the answer from the first line
of standard output, and the process exits. That makes it easy to script, and an agent can try a query builder in a plain bash script before
building out the real search. For a builder that is expensive to start, set lifetime: process and judy keeps one process and
talks to it in JSON lines.
echo '{"v":1,"query":"salon chair","size":10,"params":{}}' | ./router.shAny language works: this builder is a dozen lines of jq.
cat > router.sh <<'EOF'
#!/bin/bash
# semantic from MIN_WORDS words (default 3), lexical otherwise; it states its mode
SRC='["product_id","product_name","product_class","product_description"]'
while IFS= read -r line; do
echo "$line" | jq -c --argjson min "${MIN_WORDS:-3}" --argjson src "$SRC" '
(.query | split(" ") | map(select(length > 0)) | length) as $words
| if $words >= $min
then {id: .id, mode: "semantic", dsl: {size: .size, _source: $src, query: {semantic: {field: "product_semantic", query: .query}}}}
else {id: .id, mode: "lexical", dsl: {size: .size, _source: $src, query: {multi_match: {query: .query, fields: ["product_name^3","product_class^2","category_hierarchy","product_description","product_features"]}}}}
end'
done
EOF
chmod +x router.shtargets:
router: {builder: {cluster: live, index: judy-wands, command: [./router.sh]}}The same builder, asked about a short and a long query (real output, with the field lists abbreviated):
{"id":1,"mode":"lexical","dsl":{"size":10,"_source":[…],"query":{"multi_match":{"query":"salon chair","fields":["product_name^3", …]}}}}
{"id":2,"mode":"semantic","dsl":{"size":10,"_source":[…],"query":{"semantic":{"field":"product_semantic","query":"low profile loveseat recliner"}}}}
mode is optional and wins over what judy infers from the request. The command is resolved against the target's folder. A builder
can also return "index" per query, or {"esql": "...", "params": [...]}, or {"error": "why"}. See
dynamic query building for the full protocol.
A router is the logic that decides, for each query, how to search it: lexical (matching words), semantic (matching meaning) or
hybrid (both, fused). "Only go semantic above two words" is a router, and a plausible one. judy modes runs each way of searching on its own, then your router. It says whether the router beats always using the best
single mode. Run on WANDS, with
labels that include the LLM's (excerpt):
$ judy modes wands.judgements.yaml --target lexical --target semantic --target hybrid --router router
ndcg@10 over 479 queries
lexical 0.595 (lexical)
semantic 0.641 (semantic)
hybrid 0.666 (hybrid)
oracle (best per query) 0.733
router (router) 0.631
router vs oracle: -0.102 (perfect routing would add 0.102)
router vs best single target (hybrid): -0.036
routed by mode:
lexical 131 queries 0.669
semantic 348 queries 0.617
by query length (best target, and the oracle for that group)
words:1 23 queries lexical 0.906 semantic 0.819 hybrid 0.922* router 0.906 oracle 0.929
words:2 108 queries lexical 0.619 semantic 0.681 hybrid 0.692* router 0.619 oracle 0.779
words:3+ 348 queries lexical 0.567 semantic 0.617 hybrid 0.642* router 0.617 oracle 0.705
in plain words
On its own, hybrid is the best way to search here (0.666 ndcg@10) and lexical the weakest (0.595).
A router is the logic that picks lexical, semantic or hybrid for each query; the numbers above
say whether one is worth having.
If every query used whichever way scored best for it (the oracle, 0.733), the score would be
+0.066 above always using hybrid. That is the most any rule for choosing could add.
Your router (router) scores 0.631, 0.036 below always using hybrid: on this data routing does not
pay off. Running hybrid for every query is simpler and scores higher.
It leaves 0.102 of the oracle's potential on the table, so a better rule has room to win.
Facts you can act on:
- On this data hybrid beats every single mode in every length bucket, and the router, at 0.631, loses to it by 0.036.
- Semantic beats lexical from two words up. Lexical beats semantic only on one-word queries (0.906 against 0.819), and that is 23 queries.
- The oracle takes the best mode for each query, which is the ceiling for any router: 0.733. A smarter router has headroom, but always running hybrid already captures most of it.
Your numbers will differ. The point is that you can find out in a minute, with a real number, and rerun it when the data changes.
judy diagnose takes the worst queries and asks an LLM why they rank their relevant documents badly. Unlike the judge, this advisor sees the request. It also sees what came back, the judged documents that did not come
back, and the index mapping and settings. That means field types, analyzers, copy_to, semantic_text inference ids and
the settings that affect scoring.
$ judy diagnose wands.judgements.yaml --target lexical --max-queries 2
ran 480 queries against lexical in 12.1s
including the index mapping and settings (556 characters); --no-index-info leaves them out
An excerpt of the answer, which judy also writes to wands.lexical.diagnosis.md:
**Query 14: "beds that have leds"**
- **Stopwords and OR semantics:** "that" and "have" are not removed, unless the analyzer has a stopword filter (the mapping does not
show one). Under OR matching, any document containing "that" or "have" qualifies. That explains the wall decals and mugs at ranks 1–7, …
- **Singular/plural mismatch:** … The relevant beds say "led" … Without stemming, "leds" does not match "led", and "beds" does not
match "bed". …
- **Ignored field:** Again `product_semantic` is not queried. The embedding would relate "beds with LEDs" to LED-lit beds directly.
The model saw the mapping, so it noticed what no one had told it. The index has a populated semantic_text field, and the
query never uses it. A diagnosis is a hypothesis. judy suggest turns it into an experiment:
$ judy suggest wands.judgements.yaml --target lexical --variants 3
ran 480 queries against lexical in 12.2s
including the index mapping and settings (556 characters); --no-index-info leaves them out
ran 480 queries against lexical+min-should-match-75 in 12.1s
ran 480 queries against lexical+phrase-boost-product-name in 12.0s
ran 480 queries against lexical+semantic-hybrid-product-semantic in 14.8s
ndcg@10 on lexical: 0.594; model claude-haiku-5-5 saw 8 of 336 training queries; holdout 144 queries
variant train holdout verdict
min-should-match-75 -0.006 (93w 68l, p=0.60) -0.049 (35w 30l, p=0.03) no gain
phrase-boost-product-name +0.003 (9w 7l, p=0.25) +0.004 (6w 1l, p=0.11) better on both
semantic-hybrid-product-semantic +0.033 (130w 35l, p=0.00) +0.037 (60w 16l, p=0.00) better on both
Nothing was changed in your configuration. To adopt a variant, copy its file over the target's template and confirm with: judy compare <results> <results>.
judy prints the model's explanation of each variant and the file name under its row. This excerpt leaves them out. What makes it trustworthy:
- The model never sees the holdout. judy splits the queries by a hash of their id. It holds out 30%, and makes no split under four queries. It measures every variant on both halves. A gain on the queries the model saw that does not carry over is reported as likely overfit.
- Bad ideas are caught.
min-should-match-75sounds sensible, and it lost 0.049 nDCG on the held-out queries (p = 0.03). judy says "no gain" and shows you why. - The good idea is measured. Putting the semantic field into the query gained 0.033 on the queries the model saw. It gained 0.037 on the 144 it did not see, with 60 queries better and 16 worse.
- Validated before it runs. A variant has to parse, use
{{query}}(or?query), and differ from the current one. Your configuration is never changed: variants are files next to the set.
suggest works on dsl and esql targets.
- run: judy run search.judgements.yaml --target candidate --format md # appends to $GITHUB_STEP_SUMMARY when set
- run: judy compare search.baseline.results.yaml search.candidate.results.yaml --max-regression 0.01| Exit code | Meaning |
|---|---|
| 0 | ok |
| 1 | a gate was breached, or the candidate regressed by more than --max-regression |
| 2 | usage error or an invalid file (for example an unknown target) |
| 3 | an IO error or failed searches |
--format md gives a table for a PR comment or the step summary; --format json is for your own tooling.
### fruit on baseline
3 queries, 3 scorable, labels: human
| metric | all | `words:2` | `words:1` |
|---|---|---|---|
| success@1 | 0.333 | 0.000 | 1.000 |
| success@3 | 1.000 | 1.000 | 1.000 |
| mrr@5 | 0.667 | 0.500 | 1.000 |
| ndcg@5 | 0.638 | 0.650 | 0.613 |
A judgement set says which results are good for which query. A target is whatever answers the queries. The simplest target is a TREC run file from an earlier system, so you can try everything without Elasticsearch or an LLM. Make a folder and write four files:
cat > fruit.judgements.yaml <<'EOF'
name: fruit
k: 5
gates:
candidate: {ndcg@5: 0.9}
queries:
- {id: q1, q: yellow fruit, ratings: {/banana: 3, /lemon: 2, /apple: 0}}
- {id: q2, q: red fruit, ratings: {/apple: 3, /cherry: 3, /banana: 0}}
- {id: q3, q: citrus, ratings: {/lemon: 3, /orange: 3}}
EOF
cat > baseline.run <<'EOF'
q1 Q0 /apple 1 9 base
q1 Q0 /lemon 2 8 base
q1 Q0 /banana 3 7 base
q2 Q0 /banana 1 9 base
q2 Q0 /apple 2 8 base
q2 Q0 /cherry 3 7 base
q3 Q0 /lemon 1 9 base
q3 Q0 /apple 2 8 base
EOF
cat > candidate.run <<'EOF'
q1 Q0 /banana 1 9 cand
q1 Q0 /lemon 2 8 cand
q2 Q0 /apple 1 9 cand
q2 Q0 /cherry 2 8 cand
q3 Q0 /lemon 1 9 cand
q3 Q0 /orange 2 8 cand
EOF
cat > judy.yaml <<'EOF'
targets:
baseline: {run: {file: baseline.run}}
candidate: {run: {file: candidate.run}}
EOFGrades run from 0 (irrelevant) to 3 (perfect). A run file's query ids (q1) are matched to the set's ids. Score the baseline:
$ judy run fruit.judgements.yaml --target baseline
ran 3 queries against baseline in 0.0s
set fruit target baseline labels human
queries 3 (3 scorable)
all
success@1 0.333
success@3 1.000
mrr@5 0.667
ndcg@5 0.638
recall@5 0.833
err@5 0.573
judged@5 0.467
…
wrote fruit.baseline.results.yaml
Then the candidate. The set holds a gate for it (ndcg@5 of at least 0.9):
$ judy run fruit.judgements.yaml --target candidate
…
gates
ok ndcg@5 1.000 >= 0.900
When a gate fails, judy says which one and exits 1:
gates
FAIL ndcg@5 0.638 < 0.800
FAIL success@1 0.333 < 0.500
Compare the two results files:
$ judy compare fruit.baseline.results.yaml fruit.candidate.results.yaml
ndcg@5: baseline -> candidate over 3 paired queries
mean 0.638 -> 1.000 (+0.362)
3 better, 0 same, 0 worse p = 0.25 (not distinguishable from noise)
most improved
+0.394 0.606 -> 1.000 yellow fruit
+0.387 0.613 -> 1.000 citrus
+0.307 0.693 -> 1.000 red fruit
All three queries improved, and judy still tells you three queries cannot prove it. That is the point of the paired test.
| Command | What it does |
|---|---|
judy run <set> --target t |
Runs the set and prints the scorecard (--format text|md|json). Writes {set}.{target}.results.yaml and, when judy built the request, .requests.jsonl. --k, --labels all|human, --concurrency. |
judy compare <baseline> <candidate> |
Each side is a results file, or a target to run now (needs --set). Paired deltas, wins and losses, a randomization test, --metric, --max-regression. |
judy judge <set> --target t |
The LLM labels unjudged top-k documents into {set}.llm.yaml. --dry-run, --max-calls, --provider, --model. |
judy review <set> |
Approve, reject or skip each LLM label. |
judy diagnose <set> --target t |
An LLM explains why the worst queries rank badly. --max-queries, --query, --dry-run, --no-index-info. |
judy suggest <set> --target t |
An LLM proposes variants of a dsl or esql template; judy runs and checks them against a holdout. --variants, --holdout, --dry-run, --no-index-info. |
judy modes <set> --target a --target b [--router r] |
Compares retrieval modes query by query, with the oracle, the length breakdown and the router's cost. |
judy synthesize <corpus.ndjson> --id url --title title --text body |
An LLM writes keyword and question queries for each document, which is the perfect answer to its own queries. A first judgement set in minutes. |
judy import docs-builder|website-search|trec|wands |
Converts older judgement lists and TREC qrels. import wands also downloads the example dataset and, with --url or --cluster, creates the index and loads it. |
judy export trec|run |
Writes topics and qrels, or a run file, for trec_eval or ranx. |
name: fruit
k: 5 # depth
gates: # per target; a breach exits 1
candidate: {ndcg@5: 0.7, success@1: 0.5}
queries:
- q: yellow fruit
id: q1 # optional stable key; defaults to q
intent: wants fruits that are yellow # optional; the LLM judge reads it
tags: [colour] # metrics are also reported per tag
ratings: {/banana: 3, /lemon: 2, /apple: 0} # grades 0-3
- q: citrus
relevant: [/lemon, /orange] # shorthand: grade 1| Metric | Reads as |
|---|---|
success@k |
1 if any relevant document is in the top k |
precision@k, recall@k |
share of the top k that is relevant, share of the relevant that is in the top k |
mrr@k |
reciprocal rank of the first relevant document |
ndcg@k |
graded gain 2^grade - 1, discounted by rank, normalised by the best ordering of every judged document |
err@k |
expected reciprocal rank: how likely a searcher is to stop at each result |
judged@k |
the share of the top k that has a judgement; the rest counts as not relevant |
Queries with no relevant document are counted and left out of the means.
clusters:
dev: {url: env:ES_URL, api_key: env:ES_API_KEY} # env:NAME reads an environment variable when used
targets:
full: {dsl: {cluster: dev, index: docs, file: queries/full.json}} # {{query}} {{size}} {{params.x}}
esql: {esql: {cluster: dev, file: queries/full.esql}} # ?query ?size ?x
dynamic: {builder: {cluster: dev, index: docs, command: [node, build-query.js]}}
api: {http: {url: "https://example.test/search?q={{query}}", hits: "$.results", id: url}}
replay: {run: {file: earlier.run}} # a TREC run file
docs: {id: url, title: title, text: [summary, body]} # how ids and text are read from hits
judge: {provider: anthropic} # or openai (base_url, model) or eis (cluster, inference_id)
modes: {semantic_fields: [body_semantic]} # fields that make a match query count as semanticjudy works out how each query was answered from the request. A semantic, knn, sparse_vector or rank_vectors query is
semantic. A match on ordinary fields is lexical. An rrf retriever of both is hybrid.
judy reads ES|QL KNN(...), MATCH(...) and FUSE the same way. A match on a semantic_text field looks lexical, so list such fields under modes: {semantic_fields: [...]}. A builder can state its mode and that always wins.
diagnose and suggest read GET {index}/_mapping and _settings. They add one line per field with its type and analysis,
such as title: text analyzer=english. They add the settings that change scoring, such as analysis, similarity,
number_of_shards, pipelines and sort.
judy leaves out uuids, dates and versions, describes at most three indices, and cuts the summary at 8,000 characters. It works for
dsl and builder targets (with an index) and for esql targets whose FROM names an index. When the cluster refuses the
read, you get a warning and the run goes on without it. The judge never sees any of this. See
what the model sees.
| Set | Needs | What it is |
|---|---|---|
| the offline example above | nothing | Three queries and two TREC run files |
| WANDS | a cluster, 100 MB | 480 queries, 42,994 products, 231,873 judgements. MIT licence, (c) Wayfair |
judy synthesize |
a cluster, an LLM | LLM-written keyword and question queries for your own documents. Quick, and it flatters retrieval: use it for a first look |
NFCorpus and SciFact were considered and left out: NFCorpus has no clear licence and SciFact is non-commercial.
- Documents that are judged but absent from the index are not detected; they count as misses (
diagnoseflags them ondsltargets). - Imported alternates (website-search) all get grade 3.
- No JUnit output or
--calibrateyet. diagnoseandsuggestdo not know which retrieval mode a query used.judged@kfor semantic and hybrid targets is understated untiljudy judgefills the holes.- A variant that scores better is a hypothesis. With a small set the p-values stay high: check it on queries the set does not hold.
- The OpenAI-compatible judge backend has not been run against a live service.
suggestonly works ondslandesqltargets, anddiagnosecan only fetch missing documents from adsltarget.
mise run setup # restore the local .NET tools
mise run test # build, then run every test project
mise run check # formatting (curb) and workflow findings (zizmor)The SDK version lives in global.json. Libraries target net10.0 and net11.0; the tool and the tests target net11.0. See
AGENTS.md for the conventions.