Skip to content
Open
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 ais_bench/benchmark/datasets/gsm8k.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def gsm8k_dataset_postprocess(text: str) -> str:

@TEXT_POSTPROCESSORS.register_module('gsm8k')
def gsm8k_postprocess(text: str) -> str:
text = text.split('Question:')[0]
text = text.split('Question:')[0].replace(',', '')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Blindly replacing all commas with an empty string can lead to incorrect parsing of numbers that are separated by commas without spaces (e.g., a list of numbers like 1,2 or coordinates). For example, 1,2 would be merged into 12, causing the postprocessor to extract 12 instead of 2.

To safely remove only thousand separators, you can use a regular expression that targets commas preceded by a digit and followed by exactly three digits (and a word boundary or decimal point).

Suggested change
text = text.split('Question:')[0].replace(',', '')
text = re.sub(r'(?<=\d),(?=\d{3}\b)', '', text.split('Question:')[0])

numbers = re.findall(r'\-?\d+\.\d+|\-?\d+', text)
if not numbers:
return 'NULL'
Expand Down
Loading