Using distributed or parallel set-up in script?: No
Who can help?
No response
Information
[ ] The official example scripts
[X] My own modified scripts
Tasks
[ ] An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
[X] My own task or dataset (give details below)
Reproduction
Try loading a model from the hub that has custom code files ending in p or y
For example
import torch
from transformers import AutoModel
model = AutoModel.from_pretrained(
'BAAI/EVA-CLIP-18B',
torch_dtype=torch.float16,
trust_remote_code=True,
)
Expected behavior
The model should be loading fine. But what happens is the following error
ValueError: The model class you are passing has a `config_class` attribute that is not consistent with the config class you passed (model has <class 'transformers_modules.BAAI.EVA-CLIP-18B.ecb774f7cbba81ad031555b951e126e78f978186.configuration_evaclip.EvaCLIPConfig'> and you passed <class 'transformers_modules.BAAI.EVA-CLIP-18B.ecb774f7cbba81ad031555b951e126e78f978186.configuration_evacli.EvaCLIPConfig'>. Fix one of those so they match!
Notice how the filename configuration_evaclip is cropped to configuration_evacli
System Info
transformers
version: 4.41.1Who can help?
No response
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Try loading a model from the hub that has custom code files ending in
p
ory
For example
Expected behavior
The model should be loading fine. But what happens is the following error
Notice how the filename
configuration_evaclip
is cropped toconfiguration_evacli
The buggy code is here https://github.com/huggingface/transformers/blob/0a064dc0fcba31092868f911772df087901d90fb/src/transformers/dynamic_module_utils.py#L201
rstrip
removes all trailing characters that match these provided and not the.py
suffix