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
2 changes: 1 addition & 1 deletion src/helm/benchmark/metrics/evaluate_reference_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def final_number_exact_match(gold: str, pred: str) -> float:
"""

def get_final_number(x: str) -> str:
matches = re.findall(r"-?[\d,]+(?:.\d+)?", x)
matches = re.findall(r"-?[\d,]+(?:\.\d+)?", x)
if not matches:
return ""
return matches[-1].replace(",", "")
Expand Down
3 changes: 3 additions & 0 deletions src/helm/benchmark/metrics/test_evaluate_reference_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ def test_final_number_exact_match():
assert final_number_exact_match("34.2", "2") == 0
assert final_number_exact_match("342", "342.") == 1
assert final_number_exact_match("3,420", "3420") == 1
# A non-digit, non-dot character between digits must not be treated as part of a number.
assert final_number_exact_match("30", "the meeting is at 7:30") == 1
assert final_number_exact_match("3", "the grid is 2x3") == 1


def test_bleu_1():
Expand Down