Skip to content

Commit

Permalink
suppress HF warnings and lower during detector model instantiation (#807
Browse files Browse the repository at this point in the history
)
  • Loading branch information
leondz authored Jul 30, 2024
1 parent 8c9b659 commit f2e5182
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit f2e5182

Please sign in to comment.