Unable to save trained model in path
Author: pratikchhapolika
Pull request: no

I am downloading the model <https://huggingface.co/microsoft/Multilingual-MiniLM-L12-H384/tree/main> **microsoft/Multilingual-MiniLM-L12-H384** and then using it.

Transformer Version: '4.11.3'

**I have written the below code:**

```
model = tr.BertForSequenceClassification.from_pretrained("/home/pc/minilm_model",num_labels=2)
model.to(device)

print("hello")

training_args = tr.TrainingArguments(
    output_dir='/home/pc/proj/results2',          # output directory
    num_train_epochs=10,              # total number of training epochs
    per_device_train_batch_size=16,  # batch size per device during training
    per_device_eval_batch_size=32,   # batch size for evaluation
    learning_rate=2e-5,
    warmup_steps=1000,                # number of warmup steps for learning rate scheduler
    weight_decay=0.01,               # strength of weight decay
    logging_dir='./logs',            # directory for storing logs
    logging_steps=1000,
    evaluation_strategy="epoch",
    save_strategy="no"
)

print("hello")

trainer = tr.Trainer(
    model=model,                         # the instantiated 🤗 Transformers model to be trained
    args=training_args,                  # training arguments, defined above
    train_dataset=train_data,         # training dataset
    eval_dataset=val_data,             # evaluation dataset
    compute_metrics=compute_metrics
)
```

**The folder is empty after I train the model.**

**Also, is it okay to pass classes=2 for binary classification?** 

**The model last layer is simple linear connection which gives logits value. How to get probability score out of it?**

`model = tr.BertForSequenceClassification.from_pretrained("/home/pchhapolika/minilm_model",num_labels=2)`


Comments:
You are using `save_strategy="no"`, so, as requested, the model is not saved. You can add a line `trainer.save_model(xxx)` to manually save it after the training.

@sgugger  I corrected it to `save_strategy="epoch"` and it saves model with every epoch with numbers like `checkpoint-12250, checkpoint-915` so on. 

**How can we save only best model?**

**Which checkpoint means which epochs?**


You cannot save only the best model, the minimum you can do is use `save_total_timit=1` to only save a maximum of one checkpoint + the best checkpoint if you use `load_best_model_at_end=True`. Using that option will give you the best model inside the `Trainer` at the end of training, so using `trainer.save_model(xxx)` will allow you to save it where you want.

As for your other questions, you can see the numbers are all multiple of 915, so ecpoch n as a chackpoint named checkpoint-{n * 915}, and you have 915 training steps in each epoch.

> load_best_model_at_end=True

The parameter `load_best_model_at_end=True` will be inside `tr.TrainingArguments()` ?

Yes, see the [documentation](https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments.load_best_model_at_end).

> Yes, see the [documentation](https://huggingface.co/docs/transformers/main_classes/trainer#transformers.TrainingArguments.load_best_model_at_end).

Thank you.