Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suppress HF warnings and lower during detector model instantiation #807

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions garak/detectors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(self, model_path, target_class, config_root=_config):
AutoTokenizer,
TextClassificationPipeline,
set_seed,
logging as transformers_logging,
)

if _config.run.seed is not None:
Expand All @@ -85,6 +86,9 @@ def __init__(self, model_path, target_class, config_root=_config):
self.detector_model_path = model_path
self.detector_target_class = target_class

orig_loglevel = transformers_logging.get_verbosity()
transformers_logging.set_verbosity_error()

self.detector_model = AutoModelForSequenceClassification.from_pretrained(
self.detector_model_path
)
Expand All @@ -95,6 +99,8 @@ def __init__(self, model_path, target_class, config_root=_config):
model=self.detector_model, tokenizer=self.detector_tokenizer
)

transformers_logging.set_verbosity(orig_loglevel)

self.graceful_fail = False

def detect(self, attempt: garak.attempt.Attempt) -> List[float]:
Expand Down
Loading