Local inference using diff bert models without downloading it twice
I know that both use the same pre-trained base model (bert-large-uncased) and weights. They differ only in the additional task specific layers. I’m used the save_pretrained() method to download the models locally and run them in separately. But I don’t want to download redundant weights and call separate directories like this. Is there a way to use the pipeline() function without specifying different paths? The relevant code is below:import os
from transformers import BertForMaskedLM, BertForSequenceClassification
os.environ["HF_HUB_OFFLINE"] = "1" 
...

# Saving the model in 2 directories, wasting ~1.5Gb
masked_lm_model = BertForMaskedLM.from_pretrained("bert-base-uncased")
masked_lm_model.save_pretrained("./bert-mlm")
seq_class_model = BertForSequenceClassification.from_pretrained("bert-base-uncased")
seq_class_model.save_pretrained("./bert-scm")

...

# codeblock to run inference using pipeline()
mlm_pipeline = pipeline("fill-mask", model = "./bert-mlm")
mlm_pipeline("The milky way is a [MASK] galaxy")

scm_pipeline = pipeline("text-classification", model = "./bert-scm")
mlm_pipeline("I like developing code")