Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial skeleton for Evaluator classes and exceptions #6

Merged
merged 11 commits into from
Jun 17, 2024
13 changes: 13 additions & 0 deletions src/instructlab/eval/evaluator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-License-Identifier: Apache-2.0


class Evaluator:
"""
Parent class for Evaluators
"""

def __init__(self, model) -> None:
self.model = model

def run(self) -> dict:
nathan-weinberg marked this conversation as resolved.
Show resolved Hide resolved
return {}
18 changes: 18 additions & 0 deletions src/instructlab/eval/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# SPDX-License-Identifier: Apache-2.0


class EvalError(Exception):
"""
Parent class for all of instructlab-eval exceptions
"""


class ModelNotFoundError(EvalError):
"""
Exception raised when model is not able to be found
"""

def __init__(self, model) -> None:
super().__init__()
self.model = model
nathan-weinberg marked this conversation as resolved.
Show resolved Hide resolved
self.message = f"Model {self.model} could not be found"
31 changes: 31 additions & 0 deletions src/instructlab/eval/mmlu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: Apache-2.0

# Local
from .evaluator import Evaluator


class MMLU_Evaluator(Evaluator):
"""
Child class of an Evaluator for Massive Multitask Language Understanding (MMLU)
"""

def __init__(self, model, tasks: list[str], fewshots: int, batchsize: int) -> None:
nathan-weinberg marked this conversation as resolved.
Show resolved Hide resolved
super().__init__(model)
self.tasks = tasks
self.fewshots = fewshots
self.batchsize = batchsize


class PR_MMLU_Evaluator(Evaluator):
"""
Child class of an Evaluator for PR Massive Multitask Language Understanding (PR MMLU)
"""

def __init__(
self, model, task: str, sdg_path: str, fewshots: int, batchsize: int
) -> None:
super().__init__(model)
self.task = task
self.sdg_path = sdg_path
self.fewshots = fewshots
self.batchsize = batchsize
25 changes: 25 additions & 0 deletions src/instructlab/eval/mtbench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# SPDX-License-Identifier: Apache-2.0

# Local
from .evaluator import Evaluator


class MT_Bench_Evaluator(Evaluator):
"""
Child class of an Evaluator for Multi-turn Benchmark (MT-Bench)
"""

def __init__(self, model, server: str) -> None:
nathan-weinberg marked this conversation as resolved.
Show resolved Hide resolved
nathan-weinberg marked this conversation as resolved.
Show resolved Hide resolved
super().__init__(model)
self.server = server


class PR_Bench_Evaluator(Evaluator):
"""
Child class of an Evaluator for PR-Bench Benchmark (PR-Bench)
"""

def __init__(self, model, server: str, questions: str) -> None:
super().__init__(model)
self.server = server
self.questions = questions