Skip to content

Commit

Permalink
detect if tokenizer is not loaded and adjust (#1012)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin-tech committed Nov 20, 2024
2 parents e28aeca + ead3cb0 commit 515da0d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions garak/generators/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ def _load_client(self):

pipeline_kwargs = self._gather_hf_params(hf_constructor=pipeline)
self.generator = pipeline("text-generation", **pipeline_kwargs)
if self.generator.tokenizer is None:
# account for possible model without a stored tokenizer
from transformers import AutoTokenizer

self.generator.tokenizer = AutoTokenizer.from_pretrained(
pipeline_kwargs["model"]
)
if not hasattr(self, "deprefix_prompt"):
self.deprefix_prompt = self.name in models_to_deprefix
if _config.loaded:
Expand Down

0 comments on commit 515da0d

Please sign in to comment.