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

tweak: defer import of slow Llava* classes #908

Merged
merged 1 commit into from
Sep 10, 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
3 changes: 2 additions & 1 deletion garak/generators/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import backoff
import torch
from PIL import Image
from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration

from garak import _config
from garak.exception import ModelNameMissingError, GarakException
Expand Down Expand Up @@ -657,6 +656,8 @@ def __init__(self, name="", config_root=_config):
f"Invalid model name {self.name}, current support: {self.supported_models}."
)

from transformers import LlavaNextProcessor, LlavaNextForConditionalGeneration

self.device = self._select_hf_device()
model_kwargs = self._gather_hf_params(
hf_constructor=LlavaNextForConditionalGeneration.from_pretrained
Expand Down
Loading