mirror of
https://github.com/open-thought/reasoning-gym.git
synced 2026-04-25 17:10:51 +00:00
Create python generator files for gsm symbolic templates
This commit is contained in:
parent
ff13dc6825
commit
1e0dbc9875
100 changed files with 6919 additions and 0 deletions
69
reasoning_gym/arithmetic/gsm_symbolic/generator_12.py
Normal file
69
reasoning_gym/arithmetic/gsm_symbolic/generator_12.py
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
from random import Random
|
||||
from typing import Dict, Any
|
||||
|
||||
def generate_from_variables(name: str, game1: str, game2: str, period: str,
|
||||
time1: int, time2: int, num1: int, num2: int) -> Dict[str, Any]:
|
||||
total_time1 = time1 * num1
|
||||
total_time2 = time2 * num2
|
||||
total_time = total_time1 + total_time2
|
||||
|
||||
question = f"It takes {name} {time1} minutes to finish a {game1} and {time2} minutes to finish a {game2}. Over the {period} she solved {num1} {game1}s and {num2} {game2}s. How much time did she spend playing these games?"
|
||||
|
||||
answer_cot = f"It takes {time1} minutes to complete a {game1} and she completed {num1} for a total of {time1}*{num1} = {total_time1} minutes\n" \
|
||||
f"It takes {time2} minutes to complete a {game2} and she completed {num2} for a total of {time2}*{num2} = {total_time2} minutes\n" \
|
||||
f"She spent {total_time1} minutes on {game1}s and {total_time2} minutes on {game2}s for a total of {total_time1}+{total_time2} = {total_time} minutes\n" \
|
||||
f"#### {total_time}"
|
||||
|
||||
return {
|
||||
'question': question,
|
||||
'answer': str(total_time),
|
||||
'answer_cot': answer_cot,
|
||||
'answer_value': total_time,
|
||||
'variables': {
|
||||
'name': name,
|
||||
'game1': game1,
|
||||
'game2': game2,
|
||||
'period': period,
|
||||
'time1': time1,
|
||||
'time2': time2,
|
||||
'num1': num1,
|
||||
'num2': num2,
|
||||
'total_time1': total_time1,
|
||||
'total_time2': total_time2
|
||||
}
|
||||
}
|
||||
|
||||
def generate_example(rng: Random, difficulty: float = 1.0) -> Dict[str, Any]:
|
||||
names = ["Emma", "Olivia", "Ava", "Isabella", "Sophia", "Mia", "Charlotte"]
|
||||
games = ["word puzzle", "jigsaw puzzle", "chess puzzle", "riddle", "brain teaser"]
|
||||
periods = ["weekend", "vacation", "holiday", "day off", "free time"]
|
||||
|
||||
name = rng.choice(names)
|
||||
game1, game2 = rng.sample(games, 2)
|
||||
period = rng.choice(periods)
|
||||
|
||||
time1 = int(rng.randint(5, int(30 * difficulty)))
|
||||
time2 = int(rng.randint(3, int(20 * difficulty)))
|
||||
while time2 >= time1: # ensure time1 > time2
|
||||
time1 = int(rng.randint(5, int(30 * difficulty)))
|
||||
time2 = int(rng.randint(3, int(20 * difficulty)))
|
||||
|
||||
num1 = int(rng.randint(2, int(10 * difficulty)))
|
||||
num2 = int(rng.randint(4, int(15 * difficulty)))
|
||||
|
||||
result = generate_from_variables(name, game1, game2, period, time1, time2, num1, num2)
|
||||
|
||||
return {
|
||||
'question': result['question'],
|
||||
'answer': result['answer'],
|
||||
'metadata': {
|
||||
'difficulty': difficulty,
|
||||
'answer_value': result['answer_value'],
|
||||
'answer_cot': result['answer_cot'],
|
||||
'variables': result['variables']
|
||||
}
|
||||
}
|
||||
|
||||
def original_example() -> Dict[str, Any]:
|
||||
return generate_from_variables("Carmen", "crossword puzzle", "sudoku puzzle",
|
||||
"weekend", 10, 5, 3, 8)
|
||||
Loading…
Add table
Add a link
Reference in a new issue