Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/evaluate/evaluator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ def check_task(task: str) -> Dict:
"""
if task in TASK_ALIASES:
task = TASK_ALIASES[task]
if not check_pipeline_task(task):
raise KeyError(f"Unknown task {task}, available tasks are: {get_supported_tasks()}.")
if task in SUPPORTED_EVALUATOR_TASKS.keys() and task in SUPPORTED_PIPELINE_TASKS.keys():
if task in SUPPORTED_EVALUATOR_TASKS:
return SUPPORTED_EVALUATOR_TASKS[task]
try:
check_pipeline_task(task)
except KeyError as e:
raise KeyError(f"Unknown task {task}, available tasks are: {get_supported_tasks()}.") from e
raise KeyError(f"Unknown task {task}, available tasks are: {get_supported_tasks()}.")


Expand Down
10 changes: 10 additions & 0 deletions tests/test_evaluator.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,16 @@ def setUp(self):
self.pipe = DummyText2TextGenerationPipeline()
self.evaluator = evaluator("text2text-generation")

def test_text2text_evaluator_tasks_can_be_created(self):
for task, expected_class_name in [
("text2text-generation", "Text2TextGenerationEvaluator"),
("summarization", "SummarizationEvaluator"),
("translation", "TranslationEvaluator"),
]:
e = evaluator(task)
self.assertEqual(type(e).__name__, expected_class_name)
self.assertEqual(e.task, task)

def test_pipe_init(self):
results = self.evaluator.compute(
model_or_pipeline=self.pipe,
Expand Down