GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(multi_choices): read bracketed multi-select labels that run together by simin-yuan · Pull Request #2075 · modelscope/evalscope

Conversation

@simin-yuan

@simin-yuan simin-yuan commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Problem

parse_answers(..., multiple_correct=True) and parse_answers_zh(..., multiple_correct=True) only accept a bracketed label list when the labels are separated by ,, ,, / or 、. A model that mirrors the option list without a separator (答案:[AD], [BCD], [A D]) fails the bracketed pattern; the plain-label pattern cannot start at [, and _fallback_parse_answer returns the last upper-case letter. 答案:[AD] becomes {'D'}.

Fixes #2074.

Change

  • Add _MULTI_BRACKETED_LABEL_RE, which lets the labels inside the brackets run together or be separated by a space.
  • Use that pattern only when multiple_correct=True; single-answer extraction keeps the strict bracket pattern.
  • Bump SHARED_SCORING_VERSION to v1.3 so cached reviews of affected runs are invalidated.

Scope and compatibility

  • 答案:[A] for a single-answer sample is unchanged.
  • 答案:[注], 答案:[1] (choices A-D) still produce no answer.
  • 答案:[A,D] and 答案:(A,C) parse as before.
  • Unbracketed answers are untouched.

Measurement

Re-scored 450 stored outputs from a Chinese multi-select AGIEval run (qwen2.5:7b 150, llama3.2:3b 300) with the change; no new model calls:

model main this PR
qwen2.5:7b 63/150 72/150
llama3.2:3b 52/300 52/300
total 115/450 124/450

48/150 qwen outputs used a bracketed label written without a separator. 13 correct answers are recovered; 4 answers that the old fallback had awarded credit to are now recorded as wrong; 0 new false acceptances.

Tests

  • 4 new tests in tests/test_multi_choices.py: concatenated labels ([AD], [BD], [ABD], [BCD], [AC], [ABCD]), comma/space forms, single-answer [A] unchanged, and non-label bracket contents.
  • The two target tests fail on main ([AD] and [A D]); the single-answer and non-label tests pass on both.
  • pytest tests/test_multi_choices.py -q -> 74 passed.
  • pre-commit (ruff check, ruff format, whitespace/EOF/line-ending hooks) passes.

Simin Yuan

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@simin-yuan
fix(multi_choices): read bracketed multi-select labels that run together
564c470
Yunnglin
Yunnglin requested changes Nov 13, 2026
View reviewed changes

@Yunnglin Yunnglin left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the normal multi-select cases work, but the new regular expression introduces exponential backtracking on short malformed model outputs.

Reviewed head: 564c4702a429c39fd417aec3b1a568f7487e4494.

[P1] Avoid ambiguous whitespace consumption in _MULTI_BRACKETED_LABEL_RE — evalscope/utils/multi_choices.py:170.

Inside the repeated group, \s*[,,/、]?\s* lets each space be consumed by either whitespace matcher when the optional separator is absent. An invalid suffix makes the engine explore exponentially many combinations.

Reproducer on the PR checkout (POSIX; the alarm prevents a long-running process):

import signal
import time

from evalscope.api.dataset import Sample
from evalscope.api.evaluator import TaskState
from evalscope.api.model import ModelOutput
from evalscope.utils.multi_choices import parse_answers, parse_answers_zh


def expired(*args):
    raise TimeoutError


signal.signal(signal.SIGALRM, expired)
for parse, marker in [(parse_answers, 'ANSWER: '), (parse_answers_zh, '答案:')]:
    text = marker + '[' + 'A ' * 40 + '!]'
    state = TaskState(
        model='mock',
        sample=Sample(input='question', choices=['a', 'b', 'c', 'd'], target='A'),
        output=ModelOutput.from_content(model='mock', content=text),
    )
    started = time.perf_counter()
    signal.setitimer(signal.ITIMER_REAL, 2)
    try:
        print(parse.__name__, parse(state, multiple_correct=True))
    except TimeoutError:
        print(parse.__name__, len(text), 'characters: TIMEOUT >2s')
    finally:
        signal.setitimer(signal.ITIMER_REAL, 0)
    print('elapsed:', time.perf_counter() - started)

Locally on Python 3.10.18, both public parsers hit the 2-second cutoff for just 91 English / 86 Chinese characters. The actual base functions at 6f1fde76b2f17b146a12fcde0ea560dbe5d5b206 return for these same inputs in roughly 0.00003 seconds. Isolating the new pattern gives approximately 0.012 seconds for 16 repeated labels, 0.178 seconds for 20, and over 2 seconds for 24. These are elapsed-time observations, not a proposed performance threshold.

Model output is an input boundary: a malformed answer must not stall scoring. The existing 74 multi-choice tests pass, so the normal-case coverage does not catch this regression.

Please remove the ambiguous repeated whitespace matching (or separate bracket extraction from label validation), and add regression coverage for repeated labels with an invalid suffix and a missing closing bracket. A thread timeout alone does not fix the underlying regex execution. Please push the fix and request re-review; this PR should remain unmerged until the regression is resolved.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@simin-yuan
fix(multi_choices): keep the multi-select bracket pattern linear
2c1d9ef
The optional separator sat between two whitespace runs, so a space could be
claimed by either of them and a malformed label run such as '[A A ... !]'
made the engine try every split: exponential in the number of labels, enough
that a 91-character malformed reply stalled scoring (2.9s at 24 labels).

Put the separator and its surrounding whitespace in one character class,
which keeps the scan linear (0.03ms for 40 labels, 1.8ms for 10k). Labels are
still validated in _label_prefix afterwards, so bracketed prose stays
unparseable and the fallback result is unchanged.

Cover both malformed shapes (invalid suffix, missing closing bracket) for both
parsers; the tests read the answer in a child process so a regression fails
instead of hanging the test session.
@simin-yuan

simin-yuan commented Nov 13, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Thanks for the catch — the ambiguous whitespace is gone.

  • _MULTI_BRACKETED_LABEL_RE now groups the separator and its surrounding whitespace into a single [\s,,/、]* class instead of \s*[,,/、]?\s*, so a space can only be consumed one way. The bracket body is still validated by _label_prefix, so which answers are accepted or rejected is unchanged; only the time to reject a malformed one.
  • Timings on this head, each parse in a child process (same shape as your reproducer): '[' + 'A ' * 40 + '!]' parses in 0.03 ms (reviewed head: >2 s; ~2.9 s at 24 labels), the same run with no closing bracket in 0.05 ms, and '[' + 'A ' * 10000 + '!]' in 1.8 ms. A 300-case fuzz over 20k-character bracket bodies built from A ,/、[]! stays under 0.03 ms.
  • Regression tests added for repeated labels with an invalid suffix and with no closing bracket, for both parsers. Each parse runs in a child interpreter with a 15 s limit, so a reintroduced regression fails the test rather than hanging the session; both tests fail on the reviewed head (subprocess.TimeoutExpired) and pass here. pytest tests/test_multi_choices.py -q -> 76 passed; ruff check and format are clean.

Pushed 2c1d9ef; CI is rerunning. As an outside contributor this account cannot call RequestReviewsByLogin, so I can't re-request review through the API — flagging it here instead. Ready for another look when you have a moment.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Yunnglin
docs(multi_choices): condense parser and regression test comments
bc4a65a
Yunnglin
Yunnglin approved these changes Nov 13, 2026
View reviewed changes

@Yunnglin Yunnglin left a comment

Copy link
Copy Markdown
Collaborator

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the backtracking fix and the latest comment cleanup. The previous P1 blocker is resolved: the original malformed inputs return promptly, and regressions cover invalid suffixes and missing closing brackets in both parsers.

The latest commit only condenses comments/docstrings; executable code and assertions are unchanged. Local verification: 76 multi-choice tests plus the mock CLI-lite check passed, and all make lint checks passed. Current-head CI is also green. Approved.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Yunnglin
Yunnglin merged commit 8a45168 into modelscope:main Nov 13, 2026
3 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@devjoinedthechat devjoinedthechat mentioned this pull request Nov 20, 2026
fix(multi_choices): stop the fallback reading the "A" of "Answer:" as option A #2165
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Yunnglin Yunnglin Yunnglin approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug] Bracketed multi-select answers such as 答案:[AD] keep only the last label

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@simin-yuan @Yunnglin
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.