Training model file too large and fail to deploy

hi, community!

I have trained a Bert classification model with below config on sagemaker:

from sagemaker.huggingface import HuggingFace

# hyperparameters, which are passed into the training job
hyperparameters={'epochs': 5,
                 'train_batch_size': 4,

huggingface_estimator = HuggingFace(entry_point='',
                            # add volume size set up
                            hyperparameters = hyperparameters)
# starting the train job with our uploaded datasets as input{'train': training_input_path, 'test': test_input_path})

this works perfectly. however, I have two problems:

  1. the generated model file is huge: 64gb. why is that?
  2. I can’t deploy endpoint successfully, I am guessing due to the model size too big, any idea on how to solve?

Hey @jackieliu930,

Yes, I guess your artifact is so big because all saved checkpoints during training are included. You can either change your checkpoint saving strategy in your or the location where the checkpoints are saved.
Or you could load your model.tar.gz and remove all checkpoints from it and then upload it so s3 again. Documentation here: Deploy models to Amazon SageMaker
Another solution would be to upload your model to Models - Hugging Face and then deploy using HF_MODE_ID and HF_TASK.