fix: improve model_args type coercion in handle_arg_string#3608
Merged
baberabb merged 1 commit intoEleutherAI:mainfrom Mar 4, 2026
Merged
fix: improve model_args type coercion in handle_arg_string#3608baberabb merged 1 commit intoEleutherAI:mainfrom
baberabb merged 1 commit intoEleutherAI:mainfrom
Conversation
- Support negative integers (e.g. -1) which isnumeric() missed - Add None/none detection - Add explicit quoting to force string type (e.g. revision="123123") - Add scientific notation support via float() fallback - Add comprehensive tests for handle_arg_string and simple_parse_args_string Fixes EleutherAI#2183, related to EleutherAI#2167
redpanda1995 approved these changes Mar 1, 2026
baberabb approved these changes Mar 4, 2026
baberabb approved these changes Mar 4, 2026
Contributor
| Thanks for the PR! LGTM |
Tracin pushed a commit to Tracin/lm-evaluation-harness that referenced this pull request Mar 11, 2026
…I#3608) - Support negative integers (e.g. -1) which isnumeric() missed - Add None/none detection - Add explicit quoting to force string type (e.g. revision="123123") - Add scientific notation support via float() fallback - Add comprehensive tests for handle_arg_string and simple_parse_args_string Fixes EleutherAI#2183, related to EleutherAI#2167
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.
Summary
Improves the type inference/coercion logic in
handle_arg_string()(lm_eval/utils.py) to fix several edge cases where model argument values end up as the wrong Python type.Fixes #2183 (related: #2167)
Changes
handle_arg_stringimprovements:-1now correctly becomesint(-1)instead of staying a string (the oldstr.isnumeric()check only matched non-negative digits)None/nonenow returns PythonNonerevision="123123"keeps the value asstrinstead of casting toint. This is the recommended fix for the revision issue in [BUG] Huggingface and Neuron runs fail if model revision is an integer #2167.1e-5correctly becomesfloat(1e-5)via the float fallbackTests added:
handle_arg_stringcovering bools, None, ints, negative ints, floats, scientific notation, plain strings, and explicit quotingsimple_parse_args_stringcovering end-to-end parsing with type coercionBackward compatibility
All existing behavior is preserved. The only additions are:
Noneare now properly coerced (previously returned as strings)