Skip to content

feat(scorers): support multiple python_scorer_* entries in run YAML - #528

Open
saurabh-net wants to merge 10 commits into
mainfrom
feature/multiple-python-scorers
Open

feat(scorers): support multiple python_scorer_* entries in run YAML#528
saurabh-net wants to merge 10 commits into
mainfrom
feature/multiple-python-scorers

Conversation

@saurabh-net

@saurabh-net saurabh-net commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Motivation

In evaluation workflows, users often need to evaluate model outputs against multiple distinct Python evaluators (e.g. execution accuracy, code style, compliance, or custom domain judges) within a single evaluation run configuration YAML.

Previously:

  1. score.py only checked for exact key if key == "python_scorer":.
  2. Standard YAML parsers overwrite duplicate mapping keys, so repeating python_scorer: in YAML only preserved the last entry.
  3. Custom keys like python_scorer_accuracy or python_scorer_style were skipped by score.py.

Implementation Summary

  • Key Prefix Matching: Updated evalbench/scorers/score.py to match any dictionary key under scorers: starting with python_scorer (if key.startswith("python_scorer"):).
  • Full custom_name Fallback Resolution: Retained full custom_name resolution logic in score.py (scorer_name -> script_path basename -> key fallback).
  • Analyzer Resolution Alignment: Updated evalbench/reporting/analyzer.py (analyze_one_metric) to resolve comparator_name using the same fallback rules as score.py. This guarantees that df["comparator"] matches comparator_name cleanly regardless of whether scorer_name, script basename, or key is used for comparator naming.
  • Config Protection: Shallow-copied scorer_config before passing to PythonScorer to prevent in-place mutation of input dictionaries.
  • Documentation: Updated docs/configs/run-config.md and docs/gemini_cli_agent_testing.md with YAML usage examples for single and multiple Python scorers.

Testing & Verification Context

1. Automated Unit Tests

  • Ran pythonscorer_test.py: ./.venv/bin/python -m unittest evalbench/test/pythonscorer_test.py
    • Outcome: Passed 6/6 tests. Added coverage for multi-scorer comparator instantiation, custom_name resolution, and analyzer.py summary metric aggregation.
  • Verified hybrid_xa_judge_test.py: ./.venv/bin/python -m unittest evalbench/test/hybrid_xa_judge_test.py
    • Outcome: Passed 5/5 tests. Confirmed evalbench/scorers/judges/hybrid_xa_judge.py and datasets/bird/example_hybrid_run_config.yaml remain 100% backward-compatible.

2. Manual Integration Testing

  • Setup: Created two custom Python evaluators (scorer_accuracy.py returning 100.0% and scorer_style.py returning 85.0%) and configured a test YAML containing both under scorers: (python_scorer_accuracy and python_scorer_style).
  • CLI Execution: Ran direct end-to-end evaluation using evalbench/evalbench.py CLI:
    python evalbench/evalbench.py --experiment_config=/tmp/evalbench_noop_test_run.yaml
  • Result: evalbench.py executed all pipeline stages (DB Setup -> Prompts -> SQLGen -> SQLExec -> Scoring -> Analyzer -> CSV Exports). Both Python scorers ran natively, logged individual scores, and were recorded in scores.csv and summary.csv.

- Enable key prefix matching for any key under  starting with .
- Ensure comparator name matches YAML key for clean metric aggregation in , , and .
- Add unit tests for multiple python scorers and aggregation in .
@saurabh-net
saurabh-net requested a review from graceqi-g July 27, 2026 23:24
@saurabh-net
saurabh-net marked this pull request as draft July 27, 2026 23:37
Comment thread evalbench/reporting/analyzer.py Fixed
@saurabh-net
saurabh-net marked this pull request as ready for review July 29, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant