Skip to content

Latest commit

 

History

History
157 lines (125 loc) · 7.52 KB

README.md

File metadata and controls

157 lines (125 loc) · 7.52 KB

Auto-evaluation

This repository houses the scripts needed for auto-evaluation.

Retrieval check

eval_main.py stops with a non-zero exit before the judge runs when more than 10% of the questions (MAX_EMPTY_RETRIEVAL_SHARE) get no retrieval context or the answer invalid. That means the backend is broken, and the scores would be 0%. The message gives the count and two example questions.

Judge time limit

DeepEval runs at most five judge cases at once to reduce concurrent requests to the provider. It gives each active test case a DEEPEVAL_PER_TASK_TIMEOUT_SECONDS_OVERRIDE budget (900 s, set in llm_tests.sh). The whole batch has that budget plus DEEPEVAL_TASK_GATHER_BUFFER_SECONDS_OVERRIDE (2700 s), for a total of 3600 s. The batch limit includes time that cases wait for a concurrency slot. llm_tests.sh keeps caller overrides for both budgets. The judge model stops each Gemini call after CALL_TIMEOUT_SECONDS (120 s) and tries again. A TimeoutError can come from a case, the batch, or a model request. The stop message names the observed exception and the configured case and batch limits. The exception alone does not identify which timeout expired.

Each failed model attempt writes a judge_call_failed warning with the exception class, integer provider code or unknown, attempt count, call budget, elapsed time, and next retry delay. The final failed attempt uses retry_delay_seconds=none. The warning does not include prompts, responses, exception messages, headers, or credentials.

A run that stops early prints one Evaluation stopped: ... line. summarize_output.sh puts that line, not the end of the output, in the Secret CI comment.

Run metadata

Each run prints one line before the retrieval check and the DeepEval results, and passes the same values to DeepEval as hyperparameters:

Run metadata: judge=<model> backend=<provider>:<model> deepeval=<version> dataset=<commit> orassistant=<commit>

The dataset value is the Hugging Face commit that was downloaded, not a branch name. A judge or dataset change can move the scores as much as a code change, so compare scores only between runs with the same judge and dataset. summarize_output.sh puts this line above the Aggregate Metrics block in the Secret CI comment. See run_metadata.py for the meaning of each value.

Results file

Each run writes eval_results.json to its working directory, also when the retrieval check stops the run. It holds the schema version, the run status, the run metadata, the test count, the empty-context count, and the mean score and pass rate of each metric. A stopped run has "status": "stopped" and "metrics": null. Secret CI uploads the file from master runs as the artifact eval-results-<run id> and keeps it 90 days, as a baseline for later runs. See run_results.py for the schema.

Baseline gate

After the evaluation, Secret CI compares the results file with the one from the newest finished master push run that has scores. The run fails when the precision or recall pass rate is more than 5 points below that baseline. The job summary shows the baseline, current, and delta of each metric. The gate skips, with a notice, when the judge or the dataset differs, because the scores are then on a different scale. It also skips when the test count differs from the baseline, for example in a run with --limit 5.

A run that fails the gate is the baseline for the next run. So one drop fails one run and does not block master; check the failed run before the next merge. See baseline_gate.py.

Case records

Each case prints one line with the retrieval tool that the backend ran and the source URLs that it found:

Case 20: tool=retrieve_cmds sources=[https://a.example,https://b.example]

The index is the 0-based question position in the dataset. The DeepEval test case is named test_case_<index> and has the tool and sources as metadata. The run also writes the same records to eval_cases.jsonl in its working directory, one JSON line per case, as it goes. The file is not uploaded. See eval_cases.py for the format.

Case subset

--cases 20,84 evaluates only those 0-based question indexes, so case 84 is "What is OpenROAD?". The cases keep their dataset indexes in their names and records. --skip-judge prints the case records and stops before the retrieval check and DeepEval. The backend still needs its Google credentials. llm_tests.sh gives the arguments after the limit to eval_main.py:

./llm_tests.sh "" --cases 20,84 --skip-judge

make llm-tests in evaluation/ gives EVAL_ARGS to eval_main.py in the same way, for example make llm-tests EVAL_ARGS='--cases 20,84'.

The summary averages every case in the DeepEval cache, so run make clean in evaluation/ before a subset run. Otherwise earlier cases count too.

Judge change

A new judge model moves the scores on its own, so later runs cannot tell a judge change from a code change. Before a pull request changes JUDGE_MODEL in eval_main.py, run both judges on the same commit and dataset, and post the delta in the pull request. Run from evaluation/, with the backend up:

make clean
(cd auto_evaluation && uv run ./llm_tests.sh 5 --judge OLD_MODEL)
cp auto_evaluation/eval_results.json old.json
make clean
(cd auto_evaluation && uv run ./llm_tests.sh 5 --judge NEW_MODEL)
cp auto_evaluation/eval_results.json new.json
uv run python auto_evaluation/compare_results.py old.json new.json

make clean before each run is necessary, because the summary averages every case in the DeepEval cache (see Case subset). Use a larger limit, or no limit (""), for the delta that you post. compare_results.py exits with 1 when the two files come from a different commit or dataset.

To compare in Secret CI instead, start two runs on the same branch with the judge and limit inputs. Leave out pr: a run without it uploads its results as the artifact eval-results-<run id>, with the file eval_results.json. A run with judge, limit, or cases is a custom run. Custom runs have their own queue, so they do not cancel a full run. Only one custom eval runs at a time for each branch, and a newer custom run replaces an eval that waits. So start the second run after the first eval finishes. Each run also comments its summary on the commit. The gh run list filters show only your runs on BRANCH, so another person's run is not picked. gh run list --user does not accept @me, so the commands look up your login. A new run can take a few seconds to show in the list. Run from evaluation/:

me=$(gh api user --jq .login)
gh workflow run ci-secret.yaml --ref BRANCH -f judge=OLD_MODEL -f limit=5
gh run list --workflow ci-secret.yaml --event workflow_dispatch --branch BRANCH --user "$me" --limit 1
gh run watch OLD_RUN_ID
gh workflow run ci-secret.yaml --ref BRANCH -f judge=NEW_MODEL -f limit=5
gh run list --workflow ci-secret.yaml --event workflow_dispatch --branch BRANCH --user "$me" --limit 1
gh run watch NEW_RUN_ID
gh run download OLD_RUN_ID -n eval-results-OLD_RUN_ID -D old
gh run download NEW_RUN_ID -n eval-results-NEW_RUN_ID -D new
uv run python auto_evaluation/compare_results.py old/eval_results.json new/eval_results.json

The cases input takes 0-based question indexes, as --cases does, for example -f cases=20,84. The dataset has 100 questions, so the workflow accepts a limit from 1 to 100 and each case from 0 to 99, once. Set limit or cases, not both. The baseline gate skips a run whose case count differs from the baseline, because its scores cover only some cases. A run with limit=100, or with all 100 cases, still gates.