`\frac` and `\sqrt` shorthand with a command argument (`\frac\pi4`, `\sqrt\pi`) is mangled, which can verify a wrong answer
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Lee math_normalization.py, especialmente _fix_fracs y _fix_sqrt en las líneas enlazadas. Reproduce el problema con los ejemplos proporcionados \frac\pi4 y \sqrt\pi; después, comprueba cómo las pruebas existentes cubren los argumentos abreviados. Se considera terminado cuando los argumentos de los comandos se mantienen completos en ambas funciones y los casos de verificación proporcionados producen los resultados esperados.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
_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.
- Lenguaje dominante
- Python
- Estrellas
- 1.2k
- Forks
- 67
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de huggingface/Math-Verify
-
verify() raises ValueError comparing chained relations of different lengthPosiblemente ocupada @chetana1410 la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
huggingface/Math-Verify#93 ·
-
A period inside the math delimiters (`$\frac{1}{3}.$`) makes correct answers fail and can make wrong ones passPosiblemente ocupada @MohammadHijjawi97 la tomó hace 29 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 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 writesPosiblemente ocupada @shaurya416 la tomó hace 35 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
huggingface/Math-Verify#83 ·
-
verify() rejects a not-equal written in the other orderPosiblemente ocupada @chetana1410 la tomó hace 6 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
huggingface/Math-Verify#100 ·
-
verify() rejects an absolute-value inequality that is the same intervalPosiblemente ocupada @chetana1410 la tomó hace 6 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 35/100
huggingface/Math-Verify#98 ·
Todos los issues de huggingface/Math-Verify
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
vllm-project/vllm#64845 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
dekobon/big-code-analysis#1729 ·
Los mantenedores suelen responder en 1 día
-
Add `openai_safety_identifier`, the replacement for the `user` field that `openai_user` sendsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
pydantic/pydantic-ai#12091 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100