Skip to content

Commit 6a0c615

Browse files
committed
revert uneeded changes
1 parent f53bd76 commit 6a0c615

3 files changed

Lines changed: 38 additions & 55 deletions

File tree

src/lighteval/metrics/utils/extractive_match_utils.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,17 +345,13 @@ def lazy_indices_regex(
345345

346346

347347
def get_extraction_regexes(
348-
# target_types: Sequence[ExtractionTarget], language: Language, len_choices: int = 1
349-
formatted_doc: Doc,
350-
target_types: Sequence[ExtractionTarget],
351-
language: Language,
348+
formatted_doc: Doc, target_types: Sequence[ExtractionTarget], language: Language
352349
) -> list[tuple[list[tuple[re.Pattern[str], int]], ExtractionTarget]]:
353350
extraction_regexes: list[tuple[list[tuple[re.Pattern[str], int]], ExtractionTarget]] = [
354351
(lazy_latex_regex(target_type, language), target_type)
355352
if isinstance(target_type, LatexExtractionConfig)
356353
else (lazy_expr_regex(target_type, language), target_type)
357354
if isinstance(target_type, ExprExtractionConfig)
358-
# else (lazy_indices_regex(target_type, len_choices, language), target_type)
359355
else (lazy_indices_regex(target_type, len(formatted_doc.choices), language), target_type)
360356
for target_type in target_types
361357
]

src/lighteval/tasks/default_prompts.py

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030

3131
import numpy as np
3232
import pycountry
33-
from inspect_ai.dataset import Sample
3433

3534
from lighteval.tasks.requests import Doc
3635
from 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']}\nA:",
362+
choices=choices,
363+
gold_index=choices.index(line["target"]),
364+
instruction=instruction,
365+
)
366+
367+
352368
def 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-
894897
def 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\nAnswer:",
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']}\nAnswer:",
944+
choices=[f" {line['answer']}"],
945+
gold_index=0,
936946
)
937947

938948

src/lighteval/tasks/lighteval_task.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
from datasets import DatasetDict, load_dataset
2929
from huggingface_hub import TextGenerationInputGrammarType
30-
from inspect_ai.dataset import Sample
3130
from multiprocess import Pool
3231
from pytablewriter import MarkdownTableWriter
3332

@@ -44,28 +43,6 @@
4443
logger = logging.getLogger(__name__)
4544

4645

47-
@dataclass
48-
class LightevalTaskConfig_inspect:
49-
"""Configuration dataclass for a LightevalTask.
50-
51-
This class stores all the configuration parameters needed to define and run
52-
an evaluation task, including dataset information, prompt formatting,
53-
evaluation metrics, and generation parameters.
54-
"""
55-
56-
name: str
57-
prompt_function: Callable[[dict], Sample]
58-
dataset_repo: str
59-
dataset_subset: str
60-
dataset_split: str
61-
scorers: list
62-
solvers: list | None = None
63-
system_prompt: str | None = None
64-
dataset_revision: str | None = None
65-
epochs: int = 1
66-
epochs_reducer: str | None = None
67-
68-
6946
@dataclass
7047
class LightevalTaskConfig:
7148
"""Configuration dataclass for a LightevalTask.

0 commit comments

Comments
 (0)