from transformers import BertForSequenceClassification model = BertForSequenceClassification.from_pretrained('bert-base-uncased', num_labels=2) model.save_pretrained('./hf_model')