# How to continue training a model from where it left off?

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-continue-training-a-model-from-where-it-left-off%2F105361%3E%5C
**Category:** 🤗Transformers\
**Created:** [September 5, 2024, 3:21am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-continue-training-a-model-from-where-it-left-off%2F105361 "2024-09-05T03:21:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SiqueiraJonas](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/siqueirajonas/32/31241_2.png) [@SiqueiraJonas](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSiqueiraJonas)%5C
**Post date:** [September 5, 2024, 3:21am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-continue-training-a-model-from-where-it-left-off%2F105361%2F1 "2024-09-05T03:21:52Z")

</div>

I would like to know how I can save checkpoints when training a text classification model so that I can continue training from where it left off.

I’m having trouble and don’t know how to configure my code to save the checkpoints with the appropriate files so that I can continue training at the point where it ended previously, such as “trainer\_state.json”.

Here is my training code:

```
def executar_treinamento(self, base_treinada):
    training_args = TrainingArguments(
        output_dir=self.output_dir,
        activation_checkpointing=True,
        learning_rate=2e-5,
        per_device_train_batch_size=8,
        per_device_eval_batch_size=8,
        num_train_epochs=8,
        weight_decay=0.01,
        evaluation_strategy="epoch",
        save_strategy="steps",
        save_only_model=False,
        load_best_model_at_end=False
    )

    self.trainer = Trainer(
        model=self.model,
        args=training_args,
        compute_metrics=self.calcular_metricas,
        train_dataset=base_treinada['train'],
        eval_dataset=base_treinada['validation'],
        tokenizer=self.tokenizar_textos
    )
    
    self.trainer.train()

def avaliar_modelo(self, base_treinada):
    self.trainer.evaluate(base_treinada['test'])

def salvar_modelo(self, caminho):
    self.model.save_pretrained(caminho)
    self.tokenizer.save_pretrained(caminho)

```
