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
10 changes: 6 additions & 4 deletions lmms_eval/models/chat/huggingface.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def __init__(
system_prompt: Optional[str] = None,
interleave_visuals: Optional[bool] = False,
reasoning_prompt: Optional[str] = None,
trust_remote_code: Optional[bool] = False,
**kwargs,
) -> None:
super().__init__()
Expand Down Expand Up @@ -86,24 +87,25 @@ def __init__(
if attn_implementation is not None:
model_kwargs["attn_implementation"] = attn_implementation

config = AutoConfig.from_pretrained(pretrained)
self.trust_remote_code = trust_remote_code
config = AutoConfig.from_pretrained(pretrained, trust_remote_code=trust_remote_code)
if config.model_type in AutoModelForCausalLM._model_mapping.keys():
model_cls = AutoModelForCausalLM
elif config.model_type in AutoModelForImageTextToText._model_mapping.keys():
model_cls = AutoModelForImageTextToText
else:
model_cls = AutoModel

self._model = model_cls.from_pretrained(pretrained, **model_kwargs).eval()
self._model = model_cls.from_pretrained(pretrained, trust_remote_code=trust_remote_code, **model_kwargs).eval()
self.max_num_frames = max_num_frames

raw_prompt = reasoning_prompt or system_prompt
if raw_prompt:
self.system_prompt = self._resolve_system_prompt(raw_prompt.replace("\\n", "\n"))
else:
self.system_prompt = None
self.processor = AutoProcessor.from_pretrained(pretrained)
self._tokenizer = AutoTokenizer.from_pretrained(pretrained)
self.processor = AutoProcessor.from_pretrained(pretrained, trust_remote_code=trust_remote_code)
self._tokenizer = AutoTokenizer.from_pretrained(pretrained, trust_remote_code=trust_remote_code)
self.interleave_visuals = interleave_visuals

self._config = self.model.config
Expand Down
Loading