How can we change the vocab_size in bert model arguments?

I have seen Bert Argument for fine tuning on a specific task from hugging face library:

BertConfig {
 "attention_probs_dropout_prob": 0.1,
 "hidden_act": "gelu",
 "hidden_dropout_prob": 0.1,
 "hidden_size": 768,
 "initializer_range": 0.02,
 "intermediate_size": 3072,
 "layer_norm_eps": 1e-12,
 "max_position_embeddings": 512,
 "model_type": "bert",
 "num_attention_heads": 12,
 "num_hidden_layers": 12,
 "pad_token_id": 0,
 "type_vocab_size": 2,
 "vocab_size": 30522
}

So, my question is if the Bert model is pre-trained on a specific vocab_size, Then how can one change the vocab size as changing the vocab_size is changes the meaning and embeddings of some words which are not there in pre-trained vocabulary right, then how can the transformer model will be able to capture this difference?

A quick internet search yielded this discussion:

1 Like

Thanks for providing the information, but I am not able to make proper conclusion from this and it would be a lot helpful , if we could establish a proper clear and crisp answer.
Thank you