Value Error (and my Fix)
#6
by
reeceshuttle
- opened
Problem:
when i run the following code provided
from transformers import AutoModelForMaskedLM
mlm = AutoModelForMaskedLM.from_pretrained('mosaicml/mosaic-bert-base', trust_remote_code=True)
I get this 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.models.bert.configuration_bert.BertConfig'> and you passed <class 'transformers_modules.mosaicml.mosaic-bert-base.ce11e478cf0188df92930d4cf4e31e1a1db54b67.configuration_bert.BertConfig'>. Fix one of those so they match!
Fix:
from transformers import AutoModelForMaskedLM, AutoConfig
config = AutoConfig.from_pretrained('mosaicml/mosaic-bert-base')
mlm = AutoModelForMaskedLM.from_pretrained('mosaicml/mosaic-bert-base', config=config, trust_remote_code=True)
Thanks for catching this! We have updated the model card and also linked to a colab notebook here
jacobfulano
changed discussion status to
closed