fix: extract \boxed{} from model response in hendrycks_math#3644
Open
NezLheimeur wants to merge 3 commits intoEleutherAI:mainfrom
Open
fix: extract \boxed{} from model response in hendrycks_math#3644NezLheimeur wants to merge 3 commits intoEleutherAI:mainfrom
NezLheimeur wants to merge 3 commits intoEleutherAI:mainfrom
Conversation
fxmarty-amd
approved these changes
Mar 25, 2026
Contributor
fxmarty-amd
left a comment
There was a problem hiding this comment.
LGTM, I confirm this fixes zero accuracy.
You should probably update the README and
metadata:
version: 1.0in yaml files
This fix looks similar to: #3192
Author
|
@fxmarty-amd thanks for the review. I've updated the readme and associated yaml files. |
process_results only applied remove_boxed/last_boxed_only_string to
the target (ground truth), never to the model's response. When instruct
models output answers in \boxed{} format, the answer extraction fell
back to $...$ matching or used the entire response verbatim.
This aligns hendrycks_math with the aime task which already extracts
\boxed{} from the response.
Fixes EleutherAI#3643
Add changelog entry for the \boxed{} extraction fix.
Handle cases where models output multiple \boxed{} answers
(e.g. \boxed{3}, \boxed{5}, \boxed{7}) by extracting all
occurrences and joining them. Duplicates are removed to handle
models that repeat the final answer.
92deb43 to
d6cae43
Compare
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.
Problem
process_resultsinhendrycks_math/utils.pyappliesremove_boxed(last_boxed_only_string(...))to the target but never to the model's response. Instruct models commonly output\boxed{}formatted answers, but the extraction only looks for$...$delimiters in the response.This causes correct answers to score 0. For example, when a model outputs
"The domain is \boxed{[2,5)}", the extraction gets the entire string (no$signs found), andis_equivfails against"[2,5)".Fix
\boxed{}extraction: Try\boxed{}extraction on the response first, fall back to$...$. Aligns withlm_eval/tasks/aime/utils.py.\boxed{}extraction: Handle cases where models output separate boxed answers (e.g.\boxed{3}, \boxed{5}, \boxed{7}→3, 5, 7). Duplicates are deduplicated to handle models that repeat the final answer.metadata.versionbumped to 1.1 in YAML files.Impact
Affects
hendrycks_mathandhendrycks_math500tasks with any model that outputs\boxed{}formatted answers (standard for math instruct models).Fixes #3643
Partially addresses #3652 (multi-boxed answers)