# I have trained a model, how do I load it up?

**URL:** <https://discuss.huggingface.co/t/i-have-trained-a-model-how-do-i-load-it-up/4209>\
**Category:** Beginners\
**Created:** [March 6, 2021, 8:28pm UTC](https://discuss.huggingface.co/t/i-have-trained-a-model-how-do-i-load-it-up/4209 "2021-03-06T20:28:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![theudster](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@theudster](https://discuss.huggingface.co/u/theudster)\
**Post date:** [March 6, 2021, 8:28pm UTC](https://discuss.huggingface.co/t/i-have-trained-a-model-how-do-i-load-it-up/4209/1 "2021-03-06T20:28:18Z")

</div>

Hi, I have managed to train a model using trainer. I evaluated some results whilst the model was still on the disk using ‘trainer.predict()’. I then used `trainer.save_model()` and now want to load it up for usage again. By saving, I got three files in my drive;

1. pytorch\_model.bin
2. config.json
3. training\_args.json

I am assuming the model is pytorch\_model.bin but I am unsure how do I load it up? I trained a classification model so do I call again;

```
model = AutoModelForSequenceClassification.from_pretrained( **filepath** , 
                                                           num_labels=5,
                                                           output_attentions = False, #
                                                           output_hidden_states = False
                                                           )

```

where `filepath` is the path to pytorch\_model.bin? do I then call again a trainer and send the model to that to again use trainer.predict() for new predictions?

---

<div class="post-metadata">

**Author:** ![neuralpat](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@neuralpat](https://discuss.huggingface.co/u/neuralpat)\
**Post date:** [March 8, 2021, 7:13am UTC](https://discuss.huggingface.co/t/i-have-trained-a-model-how-do-i-load-it-up/4209/2 "2021-03-08T07:13:40Z")

</div>

You can do it in pytorch or tf like you would with any other model, or you can use [Pipelines — transformers 4.3.0 documentation](https://huggingface.co/transformers/main_classes/pipelines.html)

---

<div class="post-metadata">

**Author:** ![theudster](https://avatars.discourse-cdn.com/v4/letter/t/97f17d/32.png) [@theudster](https://discuss.huggingface.co/u/theudster)\
**Post date:** [March 8, 2021, 9:06am UTC](https://discuss.huggingface.co/t/i-have-trained-a-model-how-do-i-load-it-up/4209/3 "2021-03-08T09:06:03Z")

</div>

Thank you, just to double check, would it be like this (Im most unsure about how if this is how we call the model);

```
pipeline('sentiment-analysis', model='some_file_path/pytorch_model.bin',
 `tokenizer=tokenizer')
```

---

<div class="post-metadata">

**Author:** ![neuralpat](https://avatars.discourse-cdn.com/v4/letter/n/35a633/32.png) [@neuralpat](https://discuss.huggingface.co/u/neuralpat)\
**Post date:** [March 8, 2021, 2:44pm UTC](https://discuss.huggingface.co/t/i-have-trained-a-model-how-do-i-load-it-up/4209/4 "2021-03-08T14:44:39Z")

</div>

Looks good to me, if sentiment-analysis is what you want to do.
