|
| 1 | +from opencompass.openicl.icl_prompt_template import PromptTemplate |
| 2 | +from opencompass.openicl.icl_retriever import ZeroRetriever |
| 3 | +from opencompass.openicl.icl_inferencer import AgentInferencer |
| 4 | +from opencompass.datasets import ( |
| 5 | + MATHDataset, MATHAgentEvaluator, math_postprocess |
| 6 | +) |
| 7 | +# use pal format but not perform well |
| 8 | +math_reader_cfg = dict(input_columns=['problem'], output_column='solution') |
| 9 | + |
| 10 | +math_infer_cfg = dict( |
| 11 | + prompt_template=dict( |
| 12 | + type=PromptTemplate, |
| 13 | + template=dict( |
| 14 | + round=[ |
| 15 | + # # ################################### NEW SHOT ################################### |
| 16 | + dict(role='HUMAN', prompt='Find the coefficient of $x^3$ when $3(x^2 - x^3+x) +3(x +2x^3- 3x^2 + 3x^5+x^3) -5(1+x-4x^3 - x^2)$ is simplifie.'), |
| 17 | + dict(role='BOT', prompt="""Tool:PythonInterpreter\nTool Input:from sympy import symbols, simplify |
| 18 | +
|
| 19 | +def solution(): |
| 20 | + x = symbols('x') |
| 21 | + expr = 3*(x**2 - x**3 + x) + 3*(x + 2*x**3 - 3*x**2 + 3*x**5 + x**3) - 5*(1 + x - 4*x**3 - x**2) |
| 22 | + simplified_expr = simplify(expr) |
| 23 | +
|
| 24 | + x3_coefficient = simplified_expr.as_coefficients_dict()[x**3] |
| 25 | + result = x3_coefficient |
| 26 | + return result"""), |
| 27 | + dict(role='SYSTEM', prompt='Response:26'), |
| 28 | + dict(role='BOT', prompt='FinalAnswer: The final answer is $26$. I hope it is correct.'), |
| 29 | + dict(role='HUMAN', prompt='The surface area of a sphere with radius $r$ is $4\pi r^2$. Including the area of its circular base, what is the total surface area of a hemisphere with radius 6 cm? Express your answer in terms of $\pi$.'), |
| 30 | + dict(role='BOT', prompt="""Tool:PythonInterpreter\nTool Input:import math |
| 31 | +
|
| 32 | +def solution(): |
| 33 | + radius = 6 |
| 34 | +
|
| 35 | + # Surface area of the hemisphere |
| 36 | + hemisphere_area = 2 * math.pi * radius**2 |
| 37 | +
|
| 38 | + # Area of the circular base |
| 39 | + base_area = math.pi * radius**2 |
| 40 | +
|
| 41 | + # Total surface area |
| 42 | + total_surface_area = hemisphere_area + base_area |
| 43 | +
|
| 44 | + # Formatting the result in LaTeX |
| 45 | + result = r'{}\pi'.format(total_surface_area / math.pi) |
| 46 | + return result"""), |
| 47 | + dict(role='SYSTEM', prompt='Response:108.0\\pi'), |
| 48 | + dict(role='BOT', prompt='FinalAnswer: The final answer is $108.0\pi$. I hope it is correct.'), |
| 49 | + dict(role='HUMAN', prompt='Monica tosses a fair 6-sided die. If the roll is a prime number, then she wins that amount of dollars (so that, for example, if she rolls 3, then she wins 3 dollars). If the roll is composite, she wins nothing. Otherwise, she loses 3 dollars. What is the expected value of her winnings on one die toss? Express your answer as a dollar value to the nearest cent.'), |
| 50 | + dict(role='BOT', prompt="""Tool:PythonInterpreter\nTool Input:def solution(): |
| 51 | + # Probabilities of each outcome |
| 52 | + prime_prob = 1 / 6 |
| 53 | + composite_prob = 1 / 3 |
| 54 | + otherwise_prob = 1 / 6 |
| 55 | +
|
| 56 | + # Expected value of each outcome |
| 57 | + prime_expected_value = (2 * prime_prob) + (3 * prime_prob) + (5 * prime_prob) |
| 58 | + composite_expected_value = 0 * composite_prob |
| 59 | + otherwise_expected_value = -3 * otherwise_prob |
| 60 | +
|
| 61 | + # Total expected value |
| 62 | + total_expected_value = prime_expected_value + composite_expected_value + otherwise_expected_value |
| 63 | +
|
| 64 | + # Dollar value to the nearest cent |
| 65 | + result = "{:.2f}".format(total_expected_value) |
| 66 | + return result"""), |
| 67 | + dict(role='SYSTEM', prompt='Response:1.17'), |
| 68 | + dict(role='BOT', prompt='FinalAnswer: The final answer is $1.17$. I hope it is correct.'), |
| 69 | + dict(role='HUMAN', prompt='{problem}'), |
| 70 | + ])), |
| 71 | + retriever=dict(type=ZeroRetriever), |
| 72 | + inferencer=dict(type=AgentInferencer), |
| 73 | +) |
| 74 | + |
| 75 | +math_eval_cfg = dict( |
| 76 | + evaluator=dict(type=MATHAgentEvaluator), |
| 77 | + pred_postprocessor=dict(type=math_postprocess), |
| 78 | +) |
| 79 | + |
| 80 | +math_datasets = [ |
| 81 | + dict( |
| 82 | + abbr='math', |
| 83 | + type=MATHDataset, |
| 84 | + path='./data/math/math.json', |
| 85 | + reader_cfg=math_reader_cfg, |
| 86 | + infer_cfg=math_infer_cfg, |
| 87 | + eval_cfg=math_eval_cfg, |
| 88 | + ) |
| 89 | +] |
0 commit comments