mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-22 16:49:06 +00:00
palindrome generation curriculum (#322)
This commit is contained in:
parent
ad48c551f9
commit
9aeef4ebb0
3 changed files with 48 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ import string
|
|||
from dataclasses import dataclass
|
||||
from typing import Any, Optional
|
||||
|
||||
from ..coaching import AttributeType, BaseCurriculum, RangeAttributeDefinition
|
||||
from ..factory import ProceduralDataset, register_dataset
|
||||
|
||||
QUESTION_TEMPALTE = """Your task is, given a list of letters, to form a valid palindrome.
|
||||
|
|
@ -68,6 +69,9 @@ class PalindromeDataset(ProceduralDataset):
|
|||
"metadata": {
|
||||
"letters": scrambled_letters,
|
||||
"generated_palindrome": palindrome,
|
||||
"difficulty": {
|
||||
"length": length,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -116,4 +120,23 @@ class PalindromeDataset(ProceduralDataset):
|
|||
return 1.0 # Correct solution
|
||||
|
||||
|
||||
register_dataset("palindrome_generation", PalindromeDataset, PalindromeConfig)
|
||||
class PalindromeCurriculum(BaseCurriculum):
|
||||
def __init__(self):
|
||||
super().__init__(PalindromeCurriculum.__name__, PalindromeConfig)
|
||||
|
||||
# Define attributes
|
||||
self._define_attributes(
|
||||
RangeAttributeDefinition(
|
||||
name="length",
|
||||
levels=[10, 50, 100, 500],
|
||||
default_level=1,
|
||||
description="Length of the generated palindrome.",
|
||||
attr_type=AttributeType.APPEND,
|
||||
min_value=2,
|
||||
lower_field_name="min_length",
|
||||
upper_field_name="max_length",
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
register_dataset("palindrome_generation", PalindromeDataset, PalindromeConfig, PalindromeCurriculum)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue