# Exporting models

**URL:** <https://discuss.huggingface.co/t/exporting-models/4348>\
**Category:** Models\
**Created:** [March 12, 2021, 11:49am UTC](https://discuss.huggingface.co/t/exporting-models/4348 "2021-03-12T11:49:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [March 12, 2021, 11:49am UTC](https://discuss.huggingface.co/t/exporting-models/4348/1 "2021-03-12T11:49:11Z")

</div>

Hello,  
Is there possibility to download or export model and then save it, so that I can use models offline?

Thank you

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [March 12, 2021, 5:42pm UTC](https://discuss.huggingface.co/t/exporting-models/4348/2 "2021-03-12T17:42:34Z")

</div>

Hi @Katarina, sure there’s a method called `AutoModelForXXX.save_pretrained` that you can use: [Models — transformers 4.3.0 documentation](https://huggingface.co/transformers/main_classes/model.html#transformers.PreTrainedModel.save_pretrained)

You can then load the model using the `AutoModelForXXX.from_pretrained` method 🙂

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [March 15, 2021, 10:34am UTC](https://discuss.huggingface.co/t/exporting-models/4348/3 "2021-03-15T10:34:53Z")

</div>

Thank you…yes I have used this I saved model into my library and I get two files: pytorch\_model.bin and config.json but when I want to load it I get the error:  
OSError: Can’t load config for ‘/user-home/libraries/KK/scripts/config.json’. Make sure that:

- ‘/user-home/libraries/KK/scripts/config.json’ is a correct model identifier listed on ‘[Hugging Face – The AI community building the future.](https://huggingface.co/models)’

- or ‘/user-home/libraries/KK/scripts/config.json’ is the correct path to a directory containing a config.json file

Do you maybe know to tell me if I am doing something wrong…

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [March 15, 2021, 10:57am UTC](https://discuss.huggingface.co/t/exporting-models/4348/4 "2021-03-15T10:57:55Z")

</div>

Can you please share the code snippet that you are using to save and load your model? You can use three back ticks “```” to write code in Markdown 🙂

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [March 15, 2021, 11:46am UTC](https://discuss.huggingface.co/t/exporting-models/4348/5 "2021-03-15T11:46:25Z")

</div>

First I saved a model:

```auto
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("Helsinki-NLP/opus-mt-en-sla")

model = AutoModelForSeq2SeqLM.from_pretrained("Helsinki-NLP/opus-mt-en-sla")

model.save_pretrained("../packages/python/models/my_model")

```

And I checked, I have that folder created with files pytorch\_model.bin and config.json  
Then I again called it by inserting a path to the folder:

```auto
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

tokenizer = AutoTokenizer.from_pretrained("../packages/python/models/my_model")
model = AutoModelForSeq2SeqLM.from_pretrained("../packages/python/models/my_model")

```

But I get the error:

```auto
OSError: Can't load tokenizer for '../packages/python/models/my_model'. Make sure that:

- '../packages/python/models/my_model' is a correct model identifier listed on 'https://huggingface.co/models'

- or '../packages/python/models/my_model' is the correct path to a directory containing relevant tokenizer files

```

---

<div class="post-metadata">

**Author:** ![lewtun](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/lewtun/32/30995_2.png) [@lewtun](https://discuss.huggingface.co/u/lewtun)\
**Post date:** [March 15, 2021, 1:03pm UTC](https://discuss.huggingface.co/t/exporting-models/4348/6 "2021-03-15T13:03:41Z")

</div>

Ah you also need to save the tokenizer with

```auto
tokenizer.save_pretrained("../packages/python/models/my_model")

```

Does that solve your problem?

---

<div class="post-metadata">

**Author:** ![Katarina](https://avatars.discourse-cdn.com/v4/letter/k/eb8c5e/32.png) [@Katarina](https://discuss.huggingface.co/u/Katarina)\
**Post date:** [March 15, 2021, 1:44pm UTC](https://discuss.huggingface.co/t/exporting-models/4348/7 "2021-03-15T13:44:50Z")

</div>

yes, thank you:)
