diff --git a/play.py b/play.py new file mode 100644 index 00000000..d7b42410 --- /dev/null +++ b/play.py @@ -0,0 +1,6 @@ +import reasoning_gym +data = reasoning_gym.create_dataset('polynomial_equations', size=3, seed=42) +for i, x in enumerate(data): + print(f"{i}: question={x['question']}\n") + print(f"{i}: answer={x['answer']}\n") + print('metadata:', x['metadata']) \ No newline at end of file diff --git a/reasoning_gym/algebra/intermediate_integration.py b/reasoning_gym/algebra/intermediate_integration.py index 34e144df..84e01d9b 100644 --- a/reasoning_gym/algebra/intermediate_integration.py +++ b/reasoning_gym/algebra/intermediate_integration.py @@ -77,11 +77,10 @@ class IntermediateIntegrationDataset(ProceduralDataset): "Evaluate the indefinite integral: ∫ {integrand} dx", ] self.added_instruction = """ - \n\n - In addition, When doing calculation, Use the following instructions together with your mathematical ingenuity to solve the integral problems - ## 1. Use ** instead ^ to represent powers. For example 7*X**2 instead of 7*X^2. - ## 2. Always use * when doing all sorts of multiplcation in your reasoning steps. For example Use [-3*X**3*sin(X) - 9*X**2*cos(X) + 18*X*sin(X) + 18*cos(X) + C] instead of [-3x3sin(x) - 9x2cos(x) + 18xsin(x) + 18cos(x) + C]. - """ +In addition, when doing calculation, use the following instructions together with your mathematical ingenuity to solve the integral problems +## 1. Use ** instead ^ to represent powers. For example 7*X**2 instead of 7*X^2. +## 2. Always use * when doing all sorts of multiplcation in your reasoning steps. For example Use [-3*X**3*sin(X) - 9*X**2*cos(X) + 18*X*sin(X) + 18*cos(X) + C] instead of [-3x3sin(x) - 9x2cos(x) + 18xsin(x) + 18cos(x) + C]. +""" def _get_outer_constant(self, rng: random.Random) -> int: """Helper to generate signed outer constant from config""" diff --git a/reasoning_gym/algebra/polynomial_equations.py b/reasoning_gym/algebra/polynomial_equations.py index 88aac334..dad8a0b0 100644 --- a/reasoning_gym/algebra/polynomial_equations.py +++ b/reasoning_gym/algebra/polynomial_equations.py @@ -62,7 +62,8 @@ class PolynomialEquationsDataset(ProceduralDataset): "Determine the real value(s) of {variable} that satisfies: {polynomial_expanded} = 0", "Solve the polynomial equation for real {variable}:\n{polynomial_expanded} = 0", ] - self.added_instruction = """In solving the equations, please abide by the following instruction: + self.added_instruction = """ +In solving the equations, please abide by the following instruction: ## 1. All answers should be comma-separated. For example "-0.3773, 0.4005" etc. ## 2. In cases where your answer is b = 2 + sqrt(4560) / 172 and b = 2 - sqrt(4560) / 172. Since b can be 2 numbers, resolve your answer like this instead, "-0.3773, 0.4005". ## 3. If there are no real values of i that satisfy the equation, report your answer as empty string, "". diff --git a/reasoning_gym/algebra/polynomial_multiplication.py b/reasoning_gym/algebra/polynomial_multiplication.py index d0c472b3..67a914e8 100644 --- a/reasoning_gym/algebra/polynomial_multiplication.py +++ b/reasoning_gym/algebra/polynomial_multiplication.py @@ -62,11 +62,10 @@ class PolynomialMultiplicationDataset(ProceduralDataset): "Calculate the following: {polynomial_expr}", ] self.added_instruction = """ - \n\n - In addition, When doing calculation, Use the following instructions together with your mathematical ingenuity to solve the integral problems - ## 1. Use ** instead ^ to represent powers. For example 7*X**2 instead of 7*X^2. - ## 2. Always use * when doing all sorts of multiplcation in your reasoning steps and even in reporting answers. - """ +In addition, When doing calculation, Use the following instructions together with your mathematical ingenuity to solve the integral problems +## 1. Use ** instead ^ to represent powers. For example 7*X**2 instead of 7*X^2. +## 2. Always use * when doing all sorts of multiplcation in your reasoning steps and even in reporting answers. +""" super().__init__(config=config, seed=config.seed, size=config.size) def __getitem__(self, idx: int) -> dict: diff --git a/reasoning_gym/algebra/simple_integration.py b/reasoning_gym/algebra/simple_integration.py index d056bc7c..8dfa775b 100644 --- a/reasoning_gym/algebra/simple_integration.py +++ b/reasoning_gym/algebra/simple_integration.py @@ -42,11 +42,10 @@ class SimpleIntegrationDataset(ProceduralDataset): "Evaluate the indefinite integral: ∫ {integrand} dx", ] self.added_instruction = """ - \n\n - In addition, When doing calculation, Use the following instructions together with your mathematical ingenuity to solve the integral problems - ## 1. Use ** instead ^ to represent powers. For example 7*X**2 instead of 7*X^2. - ## 2. Always use * when doing all sorts of multiplcation in your reasoning steps. For example Use [-3*X**3*sin(X) - 9*X**2*cos(X) + 18*X*sin(X) + 18*cos(X) + C] instead of [-3x3sin(x) - 9x2cos(x) + 18xsin(x) + 18cos(x) + C]. - """ +In addition, When doing calculation, Use the following instructions together with your mathematical ingenuity to solve the integral problems +## 1. Use ** instead ^ to represent powers. For example 7*X**2 instead of 7*X^2. +## 2. Always use * when doing all sorts of multiplcation in your reasoning steps. For example Use [-3*X**3*sin(X) - 9*X**2*cos(X) + 18*X*sin(X) + 18*cos(X) + C] instead of [-3x3sin(x) - 9x2cos(x) + 18xsin(x) + 18cos(x) + C]. +""" super().__init__(config=config, seed=config.seed, size=config.size) def _generate_coefficient(self, rng: random.Random) -> Fraction: diff --git a/reasoning_gym/algorithmic/number_sorting.py b/reasoning_gym/algorithmic/number_sorting.py index 39dfda99..f906d230 100644 --- a/reasoning_gym/algorithmic/number_sorting.py +++ b/reasoning_gym/algorithmic/number_sorting.py @@ -35,11 +35,10 @@ class NumberSortingDataset(ProceduralDataset): def __init__(self, config: NumberSortingConfig): super().__init__(config=config, seed=config.seed, size=config.size) self.added_instruction = """ - \n\n - Please follow the instruction below: - # 1. Let all your answers be a list of numbers. Instead of reporting your answer as -69, -13, 1, 7, 11, 43, 59, 61, use ['-69', '-13', '1', '7', '11', '43', '59', '61'] instead - # 2. Convert all numbers in the square brackets as strings. For example, ['-69', '-13', '1', '7', '11', '43', '59', '61'] - """ +Please follow the instruction below: +## 1. Let all your answers be a list of numbers. Instead of reporting your answer as -69, -13, 1, 7, 11, 43, 59, 61, use ['-69', '-13', '1', '7', '11', '43', '59', '61'] instead +## 2. Convert all numbers in the square brackets as strings. For example, ['-69', '-13', '1', '7', '11', '43', '59', '61'] +""" def _format_number(self, num: float, decimals: int) -> str: """Format number with specified decimal places""" diff --git a/tests/test_polynomial_equations.py b/tests/test_polynomial_equations.py index 420187de..e4e72b18 100644 --- a/tests/test_polynomial_equations.py +++ b/tests/test_polynomial_equations.py @@ -112,7 +112,7 @@ def test_polynomial_solutions_evaluation(): evaluated_value = poly_expr.subs(x, solution) # Ensure the evaluated value is close to zero (numerical stability threshold) - assert abs(evaluated_value) < 1e-6, ( + assert abs(evaluated_value) < 1e-5, ( f"Solution {solution} does not satisfy the polynomial {poly_str}. " f"Evaluated value: {evaluated_value}" )