Repository navigation
Score MedCalc-Bench lab and dosage categories instead of always 0 - #4352
Open
azrabano23 wants to merge 1 commit into
Open
azrabano23 wants to merge 1 commit into
azrabano23 wants to merge 1 commit into
Conversation
`check_in_range` only range-checked the categories "dosage conversion"
and "physical". The MedCalc-Bench categories that actually reach it are
"date", "lab", "dosage" and "physical", and the string "dosage
conversion" does not occur in the dataset. Unrecognized categories hit
`raise ValueError("Category ... not supported")`, which sits inside the
same `try` whose `except ValueError: return 0` swallows it, so every
"lab" and "dosage" instance (354 of 1000 in the test split) was scored 0
regardless of the prediction.
Re-scoring the published MedHELM v3.0.0 predictions with the range check
applied to lab/dosage: claude-3-7-sonnet overall accuracy 0.210 -> 0.314
(lab 0.000 -> 0.292, dosage 0.000 -> 0.308); gpt-4o-2024-05-13 overall
0.188 -> 0.280. All other categories unchanged.
Range-check lab, dosage and physical, and move the unsupported-category
check before the `try` so an unknown category raises instead of scoring
0. Add regression tests for the numeric categories, the raise, and the
end-to-end `evaluate_generation` path on a lab instance.
Fixes stanford-crfm#4351
Signed-off-by: Azra Bano <azrabano.work@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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.
What was wrong
MedCalcBenchMetric.check_in_rangeonly range-checks the categories"dosage conversion"and"physical". The categories thatevaluate_generationactually sends to it (everything exceptrisk/severity/diagnosis) aredate,lab,dosage,physicalinncbi/MedCalc-Bench-v1.0;"dosage conversion"never occurs. Unrecognized categories reachraise ValueError("Category ... not supported"), which is inside thetrywhoseexcept ValueError: return 0catches it. Result: all 354lab+dosageinstances (of 1000) score 0 no matter what the model answered.Concrete instance from the published claude-3-7-sonnet run: category
lab, prediction303, limits[287.8766, 318.1794], reportedmedcalc_bench_accuracy = 0.0.Re-scoring the published MedHELM v3.0.0
display_predictions.jsonwith the range check applied tolab/dosage(same code pathphysicaluses today):Every other category is unchanged.
The fix
lab,dosage,physical(the referenceevaluate.pyin ncbi-nlp/MedCalc-Bench range-checks every non-date calculator).try, so a genuinely unknown category raises instead of silently scoring 0.Net change to
medcalc_bench_metrics.pyis 3 lines. Unparseable predictions and out-of-range values still score 0, as before.Tests
New
src/helm/benchmark/metrics/test_medcalc_bench_metrics.py:lab/dosage/physicalin-range, boundary, out-of-range and non-numeric predictions viacheck_in_range;ValueError;evaluate_generationon alabinstance.On
main, 4 of 5 fail (labanddosagereturn 0, the raise is swallowed, end-to-end scores 0.0); with the fix all 5 pass.Verification
Python 3.12, CPU only. Published MedCalc-Bench numbers produced by this metric understate every model's accuracy by roughly 0.09-0.10 absolute on the two runs above, and the gap is model dependent.
Fixes #4351. Also resolves item 2 of #4340 (the swallowed
raiseat this site).🤖 Generated with Claude Code