Skip to content

fix #1074: handle dict-based word_list in TextArenaEnv.ta_to_hf()#1154

Open
vominh1919 wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
vominh1919:fix/1074-textarena-wordlist-dict
Open

fix #1074: handle dict-based word_list in TextArenaEnv.ta_to_hf()#1154
vominh1919 wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
vominh1919:fix/1074-textarena-wordlist-dict

Conversation

@vominh1919
Copy link
Copy Markdown

@vominh1919 vominh1919 commented Apr 16, 2026

Fixes #1074

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 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_list is dict-shaped.

Overview
Fixes TextArenaEnv.ta_to_hf() to support TextArena games where word_list is a dict of categorized word lists by flattening it to a single list before calling random.choice().

This prevents runtime errors when generating train/eval datasets for games like TwentyQuestions-v0 that don’t expose word_list as a plain list.

Reviewed by Cursor Bugbot for commit 48cc784. Bugbot is set up for automated code reviews on this repo. Configure here.

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TextArenaEnv.ta_to_hf() crashes when word_list is a dict

1 participant