Skip to content

Commit

Permalink
rename comparisson -> comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
hynky1999 committed Jan 13, 2025
1 parent 5aa6789 commit bb19ebb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/lighteval/metrics/dynamic_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
extract_target_from_pred,
get_extraction_regexes,
)
from lighteval.metrics.utils.math_comparisson import compare_gold_target
from lighteval.metrics.utils.math_comparison import compare_gold_target
from lighteval.metrics.utils.metric_utils import MetricCategory, MetricUseCase, SampleLevelMetric
from lighteval.tasks.requests import Doc
from lighteval.utils.language import Language
Expand Down Expand Up @@ -249,7 +249,9 @@ def sample_level_fn(golds: list[str], predictions: list[str], formatted_doc: Doc
raise ValueError(f"No gold targets found for at least one gold. Gold: {golds}, Pred: {predictions}")

if all(len(p) == 0 for p in extracted_predictions):
logger.warning(f"We did not manage to extract a prediction in the correct format. Gold: {golds}, Pred: {predictions}")
logger.warning(
f"We did not manage to extract a prediction in the correct format. Gold: {golds}, Pred: {predictions}"
)

# We have to use timeout because the sypmy to str conversion can be very slow
try:
Expand Down
6 changes: 3 additions & 3 deletions src/lighteval/metrics/utils/extractive_match_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from sympy import Basic, MatrixBase, Number
from sympy.parsing import parse_expr

from lighteval.metrics.utils.math_comparisson import should_treat_as_complex
from lighteval.metrics.utils.math_comparison import should_treat_as_complex
from lighteval.tasks.requests import Doc
from lighteval.tasks.templates.utils.formulation import ChoicePrefix, get_prefix
from lighteval.tasks.templates.utils.translation_literals import TRANSLATION_LITERALS
Expand Down Expand Up @@ -151,9 +151,9 @@ def lazy_latex_regex(latex_config: LatexExtractionConfig, language: Language) ->
r"("
r"(?<!\\)\$\$(?P<latexDisplayDollar>[\s\S]+?)(?<!\\)\$\$|" # $$...$$ (display math, can be multiline)
r"(?<!\\)\\\[(?P<latexDisplayBracket>[\s\S]+?)(?<!\\)\\\]|" # \[...\] (display math, can be multiline)
r"(?<!\\|\d)\$(?P<latexInlineDollar>(?:\\[$]|[^\n$])+?)(?<!\\)\$|" # $...$ (inline math, single line, allows escaped $), we make sure it's not preceded by a digit to minimize false positives containing dollar as a unit
r"(?<!\\|\d)\$(?P<latexInlineDollar>(?:\\[$]|[^\n$])+?)(?<!\\)\$|" # $...$ (inline math, single line, allows escaped $), we make sure it's not preceded by a digit to minimize false positives containing dollar as a unit
r"(?<!\\)\\\((?P<latexInlineParenthesis>[^\n]+?)(?<!\\)\\\)|" # \(...\) (inline math, single line)
r"(?<!\\)\[(?P<latexInlineBracket>[^\n$]+?)(?<!\\)\]" # [....] While this is not a valid display, math LLMs like to generate it. We allow it
r"(?<!\\)\[(?P<latexInlineBracket>[^\n$]+?)(?<!\\)\]" # [....] While this is not a valid display, math LLMs like to generate it. We allow it
rf"){percent_re_group}?"
)

Expand Down
2 changes: 1 addition & 1 deletion tests/metrics/test_extractive_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
LatexExtractionConfig,
multilingual_extractive_match_metric,
)
from lighteval.metrics.utils.math_comparisson import sympy_expr_eq
from lighteval.metrics.utils.math_comparison import sympy_expr_eq
from lighteval.tasks.requests import Doc
from lighteval.utils.language import Language

Expand Down

0 comments on commit bb19ebb

Please sign in to comment.