Skip to content

More stable MBPP evaluation#2111

Merged
Zhudongsheng75 merged 4 commits intoopen-compass:mainfrom
f14-bertolotti:f14-mbpp-eval-patch
Jun 23, 2025
Merged

More stable MBPP evaluation#2111
Zhudongsheng75 merged 4 commits intoopen-compass:mainfrom
f14-bertolotti:f14-mbpp-eval-patch

Conversation

@f14-bertolotti
Copy link
Copy Markdown
Contributor

@f14-bertolotti f14-bertolotti commented May 21, 2025

This PR improves the stability of the evaluation process for the MBPP dataset.

Motivation

There were two key issues affecting the robustness and reliability of the evaluation:

  1. Regex performance:
    The regex pattern [r'(.*)\s*```.*'](https://github.com/open-compass/opencompass/blob/aa2b89b6f8b7c5448e47ed1aa3f12b04da1ff123/opencompass/datasets/mbpp.py#L327) occasionally hangs when processing predictions containing excessive trailing whitespace. This is likely due to catastrophic backtracking. To mitigate this, I replaced the standard re module with the regex module, which supports timeouts, and set a hard timeout of 10 seconds.

  2. Multiprocessing issue:
    The following error was encountered:
    AttributeError: Can't pickle local object 'execution.<locals>._execution'
    This occurs because the ProcessPoolExecutor cannot pickle local (non-global) functions. The fix is to move the _execution function to the global scope so it can be properly serialized.

Modifications

  1. Replaced re with regex and added a 10-second timeout to [regex.search](https://github.com/open-compass/opencompass/blob/aa2b89b6f8b7c5448e47ed1aa3f12b04da1ff123/opencompass/datasets/mbpp.py#L333).
  2. Moved the _execution function [from here](https://github.com/open-compass/opencompass/blob/aa2b89b6f8b7c5448e47ed1aa3f12b04da1ff123/opencompass/datasets/mbpp.py#L403C1-L418C33) to the global scope to resolve the pickling issue.

Backward Compatibility

This change is not breaking. However, note that introducing a regex timeout may cause differences in evaluation results for cases where the timeout is triggered.

@tonysy
Copy link
Copy Markdown
Collaborator

tonysy commented Jun 5, 2025

Thanks for your contribution. Please help review this PR. @Zhudongsheng75

@tonysy tonysy requested a review from Zhudongsheng75 June 5, 2025 04:36
@tonysy
Copy link
Copy Markdown
Collaborator

tonysy commented Jun 5, 2025

Please fix the lint issue.

@f14-bertolotti
Copy link
Copy Markdown
Contributor Author

Hi @tonysy ,

I cannot make pre-commit work. The lint issue should be resolved.

Copy link
Copy Markdown
Collaborator

@Zhudongsheng75 Zhudongsheng75 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Collaborator

@tonysy tonysy left a comment

Choose a reason for hiding this comment

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

LGTM

@tonysy
Copy link
Copy Markdown
Collaborator

tonysy commented Jun 18, 2025

Thanks for the contribution. This PR may incur performance BC. We will test it and then merge it in next version.

@tonysy
Copy link
Copy Markdown
Collaborator

tonysy commented Jun 18, 2025

Please check the evaluation performance before/after this PR. cc @Zhudongsheng75

@tonysy
Copy link
Copy Markdown
Collaborator

tonysy commented Jun 18, 2025

Also please pay attention to this PR @zhulinJulia24 @MaiziXiao . Thanks.

@Zhudongsheng75 Zhudongsheng75 merged commit d07bb3d into open-compass:main Jun 23, 2025
8 checks passed
zyc140345 pushed a commit to zyc140345/opencompass that referenced this pull request Oct 23, 2025
* timed re.search and _executor made global

* TimeOutError exception handling

* added missing blank lines

* isort import

---------

Co-authored-by: Francesco Bertolotti <[email protected]>
iamkaia pushed a commit to iamkaia/opencompass that referenced this pull request Feb 4, 2026
* timed re.search and _executor made global

* TimeOutError exception handling

* added missing blank lines

* isort import

---------

Co-authored-by: Francesco Bertolotti <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants