Diagnose and suggest
When a query ranks its relevant documents badly, two commands ask an LLM why, and what to change. Both are built so the model's answer is a hypothesis that judy then tests.
Unlike the judge, these advisors see the request: the question is about how the engine read the query. They also see what came back, the judged documents that did not, and the index mapping and settings.
For each of the worst queries:
- the query, its intent, and its score;
- the request judy sent, and the top results with their grades (
3,1,0, or?for unjudged) and text; - the judged-relevant documents that were not returned, best grades first. judy sends at most ten per query, with a count
of the rest. A WANDS query can have hundreds. For a
dsltarget their text is fetched from the index, and ids that match nothing are flagged as possibly wrong; - the request template, and the mean of the metric over the whole set.
And once, for the whole index, a condensed summary of the mapping and settings:
- one line per field with its type and analysis:
title: text analyzer=english, multi-fields astitle.raw,copy_to,semantic_textwith its inference id and model settings; - the settings that change scoring:
analysis,similarity,number_of_shards, pipelines, sort.
Uuids, dates and versions are left out, at most three indices are described, and the summary is cut 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 (an API key without view_index_metadata), judy warns and goes on without it. --no-index-info leaves it out.
$ 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
The answer is printed and written to wands.lexical.diagnosis.md. An excerpt:
**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 nobody had told it. The index has a populated semantic_text field, and the
query never uses it. Without the mapping, the same model wrote "I can't see the index mapping, so the analyzers are
assumptions to verify".
| Option | Meaning |
|---|---|
--max-queries <n> |
how many of the worst queries to send (default 5) |
--query <id> |
diagnose these query ids instead (repeatable) |
--metric <kind@k> |
the metric that ranks "worst" (defaults to nDCG) |
--dry-run |
say how many queries and characters would be sent, and send nothing |
--no-index-info |
leave the mapping and settings out |
--provider, --model |
the LLM, overriding judge: in judy.yaml |