3030
3131import numpy as np
3232import pycountry
33- from inspect_ai .dataset import Sample
3433
3534from lighteval .tasks .requests import Doc
3635from lighteval .utils .utils import as_list
@@ -131,14 +130,21 @@ def simpleqa(line, task_name: str = None):
131130 )
132131
133132
134- def aime_prompt_fn (record ):
133+ def aime_prompt_fn (line , task_name : str = None ):
135134 # Prompt template adapted from
136135 # - simple-evals: https://github.com/openai/simple-evals/blob/6e84f4e2aed6b60f6a0c7b8f06bbbf4bfde72e58/math_eval.py#L17
137136 # - Llama 3: https://huggingface.co/datasets/meta-llama/Llama-3.2-1B-Instruct-evals/viewer/Llama-3.2-1B-Instruct-evals__math__details?views%5B%5D=llama_32_1b_instruct_evals__math__details
138137 # Note that it is important to have the final answer in a box for math-verify to work correctly
139- return Sample (
140- input = record ["problem" ],
141- target = record ["answer" ],
138+ MATH_QUERY_TEMPLATE = """
139+ Solve the following math problem efficiently and clearly. The last line of your response should be of the following format: 'Therefore, the final answer is: $\\ boxed{{ANSWER}}$. I hope it is correct' (without quotes) where ANSWER is just the final number or expression that solves the problem. Think step by step before answering.
140+
141+ {Question}
142+ """ .strip ()
143+ return Doc (
144+ task_name = task_name ,
145+ query = MATH_QUERY_TEMPLATE .format (Question = line ["problem" ]),
146+ choices = [line ["answer" ]],
147+ gold_index = 0 ,
142148 )
143149
144150
@@ -330,7 +336,7 @@ def bbh_harness(line, task_name: str = None):
330336 )
331337
332338
333- def bbh (line , task_name : str = None ):
339+ def bbh_lighteval (line , task_name : str = None ):
334340 line = {k : v for k , v in line .items () if v is not None }
335341
336342 query = line .get ("task_prefix" , "" )
@@ -349,6 +355,16 @@ def bbh(line, task_name: str = None):
349355 )
350356
351357
358+ def bbh (line , instruction , choices , task_name : str = None ):
359+ return Doc (
360+ task_name = task_name ,
361+ query = f"{ instruction } Q: { line ['input' ]} \n A:" ,
362+ choices = choices ,
363+ gold_index = choices .index (line ["target" ]),
364+ instruction = instruction ,
365+ )
366+
367+
352368def bbh_boolean_expressions (line , task_name : str = None ):
353369 instruction = "Evaluate the result of a random Boolean expression.\n \n "
354370 choices = ["False" , "True" ]
@@ -878,19 +894,6 @@ def gpqa(line, task_name: str = None):
878894 )
879895
880896
881- # def gpqa_instruct(record):
882- # """Prompt template adapted from simple-evals: https://github.com/openai/simple-evals/blob/83ed7640a7d9cd26849bcb3340125002ef14abbe/common.py#L14"""
883- # gold_index = random.randint(0, 3)
884- # choices = [record["Incorrect Answer 1"], record["Incorrect Answer 2"], record["Incorrect Answer 3"]]
885- # choices.insert(gold_index, record["Correct Answer"])
886-
887- # return Sample(
888- # input=record["Question"].strip(),
889- # choices=choices,
890- # target=LETTER_INDICES[gold_index],
891- # )
892-
893-
894897def gpqa_instruct (line , task_name : str = None ):
895898 """Prompt template adapted from simple-evals: https://github.com/openai/simple-evals/blob/83ed7640a7d9cd26849bcb3340125002ef14abbe/common.py#L14"""
896899 gold_index = random .randint (0 , 3 )
@@ -917,22 +920,29 @@ def gpqa_instruct(line, task_name: str = None):
917920 )
918921
919922
920- def gsm_plus (record ):
923+ def gsm_plus (line , task_name : str = None ):
921924 # GSM8K with 8 prompt variations per sample
922925
923926 # Some prompts require critical thinking (around 1k/10k), we skip them as
924927 # they are a bit trickier to eval with regular text extraction.
928+ if line ["perturbation_type" ] == "critical thinking" :
929+ return None
925930
926- return Sample (
927- input = record ["question" ],
928- target = record ["answer" ],
931+ return Doc (
932+ task_name = task_name ,
933+ query = f"Question: { line ['question' ]} \n \n Answer:" ,
934+ choices = [line ["answer" ]],
935+ gold_index = 0 ,
929936 )
930937
931938
932- def gsm8k (record ):
933- return Sample (
934- input = record ["question" ],
935- target = record ["answer" ],
939+ def gsm8k (line , task_name : str = None ):
940+ # Has special analysis in metric for number decomposition
941+ return Doc (
942+ task_name = task_name ,
943+ query = f"Question: { line ['question' ]} \n Answer:" ,
944+ choices = [f" { line ['answer' ]} " ],
945+ gold_index = 0 ,
936946 )
937947
938948
0 commit comments