Upload metric.py with huggingface_hub
Browse files
metric.py
CHANGED
|
@@ -26,42 +26,45 @@ from .metrics import __file__ as _
|
|
| 26 |
from .normalizers import __file__ as _
|
| 27 |
from .operator import __file__ as _
|
| 28 |
from .operators import __file__ as _
|
|
|
|
| 29 |
from .processors import __file__ as _
|
| 30 |
from .random_utils import __file__ as _
|
| 31 |
from .recipe import __file__ as _
|
| 32 |
from .register import __file__ as _
|
| 33 |
from .schema import __file__ as _
|
| 34 |
-
from .serializers import __file__ as _
|
| 35 |
from .settings_utils import __file__ as _
|
|
|
|
|
|
|
| 36 |
from .split_utils import __file__ as _
|
| 37 |
from .splitters import __file__ as _
|
| 38 |
from .standard import __file__ as _
|
| 39 |
from .stream import __file__ as _
|
|
|
|
|
|
|
| 40 |
from .task import __file__ as _
|
| 41 |
from .templates import __file__ as _
|
| 42 |
from .text_utils import __file__ as _
|
| 43 |
from .type_utils import __file__ as _
|
| 44 |
from .utils import __file__ as _
|
|
|
|
| 45 |
from .validate import __file__ as _
|
| 46 |
from .version import __file__ as _
|
| 47 |
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
# TODO: currently we have two classes with this name. metric.Metric and matrics.Metric...
|
| 50 |
-
# @evaluate.utils.file_utils.add_start_docstrings(_DESCRIPTION, _KWARGS_DESCRIPTION)
|
| 51 |
class Metric(evaluate.Metric):
|
| 52 |
calc_confidence_intervals: bool = True
|
| 53 |
|
|
|
|
|
|
|
| 54 |
def _info(self):
|
| 55 |
return evaluate.MetricInfo(
|
| 56 |
description="_DESCRIPTION",
|
| 57 |
citation="_CITATION",
|
| 58 |
-
# inputs_description=_KWARGS_DESCRIPTION,
|
| 59 |
features=UNITXT_METRIC_SCHEMA,
|
| 60 |
-
codebase_urls=[
|
| 61 |
-
reference_urls=[
|
| 62 |
-
"https://",
|
| 63 |
-
"https://",
|
| 64 |
-
],
|
| 65 |
)
|
| 66 |
|
| 67 |
def _compute(
|
|
@@ -71,14 +74,18 @@ class Metric(evaluate.Metric):
|
|
| 71 |
flatten: bool = False,
|
| 72 |
split_name: str = "all",
|
| 73 |
):
|
| 74 |
-
|
| 75 |
-
from unitxt.
|
|
|
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
-
if unitxt_installed:
|
| 82 |
return _compute_installed(
|
| 83 |
predictions=predictions,
|
| 84 |
references=references,
|
|
|
|
| 26 |
from .normalizers import __file__ as _
|
| 27 |
from .operator import __file__ as _
|
| 28 |
from .operators import __file__ as _
|
| 29 |
+
from .parsing_utils import __file__ as _
|
| 30 |
from .processors import __file__ as _
|
| 31 |
from .random_utils import __file__ as _
|
| 32 |
from .recipe import __file__ as _
|
| 33 |
from .register import __file__ as _
|
| 34 |
from .schema import __file__ as _
|
|
|
|
| 35 |
from .settings_utils import __file__ as _
|
| 36 |
+
from .settings_utils import get_constants
|
| 37 |
+
from .span_lableing_operators import __file__ as _
|
| 38 |
from .split_utils import __file__ as _
|
| 39 |
from .splitters import __file__ as _
|
| 40 |
from .standard import __file__ as _
|
| 41 |
from .stream import __file__ as _
|
| 42 |
+
from .struct_data_operators import __file__ as _
|
| 43 |
+
from .system_prompts import __file__ as _
|
| 44 |
from .task import __file__ as _
|
| 45 |
from .templates import __file__ as _
|
| 46 |
from .text_utils import __file__ as _
|
| 47 |
from .type_utils import __file__ as _
|
| 48 |
from .utils import __file__ as _
|
| 49 |
+
from .utils import is_package_installed
|
| 50 |
from .validate import __file__ as _
|
| 51 |
from .version import __file__ as _
|
| 52 |
|
| 53 |
+
constants = get_constants()
|
| 54 |
+
|
| 55 |
|
|
|
|
|
|
|
| 56 |
class Metric(evaluate.Metric):
|
| 57 |
calc_confidence_intervals: bool = True
|
| 58 |
|
| 59 |
+
VERSION = constants.version
|
| 60 |
+
|
| 61 |
def _info(self):
|
| 62 |
return evaluate.MetricInfo(
|
| 63 |
description="_DESCRIPTION",
|
| 64 |
citation="_CITATION",
|
|
|
|
| 65 |
features=UNITXT_METRIC_SCHEMA,
|
| 66 |
+
codebase_urls=[constants.codebase_url],
|
| 67 |
+
reference_urls=[constants.website_url],
|
|
|
|
|
|
|
|
|
|
| 68 |
)
|
| 69 |
|
| 70 |
def _compute(
|
|
|
|
| 74 |
flatten: bool = False,
|
| 75 |
split_name: str = "all",
|
| 76 |
):
|
| 77 |
+
if is_package_installed("unitxt"):
|
| 78 |
+
from unitxt.settings_utils import \
|
| 79 |
+
get_constants as installed_get_constants
|
| 80 |
|
| 81 |
+
installed_package_constants = installed_get_constants()
|
| 82 |
+
if installed_package_constants.version != self.VERSION:
|
| 83 |
+
raise ValueError(
|
| 84 |
+
f"Located installed unitxt version {installed_get_constants.version} that is different then unitxt metric version {self.VERSION}. Please make sure the installed version is identical to the dataset version."
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
from unitxt.metric_utils import _compute as _compute_installed
|
| 88 |
|
|
|
|
| 89 |
return _compute_installed(
|
| 90 |
predictions=predictions,
|
| 91 |
references=references,
|