Repository navigation
fix(eval): score coverage against the benchmark instead of the predictions file - #136
Merged
DzmitryPihulski merged 1 commit intoOct 9, 2026
Conversation
…tions file evaluate() computed accuracy as matches / len(outputs), so a crashed run, --limit or a filtered file produced a full-looking accuracy with no warning, and duplicate question_ids were counted twice. - New pure helper resolve_prediction_coverage() deduplicates predictions (keeping the first per question_id) and returns expected / answered / missing / duplicates. Unknown ids now raise ValueError naming the id instead of a bare KeyError from questions[qid]. - New normalize_question_id() accepts int-like strings (123), which other tools commonly produce; anything else fails with the offending value. - The two asserts in evaluate_sample are replaced with explicit errors: they disappear entirely under python -O, letting malformed input through. - coverage lands both in print_summary (Coverage / Missing / Duplicate rows plus Accuracy over Benchmark) and in the JSON report; evaluate() logs a warning whenever coverage is below 100%. - New accuracy_over_benchmark field counts unanswered questions as wrong. Note: replacing the asserts changes what two existing tests in tests/utils/test_evaluation_utils.py assert on, so those assertions are updated (string ids are now a valid input, not an error case). Closes LLMSQL#124
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Collaborator
|
Hi @ddaihao2022, thank you for your contribution! Very clean work: coverage accounting, duplicate handling, string ids, and explicit errors instead of asserts, all with thorough tests. Merged. If you find LLMSQL useful, we'd be grateful if you could give the project a ⭐ on GitHub, it really helps us! |
anush-933
pushed a commit
to anush-933/llmsql-benchmark
that referenced
this pull request
Oct 10, 2026
The leaderboard run.yaml used accuracy over the predictions file, so a partial run could rank too high. Use accuracy_over_benchmark (from LLMSQL#136) and the benchmark size as num_samples. Full, duplicate-free runs (all current leaderboard entries) are unaffected.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #124
Problem
evaluate()scored whatever rows were in the predictions file:accuracy = matches / len(outputs), so a crashed run, a--limitrun or a filteredfile produced a full-looking accuracy with no warning (1,000 answers out of 80,330
could be reported as a complete result).
question_ids were counted twice.KeyErrorfromquestions[qid]."123", which other tools commonly produce) trippedassert isinstance(qid, int)— and asserts vanish underpython -O, so the checkcould silently disappear.
What changed
llmsql/utils/evaluation_utils.pyresolve_prediction_coverage(outputs_list, questions)→(unique, coverage):keeps only the first prediction per
question_id, counts duplicates, and returnsexpected/answered/missing/duplicates. Unknown ids raise aValueErrorthat names the id and the benchmark size.
normalize_question_id(value): acceptsintand int-like strings, reports theoffending value otherwise.
evaluate_sample, the twoasserts are replaced with explicit errors(
ValueErrorfor unknown ids,TypeErrorfor non-string completions).llmsql/evaluation/evaluate.pyresolve_prediction_coverage()before the loop, warns (vialog.warning) whenthere are duplicates or when coverage < 100%, and adds the coverage counters plus a new
accuracy_over_benchmarkfield (missing answers count as wrong) to the JSON report.llmsql/utils/rich_utils.pyprint_summary()takes an optionalcoveragedict (keyword-only, so existing callersare unaffected) and adds
Coverage,Missing Predictions,Duplicate PredictionsandAccuracy over Benchmarkrows. Also guards thematches / totaldivision againstan empty predictions list, which previously raised
ZeroDivisionError.Behaviour
A run that answered 1 of 4 questions, with one duplicated id, now prints:
Previously it printed only
Total Samples 1/Correct Results 1 (100.00%).Tests
Added to
tests/utils/test_evaluation_utils.py(12 new cases):TestNormalizeQuestionId— int passthrough, int-like strings incl. whitespace,non-int strings, unsupported types.
TestResolvePredictionCoverage— full coverage, partial run reported asmissing,duplicates keep the first prediction, string ids match the benchmark,
unknown id raises carrying the id, empty predictions.
evaluate_samplenow assertsTypeErrorfor non-string completions andValueErrorfor unknown ids, plus string ids are now a valid input rather than an error case.
AssertionErrorwere updated accordingly — thisis the one behavioural change existing callers/tests can notice. Everything else is
additive.
Verification performed:
ruff checkpasses on all four changed files (the 2 pre-existing errors are inllmsql/_cli/llmsql_cli.pyandllmsql/inference/inference_api.py, untouched).PYTHONPATH=. pytest tests/utils/ --ignore=tests/utils/test_inference_utils.py→ 88 passed (baseline was 76 before this change).
llmsql/utils/evaluation_utils.pymakes the new tests fail(reverse verification).
Not verified locally:
tests/evaluation/*/tests/utils/test_inference_utils.pycannot be collected here because they import
torch/vllm, which are multi-GB GPUdependencies not installed on this machine. Those suites cover
evaluate()end-to-endvia mocks; I kept
print_summary's new parameter backwards compatible precisely so thosemonkeypatched call sites keep working. I'd appreciate CI confirming them.