title: how to train a bert model from scratch with huggingface?
body: <p>i find a answer of training model from scratch in this question:
  <a href="https://stackoverflow.com/questions/65646925/how-to-train-bert-from-scratch-on-a-new-domain-for-both-mlm-and-nsp">How to train BERT from scratch on a new domain for both MLM and NSP?</a></p>
  <p>one answer use Trainer and TrainingArguments like this:</p>
  <pre><code>from transformers import Trainer, TrainingArguments
  training_args = TrainingArguments(
      output_dir= &quot;/path/to/output/dir/for/training/arguments&quot;
      overwrite_output_dir=True,
      num_train_epochs=2,
      per_gpu_train_batch_size= 16,
      save_steps=10_000,
      save_total_limit=2,
      prediction_loss_only=True,
  )
  
  trainer = Trainer(
      model=model,
      args=training_args,
      data_collator=data_collator,
      train_dataset=dataset,
  )
  
  trainer.train()
  trainer.save_model(&quot;path/to/your/model&quot;)
  </code></pre>
  <p>but huggingface official doc <a href="https://huggingface.co/transformers/training.html" rel="nofollow noreferrer">Fine-tuning a pretrained model
  </a> also use Trainer and TrainingArguments in the same way to finetune .
  so when I use Trainer and TrainingArguments to train model, Do I train model from scratch or just finetune?</p>