Skip to content

fix(scoring): BBH exact-match accepts Markdown-emphasised answers (**True** == True) - #463

Open
RealDiligent wants to merge 2 commits into
James-CUDA:mainfrom
RealDiligent:fix/critical-bbh-md-emphasis
Open

fix(scoring): BBH exact-match accepts Markdown-emphasised answers (**True** == True)#463
RealDiligent wants to merge 2 commits into
James-CUDA:mainfrom
RealDiligent:fix/critical-bbh-md-emphasis

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Type

  • General improvement — bug fix, docs, refactor, or infrastructure (welcome but earns no TAO)

General improvement

What does this PR do?

Fixes #461.

BBH's exact-match half zeroes a Markdown-bolded correct answer while the multiple-choice half of the SAME adapter accepts one:

candidate gold (exact_match) expected before after
Answer: True True 1.0 1.0 1.0
Answer: **True** True 1.0 0.0 1.0
Answer: **valid** valid 1.0 0.0 1.0
Answer: **False** True 0.0 0.0 0.0

Root cause: _normalize_exact's strip set has no */_, so **True** normalizes to **true**true. The repo already established that bolding the final answer "is a very common model format" (reward._strip_choice_md_emphasis), so Answer: **B** passes MCQ subtasks while Answer: **True** fails all ~10 exact-match subtasks — an inconsistent false negative inside one adapter.

Fix approach (minimal): peel Markdown emphasis only when the SAME marker wraps the whole answer (backreference; nested **_True_** collapses via a fixpoint loop), applied before the dyck bracket-sequence check (a bolded bracket answer still compares as a sequence) and once more after the edge strip (so **True**. unwraps). Asymmetric markers (2*3) and inner-word emphasis are content and never peeled — pinned by tests.

Why is it needed?

Systematic false negatives on ~10 of BBH's 27 subtasks (boolean_expressions, formal_fallacies, navigate, sports_understanding, object_counting, ...) for one of the most common model output styles, and intra-adapter consistency with the MCQ path.

Tests: tests/test_bbh_md_emphasis.py (9 cases): bold/italic/underscore/nested unwrap, emphasis inside terminal punctuation, multiword answers, asymmetric-marker guard, dyck sequences (plain and bolded), and end-to-end grading both directions.

Note on CI: current main is red by itself — tests/test_drop_leading_decimal_point.py (3 failures) pins wrapped leading-decimal forms; open PR #450 is the dedicated repair. Like #420/#424 did for #404, this branch carries one chore(ci) commit applying the equivalent minimal repair (credit belongs to #450) purely so CI can validate this fix; it resolves to a no-op once #450 lands, and I will rebase it away on request. With it, the full suite passes locally: 2148 passed, 2 skipped (+9 new).

Checklist

  • Tests pass: pytest tests/ (2148 passed, 2 skipped locally; 3 Windows-only console-encoding failures unrelated to this change pass on Linux)
  • Lint passes: ruff check src/
  • Type check passes: mypy src/ (for changed files)
  • New code follows existing style
  • Public functions have docstrings and type annotations

🤖 Generated with Claude Code

RealDiligent and others added 2 commits July 23, 2026 23:46
…ent of James-CUDA#450)

main CI is red: tests/test_drop_leading_decimal_point.py pins $.5 / .5.
forms that still lose the leading point on the second-chance strip path,
so every PR inherits the failure. This commit applies the same minimal
repair PR James-CUDA#450 proposes (exclude "." from _STRIP_EDGE, retry a failed
parse with rstrip(".")) purely so CI can validate this branch's own fix.
Credit for the repair belongs to James-CUDA#450; once it lands on main this
resolves to a no-op in the merge.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…True** == True)

Bolding the final answer is a very common model format — common enough
that the shared choice extractor grew _strip_choice_md_emphasis for it,
and the multiple-choice half of this adapter accepts "Answer: **B**".
But _normalize_exact's strip set had no */_, so "Answer: **True**"
normalised to "**true**" and every exact-match subtask
(boolean_expressions, formal_fallacies, navigate, sports_understanding,
object_counting, ...) graded the bolded correct answer 0.0 — an
inconsistent false negative inside one adapter.

Fix: peel Markdown emphasis only when the SAME marker wraps the whole
answer (backreference; nested wrappers collapse via fixpoint loop), once
before the dyck bracket-sequence check (so a bolded bracket answer still
compares as a sequence) and once after the edge strip (so "**true**."
unwraps). Asymmetric or inner-word markers are content and never peeled.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.

[bug] BBH exact-match grades a Markdown-bolded correct answer 0.0 — the same adapter's MCQ half accepts Answer: **B**

1 participant