From 5efa9fb748c920df015366c65565998f09f9a0af Mon Sep 17 00:00:00 2001 From: Ryokan Ri Date: Tue, 7 Jan 2025 10:19:28 +0900 Subject: [PATCH] remove NoopNormalizer --- .../core/metric/string_processor/__init__.py | 1 - flexeval/core/metric/string_processor/noop.py | 20 ------------------- .../core/metric/string_processor/test_noop.py | 16 --------------- 3 files changed, 37 deletions(-) delete mode 100644 flexeval/core/metric/string_processor/noop.py delete mode 100644 tests/core/metric/string_processor/test_noop.py diff --git a/flexeval/core/metric/string_processor/__init__.py b/flexeval/core/metric/string_processor/__init__.py index 71a07f9..c15d1e2 100644 --- a/flexeval/core/metric/string_processor/__init__.py +++ b/flexeval/core/metric/string_processor/__init__.py @@ -3,6 +3,5 @@ from .last_line import LastLineExtractor from .lower import StringLower from .nfkc import NFKCNormalizer -from .noop import NoopNormalizer from .regex import RegexExtractor from .string_strip import StringStrip diff --git a/flexeval/core/metric/string_processor/noop.py b/flexeval/core/metric/string_processor/noop.py deleted file mode 100644 index 071a8fa..0000000 --- a/flexeval/core/metric/string_processor/noop.py +++ /dev/null @@ -1,20 +0,0 @@ -from .base import StringProcessor - - -class NoopNormalizer(StringProcessor): - r""" - A processor that does nothing. - Some metrics apply normalization to both the LM outputs and references by default. - If you want to explicitly disable normalization for the references, you can use this processor. - - Examples: - >>> from flexeval import ExactMatch, NoopNormalizer, RegexExtractor - >>> metric = ExactMatch(processor=RegexExtractor(r"\d+"), reference_processor=NoopNormalizer()) - >>> lm_output = "The answer is 10." - >>> reference = "10" - >>> print(metric.evaluate([lm_output], [[reference]])) - - """ - - def __call__(self, text: str) -> str: - return text diff --git a/tests/core/metric/string_processor/test_noop.py b/tests/core/metric/string_processor/test_noop.py deleted file mode 100644 index 16373ba..0000000 --- a/tests/core/metric/string_processor/test_noop.py +++ /dev/null @@ -1,16 +0,0 @@ -import pytest - -from flexeval.core.metric.string_processor import NoopNormalizer - - -@pytest.mark.parametrize( - "text", - [ - "answer", - "evidence\nanswer", - "", - ], -) -def test_last_line_extractor(text: str) -> None: - extractor = NoopNormalizer() - assert extractor(text) == text