Skip to content

Commit b81dd63

Browse files
committed
Change input/output to output/expected_output on exact_match evaluator
1 parent 3483ed3 commit b81dd63

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

evaluators/langevals/langevals_langevals/exact_match.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,20 @@ class ExactMatchSettings(EvaluatorSettings):
2828
class ExactMatchResult(EvaluationResult):
2929
passed: Optional[bool] = Field(
3030
default=True,
31-
description="True if the output matched the input exactly, False otherwise",
31+
description="True if the output matched the expected_output exactly, False otherwise",
3232
)
3333

3434

3535
class ExactMatchEntry(EvaluatorEntry):
36-
input: Optional[str] = None
3736
output: Optional[str] = None
37+
expected_output: Optional[str] = None
3838

3939

4040
class ExactMatchEvaluator(
4141
BaseEvaluator[ExactMatchEntry, ExactMatchSettings, ExactMatchResult]
4242
):
4343
"""
44-
A simple evaluator that checks if the output matches the input exactly, with some
45-
extra bells and whistles to help with whitespace related shenanigans.
44+
A simple evaluator that checks if the output matches the expected_output exactly.
4645
"""
4746

4847
name = "Exact Match Evaluator"
@@ -51,21 +50,21 @@ class ExactMatchEvaluator(
5150
is_guardrail = False
5251

5352
def evaluate(self, entry: ExactMatchEntry) -> SingleEvaluationResult:
54-
input_text = entry.input or ""
5553
output_text = entry.output or ""
54+
expected_output_text = entry.expected_output or ""
5655

5756
if self.settings.trim_whitespace:
58-
input_text = input_text.strip()
5957
output_text = output_text.strip()
58+
expected_output_text = expected_output_text.strip()
6059

6160
if self.settings.remove_punctuation:
62-
input_text = ''.join(char for char in input_text if char.isalnum() or char.isspace())
6361
output_text = ''.join(char for char in output_text if char.isalnum() or char.isspace())
62+
expected_output_text = ''.join(char for char in expected_output_text if char.isalnum() or char.isspace())
6463

6564
if not self.settings.case_sensitive:
66-
input_text = input_text.lower()
6765
output_text = output_text.lower()
66+
expected_output_text = expected_output_text.lower()
6867

69-
passed = input_text == output_text
68+
passed = output_text == expected_output_text
7069

7170
return ExactMatchResult(passed=passed)

evaluators/langevals/tests/test_exact_match.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
def test_langeval_exact_match_evaluator():
99
entry = ExactMatchEntry(
10-
input="What is the capital of France?",
1110
output="What is the capital of France?",
11+
expected_output="What is the capital of France?",
1212
)
1313
settings = ExactMatchSettings()
1414

@@ -20,8 +20,8 @@ def test_langeval_exact_match_evaluator():
2020

2121
def test_langeval_exact_match_evaluator_defaults():
2222
entry = ExactMatchEntry(
23-
input="What is the capital of France?",
24-
output="What is the capital of the Netherlands?",
23+
output="What is the capital of France?",
24+
expected_output="What is the capital of the Netherlands?",
2525
)
2626
settings = ExactMatchSettings()
2727

@@ -33,8 +33,8 @@ def test_langeval_exact_match_evaluator_defaults():
3333

3434
def test_langeval_exact_match_case_sensitive_true():
3535
entry = ExactMatchEntry(
36-
input="Hello World",
37-
output="hello world",
36+
output="Hello World",
37+
expected_output="hello world",
3838
)
3939
settings = ExactMatchSettings(case_sensitive=True)
4040

@@ -46,8 +46,8 @@ def test_langeval_exact_match_case_sensitive_true():
4646

4747
def test_langeval_exact_match_case_sensitive_false():
4848
entry = ExactMatchEntry(
49-
input="Hello World",
50-
output="hello world",
49+
output="Hello World",
50+
expected_output="hello world",
5151
)
5252
settings = ExactMatchSettings(case_sensitive=False)
5353

@@ -59,8 +59,8 @@ def test_langeval_exact_match_case_sensitive_false():
5959

6060
def test_langeval_exact_match_trim_whitespace_true():
6161
entry = ExactMatchEntry(
62-
input=" Hello World ",
63-
output="Hello World",
62+
output=" Hello World ",
63+
expected_output="Hello World",
6464
)
6565
settings = ExactMatchSettings(trim_whitespace=True)
6666

@@ -72,8 +72,8 @@ def test_langeval_exact_match_trim_whitespace_true():
7272

7373
def test_langeval_exact_match_trim_whitespace_false():
7474
entry = ExactMatchEntry(
75-
input=" Hello World ",
76-
output="Hello World",
75+
output=" Hello World ",
76+
expected_output="Hello World",
7777
)
7878
settings = ExactMatchSettings(trim_whitespace=False)
7979

@@ -85,8 +85,8 @@ def test_langeval_exact_match_trim_whitespace_false():
8585

8686
def test_langeval_exact_match_remove_punctuation_true():
8787
entry = ExactMatchEntry(
88-
input="Hello, World!",
89-
output="Hello World",
88+
output="Hello, World!",
89+
expected_output="Hello World",
9090
)
9191
settings = ExactMatchSettings(remove_punctuation=True)
9292

@@ -98,8 +98,8 @@ def test_langeval_exact_match_remove_punctuation_true():
9898

9999
def test_langeval_exact_match_remove_punctuation_false():
100100
entry = ExactMatchEntry(
101-
input="Hello, World!",
102-
output="Hello World",
101+
output="Hello, World!",
102+
expected_output="Hello World",
103103
)
104104
settings = ExactMatchSettings(remove_punctuation=False)
105105

@@ -111,8 +111,8 @@ def test_langeval_exact_match_remove_punctuation_false():
111111

112112
def test_langeval_exact_match_combined_settings():
113113
entry = ExactMatchEntry(
114-
input=" Hello, World! ",
115-
output="hello world",
114+
output=" Hello, World! ",
115+
expected_output="hello world",
116116
)
117117
settings = ExactMatchSettings(
118118
case_sensitive=False,

0 commit comments

Comments
 (0)