Skip to main content

Overview

The evaluator is a Python module that defines an evaluate() function. SkyDiscover calls this function with the path to each generated program and uses the returned metrics to guide evolution.

Basic Structure

evaluator.py
The combined_score key is required and must be a float. Higher values indicate better solutions.

Complete Example: Circle Packing

Here’s a real evaluator from the benchmarks:
evaluator.py

Evaluator Best Practices

1. Handle Errors Gracefully

Don’t raise exceptions:
Do return zero score:

2. Use Timeouts

Prevent infinite loops or slow programs:

3. Validate Outputs

Check for NaN, inf, negative values, wrong shapes:

4. Normalize Scores

Keep combined_score in a reasonable range (e.g., 0.0 to 1.0):

Multi-Stage Evaluation (Cascade)

Speed up evaluation by implementing staged checks:
evaluator.py
Enable in config:
config.yaml
  1. SkyDiscover calls evaluate_stage1() first
  2. If combined_score < 0.3, program is rejected (no stage 2)
  3. If 0.3 ≤ combined_score < 0.6, calls evaluate_stage2()
  4. If combined_score ≥ 0.6, keeps stage 1 result (assumes valid)
This saves compute by rejecting bad programs early.

LLM-as-a-Judge

Add qualitative feedback using an LLM judge:
config.yaml
The LLM judge appends llm_* metrics to your evaluator’s output:

Prompt Optimization Evaluators

For prompt evolution tasks, the evaluator receives a .txt file:
evaluator.py
Set language: text in your config:
config.yaml

Metric Guidelines

combined_score
float
required
Required. Overall quality metric. Higher is better. Used for ranking programs.
validity
float
Binary 0.0/1.0 or continuous validity score. Helps identify constraint violations.
error
string
Error message if evaluation failed. Helps debug generated programs.
eval_time
float
Evaluation time in seconds. Useful for performance analysis.
Custom metrics
any
Task-specific metrics (accuracy, loss, reward, etc.). Logged for analysis.
Return many metrics! SkyDiscover logs all of them, making it easy to analyze trade-offs and trends.

Testing Your Evaluator

Test locally before running full discovery:
test_evaluator.py

Common Patterns

Next Steps

Configuration

Configure evaluator timeouts and cascade settings

Benchmarks

See real evaluators from 200+ benchmark tasks