﻿---
title: LLM as a judge
description: A judgement set is only as good as its grades, and nobody has time to grade everything. judy puts a language model to work on that problem and on two...
url: https://docs-v3-preview.elastic.dev/llm
---

# LLM as a judge
A judgement set is only as good as its grades, and nobody has time to grade everything. judy puts a language model to work on
that problem and on two related ones. It keeps the jobs apart, so you always know what the model touched.
The central one is the **judge**: `judy judge` has a model grade the documents your search returned that no human ever rated.
That turns a half-judged set into one you can trust for semantic and hybrid search, where unjudged documents are the norm. The other commands use the same model for three more jobs. `synthesize` writes a first set from your documents. `diagnose`
explains why a query ranks badly. `suggest` proposes a fix that judy then measures.
Use the model you already have: [Anthropic, any OpenAI-compatible endpoint, or the Elastic Inference Service](https://docs-v3-preview.elastic.dev/llm/providers) on the
cluster you search. EIS needs no key of its own.

## Judge, diagnose, suggest: what is the difference?

They answer different questions, and the model sees different things, on purpose.
```mermaid
flowchart LR
    subgraph Judge["judy judge"]
        direction LR
        JQ["Query"] --> JM(("Model"))
        JD["Document text"] --> JM
        JM --> JG["A grade"]
    end
    subgraph Advise["judy diagnose and suggest"]
        direction LR
        AQ["Query"] --> AM(("Model"))
        AR["The request judy sent"] --> AM
        AX["Results and grades"] --> AM
        AP["Index mapping"] --> AM
        AM --> AO["A diagnosis, or variants to test"]
    end
```

The judge sees less on purpose. It never sees the request, the scores or the ranks.

| Command                                                                 | The question                                           | What the model sees                                                                                                                           | What it produces                                          | What it changes                                            |
|-------------------------------------------------------------------------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|------------------------------------------------------------|
| [`judy judge`](https://docs-v3-preview.elastic.dev/llm/judging)         | Is this document relevant to this query?               | the query, its `intent`, the document's title and text. **Never the request, the scores or the ranks**                                        | a grade for each unjudged document                        | the scores, when LLM labels count; it never edits your set |
| [`judy synthesize`](https://docs-v3-preview.elastic.dev/llm/synthesize) | What would someone type to find this document?         | a document                                                                                                                                    | queries, as a new judgement set                           | creates a new set                                          |
| [`judy diagnose`](https://docs-v3-preview.elastic.dev/llm/diagnose)     | Why does this query rank its relevant documents badly? | the query, the request judy sent, the results with their grades, the relevant documents that were missing, **the index mapping and settings** | a written diagnosis                                       | nothing                                                    |
| [`judy suggest`](https://docs-v3-preview.elastic.dev/llm/suggest)       | What request would do better?                          | the same as diagnose                                                                                                                          | variant request templates, each run against the whole set | nothing: variants are files next to the set                |

The short version:
- **The judge works on the data.** It improves the *measurement*, so a score means something. It never sees how the engine ranked a document. The question is only "is this relevant", and an answer that knew the rank
  could be flattered by it.
- **The advisors work on the search.** They help you *improve* it, so they see the request and the mapping. The question is how
  the engine read the query. Their answers are hypotheses, and `suggest` tests each one.

You can run any of them alone. The usual order is judge first, so the scores are fair, then diagnose the worst queries, then ask
for a fix.

## What stays under your control

- **Nothing is sent without you asking.** `--dry-run` on `judge`, `diagnose` and `suggest` says what would be sent and sends
  nothing. `--max-calls` and `--max-queries` cap spending.
- **LLM labels never overwrite human ones.** They live in `{set}.llm.yaml`, and `--labels human` ignores them. `judy review`
  turns the ones you agree with into human ratings.
- **Proposals are measured, not trusted.** `suggest` holds queries back from the model and reports whether a gain carries over.
- **Your configuration never changes.** Advice is text and files next to the set.

See [what the model sees, and what it costs](https://docs-v3-preview.elastic.dev/llm/trust) for the details.

| Page                                                                                    | What is in it                                                            |
|-----------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [Providers](https://docs-v3-preview.elastic.dev/llm/providers)                          | Anthropic, OpenAI-compatible endpoints and the Elastic Inference Service |
| [Judging unjudged results](https://docs-v3-preview.elastic.dev/llm/judging)             | `judy judge` and `judy review`                                           |
| [Writing a first set](https://docs-v3-preview.elastic.dev/llm/synthesize)               | `judy synthesize`                                                        |
| [Diagnose](https://docs-v3-preview.elastic.dev/llm/diagnose)                            | `judy diagnose`                                                          |
| [Suggest](https://docs-v3-preview.elastic.dev/llm/suggest)                              | `judy suggest`                                                           |
| [What the model sees, and what it costs](https://docs-v3-preview.elastic.dev/llm/trust) | privacy, caching and spending limits                                     |