Skip to content
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

Fix MMLU answer extraction regex for repeated "Answer: LETTER" pattern #34

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

Conversation

lucasresck
Copy link

Description

This pull request addresses issue #33 by fixing the regular expression used to extract answers from model outputs with MMLU.

Solution

The existing regex fails to handle cases where the "Answer: LETTER" pattern appears multiple times. This is resolved by:

  • Using re.findall: Instead of re.search, re.findall is used to find all occurrences of the answer pattern.
  • Selecting the last match: The last match from the re.findall results is taken as the correct answer.
  • Allowing overlapping matches: The regex pattern is adjusted to allow overlapping matches, using a capturing group inside a lookahead.

Find all occurrences of the regular expression pattern, then take
the last one; allow overlapping.
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.

1 participant