Instructions to use mosaicml/mosaic-bert-base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mosaicml/mosaic-bert-base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="mosaicml/mosaic-bert-base", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForMaskedLM tokenizer = AutoTokenizer.from_pretrained("mosaicml/mosaic-bert-base", trust_remote_code=True) model = AutoModelForMaskedLM.from_pretrained("mosaicml/mosaic-bert-base", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
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)
jacobfulano changed discussion status to closed