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

Update MLVU answer parsing #364

Merged
merged 1 commit into from
Oct 28, 2024
Merged
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
24 changes: 18 additions & 6 deletions lmms_eval/tasks/mlvu/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,24 @@ def mlvu_doc_to_text(doc, lmms_eval_specific_kwargs=None):

def extract_characters_regex(s):
s = s.strip()
if ")" in s:
index = s.index(")")
pred = s[index - 1 : index]
return pred
else:
return s
answer_prefixes = [
"The best answer is",
"The correct answer is",
"The answer is",
"The answer",
"The best option is" "The correct option is",
"Best answer:" "Best option:",
]
for answer_prefix in answer_prefixes:
s = s.replace(answer_prefix, "")

if len(s.split()) > 10 and not re.search("[ABCD]", s):
return ""

matches = re.search(r"[ABCD]", s)
if matches is None:
return ""
return matches[0]


def mlvu_process_results(doc, results):
Expand Down
Loading