mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-19 12:58:07 +00:00
string insertion curriculum (#305)
This commit is contained in:
parent
af6120c095
commit
925283f342
3 changed files with 56 additions and 4 deletions
|
|
@ -7,6 +7,7 @@ from dataclasses import dataclass
|
|||
from random import Random
|
||||
from typing import Any, Optional
|
||||
|
||||
from ..coaching import AttributeType, BaseCurriculum, RangeAttributeDefinition
|
||||
from ..factory import ProceduralDataset, register_dataset
|
||||
|
||||
QUESTION_TEMPLATE = """Given a string consisting of characters A, B, C, D, and E, your job is to insert a character according to the following pattern:
|
||||
|
|
@ -100,8 +101,33 @@ class StringInsertionDataset(ProceduralDataset):
|
|||
return {
|
||||
"question": QUESTION_TEMPLATE.format(string=string),
|
||||
"answer": str(answer),
|
||||
"metadata": {"string": string, "solution": answer},
|
||||
"metadata": {
|
||||
"string": string,
|
||||
"solution": answer,
|
||||
"difficulty": {
|
||||
"string_length": string_length,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
register_dataset("string_insertion", StringInsertionDataset, StringInsertionConfig)
|
||||
class StringInsertionCurriculum(BaseCurriculum):
|
||||
def __init__(self):
|
||||
super().__init__(StringInsertionCurriculum.__name__, StringInsertionConfig)
|
||||
|
||||
# Define attributes
|
||||
self._define_attributes(
|
||||
RangeAttributeDefinition(
|
||||
name="string_length",
|
||||
levels=[10, 50, 100, 1000],
|
||||
default_level=1,
|
||||
description="Length of the string",
|
||||
attr_type=AttributeType.APPEND,
|
||||
min_value=5,
|
||||
lower_field_name="min_string_length",
|
||||
upper_field_name="max_string_length",
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
register_dataset("string_insertion", StringInsertionDataset, StringInsertionConfig, StringInsertionCurriculum)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue