marinone94 commited on
Commit
4123391
1 Parent(s): 3644968

delete checkpoint at the end

Browse files
Files changed (1) hide show
  1. huggingface_training.py +8 -1
huggingface_training.py CHANGED
@@ -282,8 +282,11 @@ training_args = Seq2SeqTrainingArguments(
282
  logging_steps=logging_steps,
283
  save_strategy="steps",
284
  save_steps=eval_steps,
285
- save_total_limit=2,
286
  learning_rate=1e-5,
 
 
 
287
  warmup_ratio=0.5 if test_script is True else 0.2,
288
  per_device_train_batch_size=train_bs,
289
  per_device_eval_batch_size=eval_bs,
@@ -370,4 +373,8 @@ print(final_metrics)
370
 
371
  # Pushing to hub during training slows down training
372
  # so we push it only in the end.
 
 
 
 
373
  trainer.push_to_hub()
 
282
  logging_steps=logging_steps,
283
  save_strategy="steps",
284
  save_steps=eval_steps,
285
+ # save_total_limit=2,
286
  learning_rate=1e-5,
287
+ load_best_model_at_end=True,
288
+ metric_for_best_model="wer",
289
+ greater_is_better=False,
290
  warmup_ratio=0.5 if test_script is True else 0.2,
291
  per_device_train_batch_size=train_bs,
292
  per_device_eval_batch_size=eval_bs,
 
373
 
374
  # Pushing to hub during training slows down training
375
  # so we push it only in the end.
376
+ # Since training is completed and best model has been saved, we first delete the checkpoints
377
+ for filename in os.listdir("."):
378
+ if filename.startswith("checkpoint-"):
379
+ os.remove(f"./{filename}")
380
  trainer.push_to_hub()