|
| 1 | +# SPDX-License-Identifier: Apache-2.0 |
| 2 | + |
| 3 | +# Local |
| 4 | +from .evaluator import Evaluator |
| 5 | + |
| 6 | + |
| 7 | +class MMLU_Evaluator(Evaluator): |
| 8 | + """ |
| 9 | + Child class of an Evaluator for Massive Multitask Language Understanding (MMLU) |
| 10 | +
|
| 11 | + Attributes: |
| 12 | + tasks list of tasks for MMLU to test the model with |
| 13 | + few_shots number of examples |
| 14 | + batch_size number of GPUs |
| 15 | + """ |
| 16 | + |
| 17 | + def __init__( |
| 18 | + self, model_path, tasks: list[str], few_shots: int = 2, batch_size: int = 5 |
| 19 | + ) -> None: |
| 20 | + super().__init__(model_path) |
| 21 | + self.tasks = tasks |
| 22 | + self.few_shots = few_shots |
| 23 | + self.batch_size = batch_size |
| 24 | + |
| 25 | + def run(self) -> tuple: |
| 26 | + """ |
| 27 | + Runs MMLU evaluation |
| 28 | +
|
| 29 | + Returns: |
| 30 | + overall_score MMLU score for the overall model evaluation |
| 31 | + individual_scores Individual MMLU score for each task |
| 32 | + """ |
| 33 | + individual_scores: dict[str, float] = {} |
| 34 | + overall_score: float = 0.0 |
| 35 | + return overall_score, individual_scores |
| 36 | + |
| 37 | + |
| 38 | +class PR_MMLU_Evaluator(Evaluator): |
| 39 | + """ |
| 40 | + Child class of an Evaluator for PR Massive Multitask Language Understanding (PR MMLU) |
| 41 | +
|
| 42 | + Attributes: |
| 43 | + sdg_path path where all the PR MMLU tasks are stored |
| 44 | + task group name that is shared by all the PR MMLU tasks |
| 45 | + few_shots number of examples |
| 46 | + batch_size number of GPUs |
| 47 | + """ |
| 48 | + |
| 49 | + def __init__( |
| 50 | + self, |
| 51 | + model_path, |
| 52 | + sdg_path: str, |
| 53 | + task: str = "mmlu_pr", |
| 54 | + few_shots: int = 2, |
| 55 | + batch_size: int = 5, |
| 56 | + ) -> None: |
| 57 | + super().__init__(model_path) |
| 58 | + self.sdg_path = sdg_path |
| 59 | + self.task = task |
| 60 | + self.few_shots = few_shots |
| 61 | + self.batch_size = batch_size |
| 62 | + |
| 63 | + def run(self) -> tuple: |
| 64 | + """ |
| 65 | + Runs PR MMLU evaluation |
| 66 | +
|
| 67 | + Returns: |
| 68 | + overall_score PR MMLU score for the overall model evaluation |
| 69 | + individual_scores Individual PR MMLU scores for each task |
| 70 | + qa_pairs Question and answer pairs from the evaluation |
| 71 | + """ |
| 72 | + individual_scores: dict[str, float] = {} |
| 73 | + overall_score: float = 0.0 |
| 74 | + qa_pairs: list[tuple] = [] |
| 75 | + return overall_score, individual_scores, qa_pairs |
0 commit comments