mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-26 17:13:17 +00:00
Curriculum/cognition (#314)
* added rectangle count curriculum * added number sequences * registered curriculum
This commit is contained in:
parent
d0b49cfffd
commit
0dce7adbad
5 changed files with 117 additions and 7 deletions
|
|
@ -1,6 +1,10 @@
|
|||
import pytest
|
||||
|
||||
from reasoning_gym.cognition.rectangle_count import RectangleCountConfig, RectangleCountDataset
|
||||
from reasoning_gym.cognition.rectangle_count import (
|
||||
RectangleCountConfig,
|
||||
RectangleCountCurriculum,
|
||||
RectangleCountDataset,
|
||||
)
|
||||
|
||||
|
||||
def test_dice():
|
||||
|
|
@ -17,3 +21,31 @@ def test_dice():
|
|||
# Test the scoring
|
||||
assert dataset.score_answer(answer=item["answer"], entry=item) == 1.0
|
||||
assert dataset.score_answer(answer=None, entry=item) == 0.0
|
||||
|
||||
|
||||
def test_rc_curriculum():
|
||||
"""Test the RectangleCountCurriculum functionality"""
|
||||
curriculum = RectangleCountCurriculum()
|
||||
|
||||
base_value = {"size": 150, "seed": 1}
|
||||
|
||||
# Test the initial configuration
|
||||
base_cfg: RectangleCountConfig = curriculum.generate_configuration(base_value)
|
||||
assert base_cfg.seed == 1
|
||||
assert base_cfg.size == 150
|
||||
assert base_cfg.max_rectangles == 1 # Based on number_rectangles attribute level 0 (value 1)
|
||||
|
||||
# Test incrementing the number_rectangles attribute
|
||||
curriculum.increment_attr_level("max_rectangles")
|
||||
increased_cfg = curriculum.generate_configuration(base_value)
|
||||
assert increased_cfg.max_rectangles == 3 # Based on number_rectangles attribute level 1 (value 3)
|
||||
|
||||
# Test another increment
|
||||
curriculum.increment_attr_level("max_rectangles")
|
||||
increased_cfg = curriculum.generate_configuration(base_value)
|
||||
assert increased_cfg.max_rectangles == 5 # Based on number_rectangles attribute level 2 (value 5)
|
||||
|
||||
# Test decrementing
|
||||
curriculum.decrement_attr_level("max_rectangles")
|
||||
decreased_cfg = curriculum.generate_configuration(base_value)
|
||||
assert decreased_cfg.max_rectangles == 3 # Back to level 1 (value 3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue