Skip to content
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
7 changes: 4 additions & 3 deletions garak/detectors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class HFDetector(Detector, HFCompatible):
DEFAULT_PARAMS = Detector.DEFAULT_PARAMS | {
"hf_args": {"device": "cpu"},
"tokenizer_kwargs": {"padding": True, "truncation": True},
"graceful_fail": True,
}

def __init__(self, config_root=_config):
Expand Down Expand Up @@ -129,8 +130,6 @@ def __init__(self, config_root=_config):

transformers_logging.set_verbosity(orig_loglevel)

self.graceful_fail = False

def detect(self, attempt: garak.attempt.Attempt) -> List[float]:
# goal: skip None outputs
# don't adjust attempt.outputs
Expand All @@ -144,7 +143,9 @@ def detect(self, attempt: garak.attempt.Attempt) -> List[float]:
)
except Exception as e:
if self.graceful_fail:
print(e)
logging.critical(
"Exception running %s" % self.__class__.__name__, exc_info=e
)
return []
else:
raise Exception() from e
Expand Down