Skip to content

More stable MBPP evaluation #2111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

f14-bertolotti
Copy link

@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.

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.

2 participants