Add puzzles

This commit is contained in:
Matt 2025-02-04 15:09:21 +00:00
parent b2d7ba2f1d
commit 9ca4ed5a6a
3 changed files with 15 additions and 3 deletions

View File

@ -24,4 +24,15 @@ After `pip install`ing the open-r1 repo, you can very quickly get started
>>> config.min_coefficient = -1000
>>> config.max_coefficient = 1000
>>> harder_task = LinearEquationTask(config)
```
```
## Adding new puzzles
[add puzzle guide goes here]
## Coming soon:
- Proper indexing of puzzles
- More puzzle types!
- Lazy loading (if the module gets very big)
- Gu

View File

@ -44,6 +44,6 @@ class BaseTask(ABC):
raise NotImplementedError
@abstractmethod
def validate(self, output, answer) -> float:
def verify(self, output, answer) -> float:
# This should return a score between 0. and 1. based on how well the output matches the answer
raise NotImplementedError

View File

@ -10,6 +10,7 @@ class LinearEquationConfig(BaseConfig):
min_var_value = -10
max_var_value = 10
class LinearEquationTask(BaseTask):
config_class = LinearEquationConfig
@ -37,7 +38,7 @@ class LinearEquationTask(BaseTask):
return equation, var_value
def validate(self, output, answer):
def verify(self, output, answer):
# If there's only one number in the output, it's the answer
numbers = re.findall(r"\d+", output)
if len(numbers) == 1: