Parse hellaswag_arabic endings with ast.literal_eval - #1348
Open
Nakul-Sinha wants to merge 1 commit into
Open
Conversation
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.
Fixes #1293
Problem
hellaswag_arabic_pfnparses theendingsfield with the builtineval():The field holds a string representation of a list, but
eval()executes arbitrary Python rather than just parsing a literal. The value comes fromOALL/AlGhafa-Arabic-LLM-Benchmark-Translated, a community-hosted dataset on the Hub, so a craftedendingsvalue in that dataset or any later revision of it would run code on whichever machine is running the evaluation.Change
Use
ast.literal_eval, which accepts the same literal syntax but evaluates only literals, and add theastimport.Testing
python -m py_compile src/lighteval/tasks/multilingual/tasks/arabic.pypasses.Checked that the parsing behaviour is unchanged for real inputs and that the injection no longer executes:
Single and double quoted lists, and non-ASCII contents, all parse identically to before.
main_inspect.py:568also callseval(...), but that isinspect_ai's ownevalfunction rather than the builtin, so it is unrelated and left alone.AI assistance was used for this change.