-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #89 from KennethEnevoldsen/stuff_runs_tests
Added integration test for four model types
- Loading branch information
Showing
5 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from datetime import datetime | ||
|
||
import pytest | ||
|
||
import seb | ||
from seb.cli import run_benchmark_cli | ||
from seb.registries import tasks | ||
|
||
|
||
@tasks.register("test-encode-task") | ||
def create_test_encode_task() -> seb.Task: | ||
class DummyTask(seb.Task): | ||
name = "test-encode-task" | ||
main_score = "a_metric" | ||
description = "NA" | ||
reference = "NA" | ||
version = "NA" | ||
languages = [] # noqa: RUF012 | ||
domain = [] # noqa: RUF012 | ||
task_type = "Classification" | ||
|
||
def evaluate(self, model: seb.Encoder) -> seb.TaskResult: | ||
model.encode(["a test sentence"], task=self) | ||
|
||
return seb.TaskResult( | ||
task_name="test-encode-task", | ||
task_description="NA", | ||
task_version="NA", | ||
time_of_run=datetime.now(), | ||
scores={"en": {"a_metric": 1.0}}, | ||
main_score="a_metric", | ||
) | ||
|
||
def get_descriptive_stats(self) -> dict: | ||
return {} | ||
|
||
return DummyTask() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model", | ||
[ | ||
"fasttext-cc-da-300", | ||
"intfloat/e5-small", | ||
"translate-e5-small", | ||
], | ||
) | ||
def test_integration_dummy(model: str): | ||
"""Runs all sorts of models on a dummy task to see if they can run without breaking. | ||
Cache is ignored so that the models are actually run. | ||
""" | ||
tasks = ["test-encode-task"] | ||
run_benchmark_cli(models=[model], tasks=tasks, ignore_cache=True) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"model", | ||
[ | ||
"sentence-transformers/all-MiniLM-L6-v2", | ||
], | ||
) | ||
def test_integration_lcc(model: str): | ||
"""Runs model(s) on LCC to see if everything works in order with tasks included.""" | ||
tasks = ["LCC"] | ||
run_benchmark_cli(models=[model], tasks=tasks, ignore_cache=True) |