ValueError: The model class you are passing has a `config_class` attribute that is not consistent with the config class

#1
by oualidlamrini - opened

Hi ,
I have encountered an error using the ccdv/lsg-distilroberta-base-4096 model for classification purpose (long documents classification) .
Here there are some helpful information :

  • Environment : Kaggle with GPU T4 x 2 && transfomers== 4.40.2
  • Error :
    File /opt/conda/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py:557, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    555 model_class.register_for_auto_class(cls.name)
    556 else:
    --> 557 cls.register(config.class, model_class, exist_ok=True)
    558 return model_class.from_pretrained(
    559 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
    560 )
    561 elif type(config) in cls._model_mapping.keys():

File /opt/conda/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py:583, in _BaseAutoModelClass.register(cls, config_class, model_class, exist_ok)
573 """
574 Register a new model for this class.
575
(...)
580 The model to register.
581 """
582 if hasattr(model_class, "config_class") and model_class.config_class != config_class:
--> 583 raise ValueError(
584 "The model class you are passing has a config_class attribute that is not consistent with the "
585 f"config class you passed (model has {model_class.config_class} and you passed {config_class}. Fix "
586 "one of those so they match!"
587 )
588 cls._model_mapping.register(config_class, model_class, exist_ok=exist_ok)

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.ccdv.lsg-xlm-roberta-base-4096.f9e0ca0a7236834d5dda918519c94638aab30599.modeling_lsg_xlm_roberta.LSGXLMRobertaConfig'> and you passed <class 'transformers_modules.ccdv.lsg-xlm-roberta-base-4096.f9e0ca0a7236834d5dda918519c94638aab30599.modeling_lsg_xlm_roberta.LSGXLMRobertaConfig'>. Fix one of those so they match!
Thanks in advance!

Owner

Can you provide a piece of code ?

I'm sorry for the delay in response. I just tried it on Google Colab, and the problem was solved without doing anything.
Thank you so much for your response.

ccdv changed discussion status to closed

Sign up or log in to comment