`\frac` and `\sqrt` shorthand with a command argument (`\frac\pi4`, `\sqrt\pi`) is mangled, which can verify a wrong answer
まだ誰も着手していません。
評価
調査の方向性
math_normalization.pyを読み、特にリンク先の行にある_fix_fracsと_fix_sqrtを確認してください。提供された\frac\pi4と\sqrt\piの例で再現し、既存のテストが省略形の引数をどのようにカバーしているかを確認してください。両方の関数でコマンド引数が全体のまま保たれ、提供された検証ケースが期待どおりの結果を出せば完了です。
索引モデルが issue の本文から書いたものです。
説明
_fix_fracs and _fix_sqrt in latex2sympy2_extended's math_normalization.py treat the first character after \frac or \sqrt as a whole argument. When the argument is a command such as \pi, they split it: the backslash becomes one argument and the command's first letter the next. The result either fails to parse or parses to a different value.
Reproduction with math-verify 0.9.0 and latex2sympy2_extended 1.11.0:
from math_verify import parse, verify
P = lambda s: parse("$" + s + "$")
P(r"\frac\pi4") # ['\\frac{\\}{p}i4'] no expression
P(r"\frac \pi4") # ['\\frac{\\}{p}i4'] no expression
P(r"\frac 1\pi") # [1, '\\frac{1}{\\}pi'] parses as 1
P(r"\sqrt\pi") # ['\\sqrt{\\}pi'] no expression
P(r"\frac{\pi}{4}") # [pi/4, ...] braced form is fine
verify(P(r"\frac \pi4"), P(r"\frac{\pi}{4}")) # False, should be True
verify(P(r"\frac \pi4 + 2 - \sqrt2"), P("2")) # True, should be False
The last case is a wrong answer verified as correct. The gold parses to 2 because the mangled fraction drops out. That gold is a real one: it is the boxed answer of a problem in the MATH test set, written \frac \pi4 + 2 - \sqrt2.
Cause: in _fix_fracs, after substr.lstrip() the code takes a = substr[0] and b = substr[1] as single characters. _fix_sqrt does the same with a = split[0]. Both come from Hendrycks' MATH code (math_equivalence.py), which has the same limitation.
Suggested fix: when the next character is a backslash, take the whole command (\\[a-zA-Z]+) as the argument, in both functions. For example, read each argument with a pattern like \\[a-zA-Z]+|[^\s{}\\]. \frac\pi4 then becomes \frac{\pi}{4}, and \sqrt\pi becomes \sqrt{\pi}.
Posted by Claude Code on Matt's behalf.
- 主要言語
- Python
- スター
- 1.2k
- フォーク
- 67
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
huggingface/Math-Verify のほかの issue
-
verify() raises ValueError comparing chained relations of different length対応中かも @chetana1410 が 9 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
huggingface/Math-Verify#93 ·
-
A period inside the math delimiters (`$\frac{1}{3}.$`) makes correct answers fail and can make wrong ones pass対応中かも @MohammadHijjawi97 が 32 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
huggingface/Math-Verify#85 ·
-
evaluate_model_outputs.py: rows whose gold cannot be extracted are dropped from the accuracy denominator, so the printed accuracy disagrees with the is_correct column the script writes対応中かも @shaurya416 が 37 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
huggingface/Math-Verify#83 ·
-
verify() rejects a not-equal written in the other order対応中かも @chetana1410 が 8 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
huggingface/Math-Verify#100 ·
-
verify() rejects an absolute-value inequality that is the same interval対応中かも @chetana1410 が 9 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
huggingface/Math-Verify#98 ·
huggingface/Math-Verify の issue をすべて見る
似ている issue
-
area:scripts area:tests bug priority:later
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Ikalus1988/MisakaNet#4358 ·
メンテナーはふだん 1 日以内に返信
-
Discovered ports from service discovery are never propagated to modules in Module.load()対応中かも @vishalmore90 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
OWASP/Nettacker#1828 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 88/100
aws-samples/sample-per-model-bedrock#708 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
sjkim1127/Reversecore_MCP#365 ·
メンテナーはふだん 1 日以内に返信