Skip to content

Commit

Permalink
fix: Update logging verbosity levels in MTEB (#1384)
Browse files Browse the repository at this point in the history
* Fix verbosity handling in MTEB.py for consistent logging

* updates

* update docstrings

* linting code
  • Loading branch information
YashDThapliyal authored Nov 4, 2024
1 parent ef4df62 commit 35daf58
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
1 change: 0 additions & 1 deletion mteb/benchmarks/benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from collections.abc import Sequence
from dataclasses import dataclass
from functools import lru_cache
from typing import Annotated

from pydantic import AnyUrl, BeforeValidator, TypeAdapter
Expand Down
23 changes: 16 additions & 7 deletions mteb/evaluation/MTEB.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,10 @@ def run(
Args:
model: Model to be used for evaluation
verbosity: Verbosity level. Default is 1.
0: print tasks tqdm progress bar
1: print tasks tqdm progress bar and scores
2: print everything (including datasets loading)
0: Only shows a progress bar for tasks being processed.
1: Shows a progress bar and prints task scores.
2: Prints detailed output, including messages about loading datasets and task scores.
3: Prints comprehensive logs for debugging, including all data loading and evaluation details.
output_folder: Folder where the results will be saved. Default to 'results'. Where it will save the results in the format:
`{output_folder}/{model_name}/{model_revision}/{task_name}.json`.
eval_splits: List of splits to evaluate on. If None, the splits are taken from the task metadata.
Expand All @@ -347,10 +348,18 @@ def run(
)
encode_kwargs["batch_size"] = kwargs["batch_size"]

# Set logging
if verbosity < 2:
datasets.logging.set_verbosity(40)
datasets.logging.disable_progress_bar()
# update logging to account for different levels of Verbosity (similar to the command line)

if verbosity == 0:
datasets.logging.set_verbosity(logging.CRITICAL) # 40
datasets.logging.disable_progress_bar() # Disable progress bar
elif verbosity == 1:
datasets.logging.set_verbosity(logging.WARNING)
datasets.logging.disable_progress_bar() # Disable progress bar
elif verbosity == 2:
datasets.logging.set_verbosity(logging.INFO)
elif verbosity == 3:
datasets.logging.set_verbosity(logging.DEBUG)

meta = self.create_model_meta(model)
output_path = self.create_output_folder(meta, output_folder)
Expand Down
2 changes: 1 addition & 1 deletion mteb/leaderboard/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import gradio as gr
import numpy as np
import pandas as pd
from pandas.api.types import is_numeric_dtype, is_string_dtype
from pandas.api.types import is_numeric_dtype

from mteb.models.overview import get_model_meta
from mteb.overview import get_task
Expand Down

0 comments on commit 35daf58

Please sign in to comment.