ProkBertConfig Error

#2
by 8497prashant - opened

Hi, I ran the code as given on the model card page, and got the following error. Moreover, in whichever way I try to run it I am running it to the same or similar error. Please let me know how to move forward from here.

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-3-06ce7da147ef> in <cell line: 4>()
      2 
      3 tokenizer = AutoTokenizer.from_pretrained("neuralbioinfo/prokbert-mini-c", trust_remote_code=True)
----> 4 model = AutoModel.from_pretrained("neuralbioinfo/prokbert-mini-c", trust_remote_code=True)
      5 
      6 segment = "ATGTCCGCGGGACCT"

/usr/local/lib/python3.10/dist-packages/transformers/models/auto/auto_factory.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
    557             else:
    558                 cls.register(config.__class__, model_class, exist_ok=True)
--> 559             return model_class.from_pretrained(
    560                 pretrained_model_name_or_path, *model_args, config=config, **hub_kwargs, **kwargs
    561             )

/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, config, cache_dir, ignore_mismatched_sizes, force_download, local_files_only, token, revision, use_safetensors, *model_args, **kwargs)
   3830         with ContextManagers(init_contexts):
   3831             # Let's make sure we don't run the init function of buffer modules
-> 3832             model = cls(config, *model_args, **model_kwargs)
   3833 
   3834         # make sure we use the model's config since the __init__ call might have copied it

~/.cache/huggingface/modules/transformers_modules/neuralbioinfo/prokbert-mini-c/304ac66b7d769acd1fd1bac089d25477e3627578/models.py in __init__(self, config, **kwargs)
    195     def __init__(self, config: ProkBertConfig, **kwargs):
    196         if not isinstance(config, ProkBertConfig):
--> 197             raise ValueError(f"Expected `ProkBertConfig`, got {config.__class__.__module__}.{config.__class__.__name__}")
    198 
    199         super().__init__(config, **kwargs)

ValueError: Expected `ProkBertConfig`, got transformers_modules.neuralbioinfo.prokbert-mini-c.304ac66b7d769acd1fd1bac089d25477e3627578.models.ProkBertConfig
Neural Bioinformatics Research Group org

Hi,
it seems that the config class registrations are mixed up in transformers module.
Cleaning up the cache might help:
rm -rf ~/.cache/huggingface

Alternatively try to install the prokbert directly from the github repository: pip install git+https://github.com/nbrg-ppcu/prokbert.git
Then try the following:
from prokbert.models import ProkBertModel
ProkBertModel.from_pretrained("neuralbioinfo/prokbert-mini-c", trust_remote_code=True)

Sign up or log in to comment