Skip to content

Commit

Permalink
Update MLVU answer parsing (EvolvingLMMs-Lab#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiuyu-Li authored and ZhaoCinyu committed Dec 9, 2024
1 parent e125a0c commit 7af5630
Showing 1 changed file with 18 additions and 6 deletions.
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

0 comments on commit 7af5630

Please sign in to comment.