mathcheck-bench 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mathcheck_bench-0.1.0/.github/workflows/release.yml +19 -0
- mathcheck_bench-0.1.0/.github/workflows/tests.yml +17 -0
- mathcheck_bench-0.1.0/.gitignore +6 -0
- mathcheck_bench-0.1.0/CHANGELOG.md +8 -0
- mathcheck_bench-0.1.0/CONTRIBUTING.md +58 -0
- mathcheck_bench-0.1.0/LICENSE +202 -0
- mathcheck_bench-0.1.0/PKG-INFO +145 -0
- mathcheck_bench-0.1.0/README.md +113 -0
- mathcheck_bench-0.1.0/pyproject.toml +37 -0
- mathcheck_bench-0.1.0/src/mathcheck_bench/__init__.py +7 -0
- mathcheck_bench-0.1.0/src/mathcheck_bench/cases.py +47 -0
- mathcheck_bench-0.1.0/src/mathcheck_bench/checkers.py +67 -0
- mathcheck_bench-0.1.0/src/mathcheck_bench/cli.py +76 -0
- mathcheck_bench-0.1.0/src/mathcheck_bench/data/cases.jsonl +302 -0
- mathcheck_bench-0.1.0/src/mathcheck_bench/runner.py +72 -0
- mathcheck_bench-0.1.0/tests/test_cases.py +42 -0
- mathcheck_bench-0.1.0/tests/test_runner.py +52 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: release
|
|
2
|
+
# Publishes to PyPI when a GitHub Release is published.
|
|
3
|
+
# Uses PyPI "trusted publishing": no API token is stored in the repo.
|
|
4
|
+
on:
|
|
5
|
+
release:
|
|
6
|
+
types: [published]
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.12"
|
|
18
|
+
- run: pip install build && python -m build
|
|
19
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
name: tests
|
|
2
|
+
on: [push, pull_request]
|
|
3
|
+
jobs:
|
|
4
|
+
test:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
strategy:
|
|
7
|
+
fail-fast: false
|
|
8
|
+
matrix:
|
|
9
|
+
python-version: ["3.10", "3.12", "3.13"]
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version: ${{ matrix.python-version }}
|
|
15
|
+
- run: pip install -e ".[dev]"
|
|
16
|
+
- run: pytest -q
|
|
17
|
+
- run: mathcheck-bench run --checker all
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0 (unreleased)
|
|
4
|
+
|
|
5
|
+
- 302 hand-labeled answer pairs across 15 categories (28% "not equivalent").
|
|
6
|
+
- Adapters for Math-Verify, SymPy (Lark LaTeX parser) and a string-normalizer baseline.
|
|
7
|
+
- `mathcheck-bench run` CLI with per-category scores, false accepts vs false rejects,
|
|
8
|
+
crash counts, `--failures`, and `--format markdown`.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
Thanks for helping! The most valuable contribution is a new test case.
|
|
4
|
+
|
|
5
|
+
## Adding a case
|
|
6
|
+
|
|
7
|
+
1. Add one line to `src/mathcheck_bench/data/cases.jsonl`.
|
|
8
|
+
2. Use the next free id in its category (for example `unit-004`).
|
|
9
|
+
3. Fill every field:
|
|
10
|
+
- `reference`: the gold answer, bare LaTeX, no `$`.
|
|
11
|
+
- `answer`: what a model might output.
|
|
12
|
+
- `equivalent`: `true` only if a careful human grader would give full credit.
|
|
13
|
+
- `note`: one short phrase on why the case is tricky.
|
|
14
|
+
4. Run `pytest` and `mathcheck-bench run --checker all --failures`.
|
|
15
|
+
5. Open a pull request. Mention which checkers get your case wrong.
|
|
16
|
+
|
|
17
|
+
## Labeling rules
|
|
18
|
+
|
|
19
|
+
- Judge as a fair human grader would, given only the reference answer.
|
|
20
|
+
- Exact values only: a rounded decimal is not equal to an irrational or repeating value
|
|
21
|
+
unless the problem says to round.
|
|
22
|
+
- A unit on the answer is fine when the reference has none; a different unit with the same
|
|
23
|
+
number is not.
|
|
24
|
+
- Order does not matter for sets and lists of solutions; it does for tuples and coordinates.
|
|
25
|
+
- Mixed numbers are read the way a person reads them: `2\frac{1}{2}` means 2.5.
|
|
26
|
+
- Different angle units are fine when the value is the same (`\frac{\pi}{4}` = `45^\circ`);
|
|
27
|
+
a coterminal angle (`-\frac{\pi}{2}` vs `\frac{3\pi}{2}`) is a different answer.
|
|
28
|
+
- Approximations of irrational or repeating values are not equivalent (`3.14` is not `\pi`).
|
|
29
|
+
- A percent sign changes the value: `50` is not `\frac{1}{2}`, but `50\%` is.
|
|
30
|
+
- If the reference includes a constant of integration, the answer must too (any letter is fine).
|
|
31
|
+
- Skip cases a fair grader could reasonably mark either way; a test suite is only useful if its
|
|
32
|
+
labels are uncontroversial.
|
|
33
|
+
- If you are unsure, say so in the pull request so we can discuss.
|
|
34
|
+
|
|
35
|
+
Good cases come in pairs: a "should be equivalent" case and a nearby "should NOT be
|
|
36
|
+
equivalent" case, so a checker cannot score well by saying yes to everything.
|
|
37
|
+
|
|
38
|
+
## Categories and id prefixes
|
|
39
|
+
|
|
40
|
+
| Category | Prefix | | Category | Prefix |
|
|
41
|
+
|---|---|---|---|---|
|
|
42
|
+
| fraction_decimal | frac | | expressions | expr |
|
|
43
|
+
| latex_format | fmt | | equations_relations | eq |
|
|
44
|
+
| whitespace_punct | ws | | complex_numbers | cplx |
|
|
45
|
+
| units | unit | | matrices_vectors | mat |
|
|
46
|
+
| angles | ang | | text_answers | text |
|
|
47
|
+
| intervals_sets | int | | constants_irrational | const |
|
|
48
|
+
| combinatorics | comb | | multiple_answers | multi |
|
|
49
|
+
| large_numbers | big | | | |
|
|
50
|
+
|
|
51
|
+
Want a new category? Open an issue first.
|
|
52
|
+
|
|
53
|
+
## Development
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pip install -e ".[dev]"
|
|
57
|
+
pytest
|
|
58
|
+
```
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mathcheck-bench
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A labeled test suite and scorecard for math answer checkers used in LLM evaluation.
|
|
5
|
+
Project-URL: Homepage, https://github.com/Harish-Mathematican/mathcheck-bench
|
|
6
|
+
Project-URL: Issues, https://github.com/Harish-Mathematican/mathcheck-bench/issues
|
|
7
|
+
Author: Harish
|
|
8
|
+
License-Expression: Apache-2.0
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: benchmark,evaluation,latex,llm,math,verifier
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Provides-Extra: all
|
|
18
|
+
Requires-Dist: lark>=1.1; extra == 'all'
|
|
19
|
+
Requires-Dist: math-verify>=0.9; extra == 'all'
|
|
20
|
+
Requires-Dist: sympy>=1.13; extra == 'all'
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: lark>=1.1; extra == 'dev'
|
|
23
|
+
Requires-Dist: math-verify>=0.9; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
25
|
+
Requires-Dist: sympy>=1.13; extra == 'dev'
|
|
26
|
+
Provides-Extra: math-verify
|
|
27
|
+
Requires-Dist: math-verify>=0.9; extra == 'math-verify'
|
|
28
|
+
Provides-Extra: sympy
|
|
29
|
+
Requires-Dist: lark>=1.1; extra == 'sympy'
|
|
30
|
+
Requires-Dist: sympy>=1.13; extra == 'sympy'
|
|
31
|
+
Description-Content-Type: text/markdown
|
|
32
|
+
|
|
33
|
+
# mathcheck-bench
|
|
34
|
+
|
|
35
|
+
**How often does your math answer checker get it wrong?**
|
|
36
|
+
|
|
37
|
+
When we evaluate or train LLMs on math, a *checker* decides whether the model's answer
|
|
38
|
+
matches the reference (`1/2` vs `0.5`, `\binom{5}{2}` vs `10`, `(0,1]` vs `0 < x \le 1`).
|
|
39
|
+
Benchmark scores are only as good as that checker, and studies show checkers wrongly reject
|
|
40
|
+
about 14% of correct answers ([Huang et al.](https://arxiv.org/abs/2505.22203)) and disagree
|
|
41
|
+
with each other by up to 41 points on identical inputs ([verifier audit](https://arxiv.org/abs/2609.01354)).
|
|
42
|
+
|
|
43
|
+
`mathcheck-bench` is a small, hand-labeled suite of tricky answer pairs plus a one-command
|
|
44
|
+
scorecard, so you can see **where** a checker fails before you trust its numbers.
|
|
45
|
+
|
|
46
|
+
> Status: v0.1. Contributions of new cases are very welcome.
|
|
47
|
+
|
|
48
|
+
## Quick start
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pip install "mathcheck-bench[all]"
|
|
52
|
+
mathcheck-bench run --checker all
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
== math-verify ==
|
|
57
|
+
category correct errors
|
|
58
|
+
angles 7/18 0
|
|
59
|
+
units 11/26 0
|
|
60
|
+
...
|
|
61
|
+
overall 74.2% 0
|
|
62
|
+
false accepts: 8 false rejects: 70
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Add `--failures` to list every case a checker got wrong.
|
|
66
|
+
|
|
67
|
+
## Current scorecard (302 cases, 15 categories)
|
|
68
|
+
|
|
69
|
+
| Category | Cases | string-normalize | sympy-basic | math-verify |
|
|
70
|
+
|---|---:|---:|---:|---:|
|
|
71
|
+
| angles | 18 | 22% | 0% | 39% |
|
|
72
|
+
| combinatorics | 20 | 25% | 70% | 85% |
|
|
73
|
+
| complex_numbers | 15 | 27% | 33% | 33% |
|
|
74
|
+
| constants_irrational | 14 | 43% | 29% | 93% |
|
|
75
|
+
| equations_relations | 18 | 22% | 0% | 94% |
|
|
76
|
+
| expressions | 25 | 32% | 72% | 92% |
|
|
77
|
+
| fraction_decimal | 28 | 29% | 75% | 86% |
|
|
78
|
+
| intervals_sets | 23 | 26% | 0% | 52% |
|
|
79
|
+
| large_numbers | 22 | 45% | 73% | 73% |
|
|
80
|
+
| latex_format | 28 | 29% | 64% | 96% |
|
|
81
|
+
| matrices_vectors | 13 | 31% | 23% | 54% |
|
|
82
|
+
| multiple_answers | 17 | 35% | 0% | 100% |
|
|
83
|
+
| text_answers | 15 | 33% | 20% | 67% |
|
|
84
|
+
| units | 26 | 35% | 0% | 42% |
|
|
85
|
+
| whitespace_punct | 20 | 45% | 35% | 90% |
|
|
86
|
+
| **overall** | **302** | **31.8%** | **36.1%** | **74.2%** |
|
|
87
|
+
| false accepts | | 0 | 0 | 8 |
|
|
88
|
+
| false rejects | | 206 | 29 | 70 |
|
|
89
|
+
| crashed | | 0 | 164 | 0 |
|
|
90
|
+
|
|
91
|
+
*Checkers run with default settings: Math-Verify 0.9, SymPy 1.14 (Lark LaTeX parser), and a
|
|
92
|
+
whitespace/`\boxed` string normalizer. Regenerate with `mathcheck-bench run --checker all --format markdown`.*
|
|
93
|
+
|
|
94
|
+
**What the scorecard shows**
|
|
95
|
+
|
|
96
|
+
- **False accepts** (a wrong answer marked correct) are the dangerous error when a checker is used
|
|
97
|
+
as an RL reward, because the model learns to exploit them. With default settings, Math-Verify
|
|
98
|
+
ignores units (`5 m` = `5 cm`, `1 kg` = `1 g`, `0°C` = `0°F`) and accepts truncated decimals
|
|
99
|
+
(`1/7` = `0.142857`).
|
|
100
|
+
- **False rejects** (a correct answer marked wrong) deflate benchmark scores. Common ones: unit
|
|
101
|
+
conversions (`3 hours` vs `180 minutes`), radians vs degrees, interval vs inequality, e-notation
|
|
102
|
+
(`1e6`), and repeating decimals (`0.\overline{3}`).
|
|
103
|
+
- **Crashes** are reported separately and never counted as a correct "not equivalent" verdict.
|
|
104
|
+
|
|
105
|
+
## Test your own checker
|
|
106
|
+
|
|
107
|
+
A checker is any function `(reference: str, answer: str) -> bool`:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
# my_checker.py
|
|
111
|
+
def check(reference, answer):
|
|
112
|
+
return reference.strip() == answer.strip()
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
mathcheck-bench run --checker my_checker:check --failures
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Or from Python:
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
from mathcheck_bench import run
|
|
123
|
+
card = run(check, name="mine")
|
|
124
|
+
print(card.accuracy, card.by_category())
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## The data
|
|
128
|
+
|
|
129
|
+
Cases live in [`src/mathcheck_bench/data/cases.jsonl`](src/mathcheck_bench/data/cases.jsonl),
|
|
130
|
+
one JSON object per line:
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{"id": "unit-003", "category": "units", "reference": "5 \\text{ m}", "answer": "5 \\text{ cm}", "equivalent": false, "note": "same number, different unit"}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Answers are bare final answers (no surrounding solution text), written in LaTeX without `$`.
|
|
137
|
+
Adapters add whatever wrapping their checker needs.
|
|
138
|
+
|
|
139
|
+
## Contributing
|
|
140
|
+
|
|
141
|
+
Found a pair your checker gets wrong? Add one line. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
Apache-2.0
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# mathcheck-bench
|
|
2
|
+
|
|
3
|
+
**How often does your math answer checker get it wrong?**
|
|
4
|
+
|
|
5
|
+
When we evaluate or train LLMs on math, a *checker* decides whether the model's answer
|
|
6
|
+
matches the reference (`1/2` vs `0.5`, `\binom{5}{2}` vs `10`, `(0,1]` vs `0 < x \le 1`).
|
|
7
|
+
Benchmark scores are only as good as that checker, and studies show checkers wrongly reject
|
|
8
|
+
about 14% of correct answers ([Huang et al.](https://arxiv.org/abs/2505.22203)) and disagree
|
|
9
|
+
with each other by up to 41 points on identical inputs ([verifier audit](https://arxiv.org/abs/2609.01354)).
|
|
10
|
+
|
|
11
|
+
`mathcheck-bench` is a small, hand-labeled suite of tricky answer pairs plus a one-command
|
|
12
|
+
scorecard, so you can see **where** a checker fails before you trust its numbers.
|
|
13
|
+
|
|
14
|
+
> Status: v0.1. Contributions of new cases are very welcome.
|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
pip install "mathcheck-bench[all]"
|
|
20
|
+
mathcheck-bench run --checker all
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
== math-verify ==
|
|
25
|
+
category correct errors
|
|
26
|
+
angles 7/18 0
|
|
27
|
+
units 11/26 0
|
|
28
|
+
...
|
|
29
|
+
overall 74.2% 0
|
|
30
|
+
false accepts: 8 false rejects: 70
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Add `--failures` to list every case a checker got wrong.
|
|
34
|
+
|
|
35
|
+
## Current scorecard (302 cases, 15 categories)
|
|
36
|
+
|
|
37
|
+
| Category | Cases | string-normalize | sympy-basic | math-verify |
|
|
38
|
+
|---|---:|---:|---:|---:|
|
|
39
|
+
| angles | 18 | 22% | 0% | 39% |
|
|
40
|
+
| combinatorics | 20 | 25% | 70% | 85% |
|
|
41
|
+
| complex_numbers | 15 | 27% | 33% | 33% |
|
|
42
|
+
| constants_irrational | 14 | 43% | 29% | 93% |
|
|
43
|
+
| equations_relations | 18 | 22% | 0% | 94% |
|
|
44
|
+
| expressions | 25 | 32% | 72% | 92% |
|
|
45
|
+
| fraction_decimal | 28 | 29% | 75% | 86% |
|
|
46
|
+
| intervals_sets | 23 | 26% | 0% | 52% |
|
|
47
|
+
| large_numbers | 22 | 45% | 73% | 73% |
|
|
48
|
+
| latex_format | 28 | 29% | 64% | 96% |
|
|
49
|
+
| matrices_vectors | 13 | 31% | 23% | 54% |
|
|
50
|
+
| multiple_answers | 17 | 35% | 0% | 100% |
|
|
51
|
+
| text_answers | 15 | 33% | 20% | 67% |
|
|
52
|
+
| units | 26 | 35% | 0% | 42% |
|
|
53
|
+
| whitespace_punct | 20 | 45% | 35% | 90% |
|
|
54
|
+
| **overall** | **302** | **31.8%** | **36.1%** | **74.2%** |
|
|
55
|
+
| false accepts | | 0 | 0 | 8 |
|
|
56
|
+
| false rejects | | 206 | 29 | 70 |
|
|
57
|
+
| crashed | | 0 | 164 | 0 |
|
|
58
|
+
|
|
59
|
+
*Checkers run with default settings: Math-Verify 0.9, SymPy 1.14 (Lark LaTeX parser), and a
|
|
60
|
+
whitespace/`\boxed` string normalizer. Regenerate with `mathcheck-bench run --checker all --format markdown`.*
|
|
61
|
+
|
|
62
|
+
**What the scorecard shows**
|
|
63
|
+
|
|
64
|
+
- **False accepts** (a wrong answer marked correct) are the dangerous error when a checker is used
|
|
65
|
+
as an RL reward, because the model learns to exploit them. With default settings, Math-Verify
|
|
66
|
+
ignores units (`5 m` = `5 cm`, `1 kg` = `1 g`, `0°C` = `0°F`) and accepts truncated decimals
|
|
67
|
+
(`1/7` = `0.142857`).
|
|
68
|
+
- **False rejects** (a correct answer marked wrong) deflate benchmark scores. Common ones: unit
|
|
69
|
+
conversions (`3 hours` vs `180 minutes`), radians vs degrees, interval vs inequality, e-notation
|
|
70
|
+
(`1e6`), and repeating decimals (`0.\overline{3}`).
|
|
71
|
+
- **Crashes** are reported separately and never counted as a correct "not equivalent" verdict.
|
|
72
|
+
|
|
73
|
+
## Test your own checker
|
|
74
|
+
|
|
75
|
+
A checker is any function `(reference: str, answer: str) -> bool`:
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
# my_checker.py
|
|
79
|
+
def check(reference, answer):
|
|
80
|
+
return reference.strip() == answer.strip()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
mathcheck-bench run --checker my_checker:check --failures
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Or from Python:
|
|
88
|
+
|
|
89
|
+
```python
|
|
90
|
+
from mathcheck_bench import run
|
|
91
|
+
card = run(check, name="mine")
|
|
92
|
+
print(card.accuracy, card.by_category())
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## The data
|
|
96
|
+
|
|
97
|
+
Cases live in [`src/mathcheck_bench/data/cases.jsonl`](src/mathcheck_bench/data/cases.jsonl),
|
|
98
|
+
one JSON object per line:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{"id": "unit-003", "category": "units", "reference": "5 \\text{ m}", "answer": "5 \\text{ cm}", "equivalent": false, "note": "same number, different unit"}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Answers are bare final answers (no surrounding solution text), written in LaTeX without `$`.
|
|
105
|
+
Adapters add whatever wrapping their checker needs.
|
|
106
|
+
|
|
107
|
+
## Contributing
|
|
108
|
+
|
|
109
|
+
Found a pair your checker gets wrong? Add one line. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
Apache-2.0
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "mathcheck-bench"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A labeled test suite and scorecard for math answer checkers used in LLM evaluation."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "Apache-2.0"
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Harish" }]
|
|
13
|
+
dependencies = []
|
|
14
|
+
keywords = ["llm", "evaluation", "math", "benchmark", "verifier", "latex"]
|
|
15
|
+
classifiers = [
|
|
16
|
+
"Development Status :: 3 - Alpha",
|
|
17
|
+
"Intended Audience :: Science/Research",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
20
|
+
"Topic :: Scientific/Engineering :: Mathematics",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "https://github.com/Harish-Mathematican/mathcheck-bench"
|
|
25
|
+
Issues = "https://github.com/Harish-Mathematican/mathcheck-bench/issues"
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
math-verify = ["math-verify>=0.9"]
|
|
29
|
+
sympy = ["sympy>=1.13", "lark>=1.1"]
|
|
30
|
+
all = ["math-verify>=0.9", "sympy>=1.13", "lark>=1.1"]
|
|
31
|
+
dev = ["pytest>=8", "math-verify>=0.9", "sympy>=1.13", "lark>=1.1"]
|
|
32
|
+
|
|
33
|
+
[project.scripts]
|
|
34
|
+
mathcheck-bench = "mathcheck_bench.cli:main"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["src/mathcheck_bench"]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""Load the labeled test cases that ship with the package."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from dataclasses import dataclass
|
|
7
|
+
from importlib import resources
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
from typing import List, Optional, Union
|
|
10
|
+
|
|
11
|
+
REQUIRED_FIELDS = ("id", "category", "reference", "answer", "equivalent", "note")
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@dataclass(frozen=True)
|
|
15
|
+
class Case:
|
|
16
|
+
"""One labeled pair: is `answer` mathematically equivalent to `reference`?"""
|
|
17
|
+
|
|
18
|
+
id: str
|
|
19
|
+
category: str
|
|
20
|
+
reference: str
|
|
21
|
+
answer: str
|
|
22
|
+
equivalent: bool
|
|
23
|
+
note: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def load_cases(path: Optional[Union[str, Path]] = None) -> List[Case]:
|
|
27
|
+
"""Read cases from a JSONL file (one JSON object per line).
|
|
28
|
+
|
|
29
|
+
With no path, reads the suite bundled with the package.
|
|
30
|
+
"""
|
|
31
|
+
if path is None:
|
|
32
|
+
text = resources.files("mathcheck_bench").joinpath("data/cases.jsonl").read_text("utf-8")
|
|
33
|
+
else:
|
|
34
|
+
text = Path(path).read_text("utf-8")
|
|
35
|
+
|
|
36
|
+
cases = []
|
|
37
|
+
for lineno, line in enumerate(text.splitlines(), start=1):
|
|
38
|
+
if not line.strip():
|
|
39
|
+
continue
|
|
40
|
+
row = json.loads(line)
|
|
41
|
+
missing = [f for f in REQUIRED_FIELDS if f not in row]
|
|
42
|
+
if missing:
|
|
43
|
+
raise ValueError(f"line {lineno}: missing fields {missing}")
|
|
44
|
+
if not isinstance(row["equivalent"], bool):
|
|
45
|
+
raise ValueError(f"line {lineno}: 'equivalent' must be true or false")
|
|
46
|
+
cases.append(Case(**{f: row[f] for f in REQUIRED_FIELDS}))
|
|
47
|
+
return cases
|