API Reference
math_utils
solve_problem
(openai<1) Solve the math problem.
Arguments:
problem
str - The problem statement.config
Optional, dict - The configuration for the API call.
Returns:
str
- The solution to the problem.
remove_boxed
Source: https://github.com/hendrycks/math Extract the text within a \boxed{…} environment.
Example:
remove_boxed(“\boxed{\frac{2}{3}}”)
\frac{2}{3}
last_boxed_only_string
Source: https://github.com/hendrycks/math Extract the last \boxed{…} or \fbox{…} element from a string.
is_equiv
Returns (as a float) whether two strings containing math are equivalent up to differences of formatting in
- units
- fractions
- square roots
- superfluous LaTeX. Source: https://github.com/hendrycks/math
is_equiv_chain_of_thought
Strips the solution first before calling is_equiv
.
eval_math_responses
Select a response for a math problem using voting, and check if the response is correct if the solution is provided.
Arguments:
responses
list - The list of responses.solution
str - The canonical solution.
Returns:
dict
- The success metrics.