Skip to content

Commit

Permalink
added forgotten history_ir_get_choice method change.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fajcik committed Jun 14, 2024
1 parent d475cd8 commit 6f60539
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lm_eval/tasks/benczechmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,18 @@ def aggregation(self) -> dict:
"acc": mean,
}


# MMLU multi-choice style (A....Z)
ANSWER_LETTERS = [chr(ord('A') + i) for i in range(ord('Z') - ord('A') + 1)]


def mmlu_get_choice(dataset):
choice = [c for c in ANSWER_LETTERS if c in dataset.keys()]
if len(choice) == 0:
raise ValueError(f"No answer columns found in dataset")
return choice


def mmlu_get_answer_index(dataset):
return ANSWER_LETTERS.index(dataset["correct_answer"])

Expand All @@ -308,12 +311,17 @@ def cermat_get_choice(dataset):
raise ValueError(f"Invalid number of choices: {len(dataset['choices'])}")


def history_ir_get_choice(dataset):
return ["A", "B", "C", "D"]


def mmlu_get_question_text(dataset):
dataset_answer_keys = mmlu_get_choice(dataset)
question_text = dataset['question'].strip()
choices_text = "\n".join(f"{c}. {dataset[c]}" for c in dataset_answer_keys)
return f"{question_text}\n{choices_text}\nOdpověď: "


def mmlu_get_question_text_umimeto(dataset):
"""
Umimeto has really bad questions, which require the topic at minimum to make sense
Expand All @@ -322,4 +330,4 @@ def mmlu_get_question_text_umimeto(dataset):
question_text = dataset['question'].strip()
choices_text = "\n".join(f"{c}. {dataset[c]}" for c in dataset_answer_keys)
topic = dataset["topic"]
return f"{topic}: {question_text}\n{choices_text}\nOdpověď: "
return f"{topic}: {question_text}\n{choices_text}\nOdpověď: "

0 comments on commit 6f60539

Please sign in to comment.