fix #1074: handle dict-based word_list in TextArenaEnv.ta_to_hf()#1154
Open
vominh1919 wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
Open
fix #1074: handle dict-based word_list in TextArenaEnv.ta_to_hf()#1154vominh1919 wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
vominh1919 wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
Conversation
…nv.ta_to_hf() Games like TwentyQuestions-v0 use categorized word lists (dict with category keys mapping to word lists). Ta_to_hf() called random.choice() directly on the word_list, causing KeyError when it's a dict. Now flattens dict word lists into a single list before sampling. Fixes PrimeIntellect-ai#1074
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 #1074
Games like TwentyQuestions-v0 use categorized word lists (dict with category keys mapping to word lists).
ta_to_hf()calledrandom.choice()directly on theword_list, causingKeyErrorwhen it is a dict.Fix: flatten dict word lists into a single list before sampling.
This likely affects any TextArena game that uses categorized word lists, not just TwentyQuestions-v0.
Note
Low Risk
Small, localized data-prep change that only affects how answers are sampled when
word_listis dict-shaped.Overview
Fixes
TextArenaEnv.ta_to_hf()to support TextArena games whereword_listis a dict of categorized word lists by flattening it to a single list before callingrandom.choice().This prevents runtime errors when generating train/eval datasets for games like
TwentyQuestions-v0that don’t exposeword_listas a plain list.Reviewed by Cursor Bugbot for commit 48cc784. Bugbot is set up for automated code reviews on this repo. Configure here.