> For the complete documentation index, see [llms.txt](https://docs.layerlens.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layerlens.ai/more-in-this-section-9/judge-optimizations-1.md).

# Judge optimizations

Automated judge optimization tunes a judge's prompt against examples to improve scoring accuracy. Use the `client.judge_optimizations` resource.

## Estimate cost

Always estimate before running:

```python
estimate = client.judge_optimizations.estimate(
 judge_id="judge_abc",
 budget="medium", # "light" | "medium" (default) | "heavy"
)
```

## Create (start optimization run)

```python
optimization = client.judge_optimizations.create(
 judge_id="judge_abc",
 budget="medium",
)
# optimization.status starts as "pending" / "in_progress"
```

## Poll

```python
import time
while True:
 optimization = client.judge_optimizations.get(optimization.id)
 if optimization.status.value in ("success", "failure"):
 break
 time.sleep(30)
```

## Apply (commits optimized prompt)

```python
if optimization.status.value == "success":
 print(f"Baseline: {optimization.baseline_accuracy}")
 print(f"Optimized: {optimization.optimized_accuracy}")
 client.judge_optimizations.apply(optimization.id)
 # Creates a new judge version with the optimized goal
```

## List

```python
response = client.judge_optimizations.get_many(judge_id="judge_abc", page=1, page_size=20)
```

## Object fields

`JudgeOptimizationRun` includes:

* `status` — `OptimizationRunStatus` enum (`pending`, `in_progress`, `success`, `failure`)
* `baseline_accuracy` — measured before optimization
* `optimized_accuracy` — measured after
* `original_goal` — original judge `evaluation_goal`
* `optimized_goal` — new prompt
* `estimated_cost` / `actual_cost`
* `applied_version` — judge version ID once applied

## Budget levels

| Budget             | When to use                                         |
| ------------------ | --------------------------------------------------- |
| `light`            | Quick validation, ≤30 labeled examples              |
| `medium` (default) | Standard production tuning, 30-100 labels           |
| `heavy`            | Maximum exploration, 100+ labels, high-value judges |

## See also

* [Tutorial 5: GEPA optimize](/9.-improve-tune-the-system/05-gepa-optimize.md)
* [Concept: Judges](/more-in-this-section-9/judges-2.md)
* [Bootstrap a judge before GEPA](/more-in-this-section-6/bootstrap-judges.md)
* [SDK sample: `judge_optimization.py`](https://github.com/layerlens/stratix-python/blob/main/samples/core/judge_optimization.py)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.layerlens.ai/more-in-this-section-9/judge-optimizations-1.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
