Skip to content
Open
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
11 changes: 11 additions & 0 deletions vlmeval/utils/matching_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
logger = get_logger(__name__)


# Matches verbose chain-of-thought answers such as:
# "The correct answer is **B**. Here's why: ..."
# "The answer is C."
_VERBOSE_ANSWER_RE = re.compile(r"(?i)(?:correct\s+)?answer\s+is\s+\**([ABCD])\**")


def can_infer_option(answer, choices):
verbose = os.environ.get('VERBOSE', 0)
# Choices is a dictionary
Expand Down Expand Up @@ -47,6 +53,11 @@ def count_choice(splits, choices, prefix='', suffix=''):
return ch
elif count == 0 and count_choice(splits, {'Z', ''}) == 1:
return 'Z'

match = _VERBOSE_ANSWER_RE.search(answer or "")
if match and match.group(1).upper() in choices:
return match.group(1).upper()

return False


Expand Down