You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
My own task or dataset (give details below)
Reproduction
from transformers import AutoModel, AutoTokenizer, AutoConfig
# Load a custom model from the Hub
model = AutoModel.from_pretrained("jinaai/jina-embeddings-v2-base-de", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("jinaai/jina-embeddings-v2-base-de")
# Save them locally
model.save_pretrained("tmp")
tokenizer.save_pretrained("tmp")
# Now load that model again, via a Config
config = AutoConfig.from_pretrained("tmp", trust_remote_code=True)
print(config.__class__)
# <class 'transformers_modules.jinaai.jina-bert-implementation.f3ec4cf7de7e561007f27c9efc7148b0bd713f81.configuration_bert.JinaBertConfig'>
local_model = AutoModel.from_pretrained("tmp", config=config, trust_remote_code=True)
# And save it again
local_model.save_pretrained("tmp_2")
tokenizer.save_pretrained("tmp_2")
# Now load that model again, via a Config
config_2 = AutoConfig.from_pretrained("tmp_2", trust_remote_code=True)
print(config_2.__class__)
# <class 'transformers_modules.tmp_2.configuration_bert.JinaBertConfig'>
# The second time around, the config is not the same as the first time
local_model_2 = AutoModel.from_pretrained("tmp_2", config=config_2, trust_remote_code=True)
# 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.jinaai.jina-bert-implementation.f3ec4cf7de7e561007f27c9efc7148b0bd713f81.configuration_bert.JinaBertConfig'>
# and you passed <class 'transformers_modules.tmp_2.configuration_bert.JinaBertConfig'>. Fix one of those so they match!
Expected behavior
Model should load without raising a ValueError
The text was updated successfully, but these errors were encountered:
System Info
transformers
version: 4.47.1Who can help?
@ArthurZucker
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
Expected behavior
Model should load without raising a
ValueError
The text was updated successfully, but these errors were encountered: