add word ladder curriculum (#361)

* add word ladder curriculum

* add to __init__.py
This commit is contained in:
Oliver Stanley 2025-03-14 15:10:52 +00:00 committed by GitHub
parent 8f8bd9d756
commit b5651e5e2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 55 additions and 4 deletions

View file

@ -3,7 +3,7 @@ from random import Random
import pytest
from reasoning_gym.algorithmic.word_ladder import WordLadderConfig, WordLadderDataset
from reasoning_gym.algorithmic.word_ladder import WordLadderConfig, WordLadderCurriculum, WordLadderDataset
def test_word_ladder_config_validation():
@ -397,3 +397,24 @@ def test_word_ladder_score_answer():
# Test with unknown words (should return partial credit)
assert dataset.score_answer("COLD,COXD,CORD,CARD,WARD,WARM", entry) < 1.0
assert dataset.score_answer("COLD,COXD,CORD,CARD,WARD,WARM", entry) > 0.0
def test_word_ladder_curriculum():
curriculum = WordLadderCurriculum()
base_value = {"size": 150, "seed": 1}
base_cfg: WordLadderConfig = curriculum.generate_configuration(base_value)
assert base_cfg.seed == 1
assert base_cfg.size == 150
assert base_cfg.min_word_length == 3 and base_cfg.max_word_length == 4
# test incrementing attribute levels
curriculum.increment_attr_level("word_length")
increased_cfg = curriculum.generate_configuration(base_value)
assert increased_cfg.min_word_length == 3 and increased_cfg.max_word_length == 5
# test decrementing attribute level for word length again
curriculum.decrement_attr_level("word_length")
partially_decreased_cfg = curriculum.generate_configuration(base_value)
assert partially_decreased_cfg.min_word_length == 3 and partially_decreased_cfg.max_word_length == 4